Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with Python 2.6 #12

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions bin/rpm-s3
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,38 @@ 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 <http://fedoranews.org/tchung/gpg/>"""
# TODO: check if file is indeed signed
cmd = "rpm --resign '%s'" % rpmfile
logging.info(cmd)
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 <http://fedoranews.org/tchung/gpg/>"""
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)
Expand All @@ -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"""
Expand Down Expand Up @@ -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 <location> tags of primary.xml.gz
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion vendor/createrepo/createrepo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vendor/createrepo/createrepo/deltarpms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion vendor/createrepo/createrepo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vendor/createrepo/modifyrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down