diff --git a/bin/rpm-s3 b/bin/rpm-s3 index e6decef..6d27bdc 100755 --- a/bin/rpm-s3 +++ b/bin/rpm-s3 @@ -111,15 +111,15 @@ def getclient(base, region): return boto.connect_s3( os.getenv('AWS_ACCESS_KEY'), os.getenv('AWS_SECRET_KEY'), - host="s3-{}.amazonaws.com".format(region) + host="s3-{0}.amazonaws.com".format(region) ).get_bucket(base.netloc) else: return boto.connect_s3( - host="s3-{}.amazonaws.com".format(region) + host="s3-{0}.amazonaws.com".format(region) ).get_bucket(base.netloc) -def sign(rpmfile): +def sign(rpmfile, options): """Requires a proper ~/.rpmmacros file. See """ # TODO: check if file is indeed signed cmd = "rpm --resign '%s'" % rpmfile @@ -127,16 +127,22 @@ def sign(rpmfile): try: child = pexpect.spawn(cmd) child.expect('Enter pass phrase: ') - child.sendline('') + child.sendline(options.passphrase) child.expect(pexpect.EOF) except pexpect.EOF, e: print "Unable to sign package '%s' - %s" % (rpmfile, child.before) logging.error("Unable to sign package: %s", e) exit(1) -def sign_metadata(repomdfile): +def sign_metadata(repomdfile, options): """Requires a proper ~/.rpmmacros file. See """ - cmd = ["gpg", "--detach-sign", "--armor", repomdfile] + if options.batch: + passphrase_file = open("passphrase", "w") + passphrase_file.write(options.passphrase) + passphrase_file.flush() + cmd = ["gpg", "--detach-sign", "--armor", "--batch", "--no-tty", "--passphrase-file", "passphrase", repomdfile] + else: + cmd = ["gpg", "--detach-sign", "--armor", repomdfile] logging.info(cmd) try: subprocess.check_call(cmd) @@ -145,6 +151,10 @@ def sign_metadata(repomdfile): print "Unable to sign repository metadata '%s'" % (repomdfile) logging.error("Unable to sign repository metadata: %s", e) exit(1) + finally: + if options.batch: + passphrase_file.close() + os.unlink("passphrase") def setup_repository(repo, repopath): """Make sure a repo is present at repopath""" @@ -190,7 +200,7 @@ def update_repodata(repopath, rpmfiles, options): logging.info("rpmfile: %s", rpmfile) if options.sign: - sign(rpmfile) + sign(rpmfile, options) mdgen._grabber = filegrabber # please, don't mess with my path in the tags of primary.xml.gz @@ -228,7 +238,7 @@ def update_repodata(repopath, rpmfiles, options): # Generate repodata/repomd.xml.asc if options.sign: - sign_metadata(os.path.join(tmpdir, 'repodata', 'repomd.xml')) + sign_metadata(os.path.join(tmpdir, 'repodata', 'repomd.xml'), options) # Replace metadata on s3 s3grabber.syncdir(os.path.join(tmpdir, 'repodata'), 'repodata') @@ -257,5 +267,7 @@ if __name__ == '__main__': parser.add_option('-l', '--logfile') parser.add_option('-d', '--delete', action='store_true', default=False) parser.add_option('-r', '--region', default='eu-central-1') + parser.add_option('-B', '--batch', default=False) + parser.add_option('-P', '--passphrase', default='') options, args = parser.parse_args() main(options, args) diff --git a/vendor/createrepo/createrepo/__init__.py b/vendor/createrepo/createrepo/__init__.py index ef63e57..fa5f5b1 100644 --- a/vendor/createrepo/createrepo/__init__.py +++ b/vendor/createrepo/createrepo/__init__.py @@ -63,7 +63,7 @@ def __init__(self): self.excludes = [] self.baseurl = None self.groupfile = None - self.sumtype = 'sha256' + self.sumtype = 'sha1' self.pretty = False self.cachedir = None self.use_cache = False diff --git a/vendor/createrepo/createrepo/deltarpms.py b/vendor/createrepo/createrepo/deltarpms.py index 3edcbb5..89d3b6e 100644 --- a/vendor/createrepo/createrepo/deltarpms.py +++ b/vendor/createrepo/createrepo/deltarpms.py @@ -36,7 +36,7 @@ def __init__(self, po, basedir, filename): del stats except OSError, e: raise MDError, "Error Stat'ing file %s%s" % (basedir, filename) - self.csum_type = 'sha256' + self.csum_type = 'sha1' self.relativepath = filename self.po = po diff --git a/vendor/createrepo/createrepo/utils.py b/vendor/createrepo/createrepo/utils.py index b0d92ec..e4a73e8 100644 --- a/vendor/createrepo/createrepo/utils.py +++ b/vendor/createrepo/createrepo/utils.py @@ -167,7 +167,7 @@ def checkAndMakeDir(directory): result = True return result -def checksum_and_rename(fn_path, sumtype='sha256'): +def checksum_and_rename(fn_path, sumtype='sha1'): """checksum the file rename the file to contain the checksum as a prefix return the new filename""" csum = misc.checksum(sumtype, fn_path) diff --git a/vendor/createrepo/modifyrepo.py b/vendor/createrepo/modifyrepo.py index 3c8a8bd..ff81b52 100755 --- a/vendor/createrepo/modifyrepo.py +++ b/vendor/createrepo/modifyrepo.py @@ -218,7 +218,7 @@ def main(args): unique_md_filenames = re.match(r'[0-9a-f]{32,}-', name) != None compress_type = name.rsplit('.', 1)[1] except RepoMDError: - sumtype = 'sha256' + sumtype = 'sha1' unique_md_filenames = True compress_type = 'gz'