[143778] contrib/pypi2port/pypi2port.py
raimue at macports.org
raimue at macports.org
Mon Dec 21 04:47:51 PST 2015
Revision: 143778
https://trac.macports.org/changeset/143778
Author: raimue at macports.org
Date: 2015-12-21 04:47:51 -0800 (Mon, 21 Dec 2015)
Log Message:
-----------
pypi2port:
Improve checksum handling and printing.
Include md5 checksum for manual verification against pypi.
Modified Paths:
--------------
contrib/pypi2port/pypi2port.py
Modified: contrib/pypi2port/pypi2port.py
===================================================================
--- contrib/pypi2port/pypi2port.py 2015-12-21 11:53:42 UTC (rev 143777)
+++ contrib/pypi2port/pypi2port.py 2015-12-21 12:47:51 UTC (rev 143778)
@@ -284,20 +284,16 @@
print("Attempting to fetch distfiles...")
file_name = fetch_url(pkg_name, pkg_version, True)
if file_name:
- checksums = []
+ checksums = {}
try:
print("Generating checksums...")
- command = "openssl rmd160 "+file_name
- command = command.split()
- rmd160 = str(subprocess.check_output(command, stderr=subprocess.STDOUT))
- rmd160 = rmd160.split('=')[1][1:-3]
- checksums.insert(0, rmd160)
- command = "openssl sha256 "+file_name
- command = command.split()
- sha256 = str(subprocess.check_output(command, stderr=subprocess.STDOUT))
- sha256 = sha256.split('=')[1][1:-3]
- checksums.insert(1, sha256)
+ for chk in ['md5', 'rmd160', 'sha256']:
+ command = "openssl " + chk + " " + file_name
+ command = command.split()
+ val = str(subprocess.check_output(command, stderr=subprocess.STDOUT))
+ val = val.split('=')[1][1:-3]
+ checksums[chk] = val
dir = '/'.join(file_name.split('/')[0:-1])
if flag:
@@ -573,10 +569,19 @@
print(("Attempting to generate checksums for " + dict['name'] + "..."))
checksums_values = checksums(dict['name'], dict['version'])
if checksums_values:
- file.write('checksums rmd160 {0} \\\n'.format(checksums_values[0]))
- file.write(' sha256 {0}\n\n'.format(checksums_values[1]))
+ first=True
+ for chk in sorted(checksums_values.keys()):
+ if first:
+ file.write('checksums ')
+ first=False
+ else:
+ file.write(' \\\n')
+ file.write(' ')
+ file.write('{0: <6} {1}'.format(chk, checksums_values[chk]))
+ file.write('\n\n')
else:
- file.write('checksums rmd160 XXX \\\n')
+ file.write('checksums md5 XXX \\\n')
+ file.write(' rmd160 XXX \\\n')
file.write(' sha256 XXX\n\n')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20151221/47b47fe3/attachment.html>
More information about the macports-changes
mailing list