Skip to content

Commit

Permalink
Generate repomd.xml.asc
Browse files Browse the repository at this point in the history
  • Loading branch information
crohr committed Jan 20, 2015
1 parent f76c9a2 commit f0ec8dc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions bin/rpm-s3
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ def sign(rpmfile):
logging.error("Unable to sign package: %s", e)
exit(1)

def sign_metadata(repomdfile):
"""Requires a proper ~/.rpmmacros file. See <http://fedoranews.org/tchung/gpg/>"""
cmd = "gpg --detach-sign --armor '%s'" % repomdfile
logging.info(cmd)
try:
child = pexpect.spawn(cmd)
child.expect(pexpect.EOF)
except pexpect.EOF, e:
print "Unable to sign repository metadata '%s' - %s" % (repomdfile, child.before)
logging.error("Unable to sign repository metadata: %s", e)
exit(1)

def setup_repository(repo, repopath):
"""Make sure a repo is present at repopath"""
key = repo._grab.check("repodata/repomd.xml")
Expand Down Expand Up @@ -193,6 +205,11 @@ def update_repodata(repopath, rpmfiles, options):
logging.info("rpmfile: %s", rpmfile)
s3grabber.upload(rpmfile, os.path.basename(rpmfile))


# Generate repodata/repomd.xml.asc
if options.sign:
sign_metadata(os.path.join(tmpdir, 'repodata', 'repomd.xml'))

# Replace metadata on s3
s3grabber.syncdir(os.path.join(tmpdir, 'repodata'), 'repodata')

Expand Down
8 changes: 7 additions & 1 deletion test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ set -e

DIR=$( cd "$( dirname "$0" )" && pwd )
ROOT_DIR="$(dirname "$DIR")"
TMPDIR=$(mktemp -d)

cp -r ${DIR}/.gnupg $TMPDIR/
chmod 0700 $TMPDIR/.gnupg
cp ${DIR}/.rpmmacros $TMPDIR/

# used to get .rpmmacros and .gnupg
HOME="$DIR"
HOME="$TMPDIR"
echo "HOME=$HOME"

$ROOT_DIR/bin/rpm-s3 -b ${BUCKET:="pkgr-development-rpm"} -v -p gh/crohr/test/centos6/master --sign --keep 1000 ${DIR}/*.rpm

Expand Down

0 comments on commit f0ec8dc

Please sign in to comment.