···22 for x in packages:
2324 md5 = x['md5']
000000025 tarball = x['tarball']
2627 url = construct_url(x)
28 print('url: {}'.format(url), file=sys.stderr)
2930- path = download(url, tarball, md5)
31 print('path: {}'.format(path), file=sys.stderr)
3233 sha256 = get_sha256(path)
···38 print(' url = "{}";'.format(url))
39 print(' sha256 = "{}";'.format(sha256))
40 print(' md5 = "{}";'.format(md5))
41- print(' md5name = "{}-{}";'.format(md5,tarball))
42 print(' }')
4344 print(']')
···53 x.get('subdir', ''), x['md5'], x['tarball'])
545556-def download(url, name, md5):
57- cmd = ['nix-prefetch-url', url, md5, '--print-path',
58- '--type', 'md5', '--name', name]
59 proc = subprocess.run(cmd, stdout=subprocess.PIPE, check=True,
60 universal_newlines=True)
61 return proc.stdout.split('\n')[1].strip()
···114 Groups lines according to their order within the file, to support
115 packages that are listed in `download.lst` more than once.
116 """
117- keys = ['tarball', 'md5', 'brief']
118 a = {k: [x for x in xs if k in x['attrs']] for k in keys}
119 return zip(*[a[k] for k in keys])
120···220221 def get_value(k):
222 x = symbols.get(k)
223- return x['value'] if x is not None else None
224225 for x in xs:
226 yield dict_merge([{'value': sub_str(x['value'], get_value)},
···249 Output: One of 1. Dict with keys 'name' and 'attrs'
250 2. 'unrecognized' (if interpretation failed)
251 """
252- for f in [interpret_md5, interpret_tarball_with_md5, interpret_tarball]:
253 result = f(x)
254 if result is not None:
255 return result
···267268 if match:
269 return {'name': match.group(1),
270- 'attrs': {'md5': x['value']}}
271000000272273def interpret_tarball(x):
274 """
···301 return {'name': match['key'].group(1),
302 'attrs': {'tarball': match['value'].group('tarball'),
303 'md5': match['value'].group('md5'),
0304 'brief': False}}
305306
···22 for x in packages:
2324 md5 = x['md5']
25+ upstream_sha256 = x['sha256']
26+ if upstream_sha256:
27+ hash = upstream_sha256
28+ hashtype = 'sha256'
29+ else:
30+ hash = md5
31+ hashtype = 'md5'
32 tarball = x['tarball']
3334 url = construct_url(x)
35 print('url: {}'.format(url), file=sys.stderr)
3637+ path = download(url, tarball, hash, hashtype)
38 print('path: {}'.format(path), file=sys.stderr)
3940 sha256 = get_sha256(path)
···45 print(' url = "{}";'.format(url))
46 print(' sha256 = "{}";'.format(sha256))
47 print(' md5 = "{}";'.format(md5))
48+ print(' md5name = "{}-{}";'.format(md5 or upstream_sha256,tarball))
49 print(' }')
5051 print(']')
···60 x.get('subdir', ''), x['md5'], x['tarball'])
616263+def download(url, name, hash, hashtype):
64+ cmd = ['nix-prefetch-url', url, hash, '--print-path',
65+ '--type', hashtype, '--name', name]
66 proc = subprocess.run(cmd, stdout=subprocess.PIPE, check=True,
67 universal_newlines=True)
68 return proc.stdout.split('\n')[1].strip()
···121 Groups lines according to their order within the file, to support
122 packages that are listed in `download.lst` more than once.
123 """
124+ keys = ['tarball', 'md5', 'sha256', 'brief']
125 a = {k: [x for x in xs if k in x['attrs']] for k in keys}
126 return zip(*[a[k] for k in keys])
127···227228 def get_value(k):
229 x = symbols.get(k)
230+ return x['value'] if x is not None else ''
231232 for x in xs:
233 yield dict_merge([{'value': sub_str(x['value'], get_value)},
···256 Output: One of 1. Dict with keys 'name' and 'attrs'
257 2. 'unrecognized' (if interpretation failed)
258 """
259+ for f in [interpret_md5, interpret_sha256, interpret_tarball_with_md5, interpret_tarball]:
260 result = f(x)
261 if result is not None:
262 return result
···274275 if match:
276 return {'name': match.group(1),
277+ 'attrs': {'md5': x['value'], 'sha256': ''}}
278279+def interpret_sha256(x):
280+ match = re.match('^(.*)_SHA256SUM$', x['key'])
281+282+ if match:
283+ return {'name': match.group(1),
284+ 'attrs': {'sha256': x['value'], 'md5': ''}}
285286def interpret_tarball(x):
287 """
···314 return {'name': match['key'].group(1),
315 'attrs': {'tarball': match['value'].group('tarball'),
316 'md5': match['value'].group('md5'),
317+ 'sha256': '',
318 'brief': False}}
319320