8000 Merge branch 'wexi-local' · pygame/python-for-android@05117c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 05117c2

Browse files
committed
Merge branch 'wexi-local'
2 parents 129cbfa + a88f3b7 commit 05117c2

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

pythonforandroid/recipe.py

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from six import PY2, with_metaclass
77

88
import hashlib
9+
from re import match
910

1011
import sh
1112
import shutil
@@ -349,51 +350,58 @@ def download(self):
349350
return
350351

351352
url = self.versioned_url
353+
ma = match(u'^(.+)#md5=([0-9a-f]{32})$', url)
354+
if ma: # fragmented URL?
355+
if self.md5sum:
356+
raise ValueError(
357+
('Received md5sum from both the {} recipe '
358+
'and its url').format(self.name))
359+
url = ma.group(1)
360+
expected_md5 = ma.group(2)
361+
else:
362+
expected_md5 = self.md5sum
352363

353364
shprint(sh.mkdir, '-p', join(self.ctx.packages_path, self.name))
354365

355366
with current_directory(join(self.ctx.packages_path, self.name)):
356367
filename = shprint(sh.basename, url).stdout[:-1].decode('utf-8')
357368

358369
do_download = True
359-
360370
marker_filename = '.mark-{}'.format(filename)
361371
if exists(filename) and isfile(filename):
362372
if not exists(marker_filename):
363373
shprint(sh.rm, filename)
364-
elif self.md5sum:
374+
elif expected_md5:
365375
current_md5 = md5sum(filename)
366-
if current_md5 == self.md5sum:
367-
debug('Checked md5sum: downloaded expected content!')
368-
do_download = False
369-
else:
370-
info('Downloaded unexpected content...')
376+
if current_md5 != expected_md5:
371377
debug('* Generated md5sum: {}'.format(current_md5))
372-
debug('* Expected md5sum: {}'.format(self.md5sum))
373-
378+
debug('* Expected md5sum: {}'.format(expected_md5))
379+
raise ValueError(
380+
('Generated md5sum does not match expected md5sum '
381+
'for {} recipe').format(self.name))
382+
do_download = False
374383
else:
375384
do_download = False
376-
info('{} download already cached, skipping'
377-
.format(self.name))
378385

379386
# If we got this far, we will download
380387
if do_download:
381388
debug('Downloading {} from {}'.format(self.name, url))
382389

383390
shprint(sh.rm, '-f', marker_filename)
384-
self.download_file(url, filename)
391+
self.download_file(self.versioned_url, filename)
385392
shprint(sh.touch, marker_filename)
386393

387-
if exists(filename) and isfile(filename) and self.md5sum:
394+
if exists(filename) and isfile(filename) and expected_md5:
388395
current_md5 = md5sum(filename)
389-
if self.md5sum is not None:
390-
if current_md5 == self.md5sum:
391-
debug('Checked md5sum: downloaded expected content!')
392-
else:
393-
info('Downloaded unexpected content...')
396+
if expected_md5 is not None:
397+
if current_md5 != expected_md5:
394398
debug('* Generated md5sum: {}'.format(current_md5))
395-
debug('* Expected md5sum: {}'.format(self.md5sum))
396-
exit(1)
399+
debug('* Expected md5sum: {}'.format(expected_md5))
400+
raise ValueError(
401+
('Generated md5sum does not match expected md5sum '
402+
'for {} recipe').format(self.name))
403+
else:
404+
info('{} download already cached, skipping'.format(self.name))
397405

398406
def unpack(self, arch):
399407
info_main('Unpacking {} for {}'.format(self.name, arch))
@@ -421,6 +429,9 @@ def unpack(self, arch):
421429

422430
filename = shprint(
423431
sh.basename, self.versioned_url).stdout[:-1].decode('utf-8')
432+
ma = match(u'^(.+)#md5=([0-9a-f]{32})$', filename)
433+
if ma: # fragmented URL?
434+
filename = ma.group(1)
424435

425436
with current_directory(build_dir):
426437
directory_name = self.get_build_dir(arch)

0 commit comments

Comments
 (0)
0