Skip to content

Commit 588b2d3

Browse files
committed
Merge branch 'thopiekar-master-fix-referenced-before-assignment-recipe'
2 parents 1b338a8 + f6c1db1 commit 588b2d3

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

pythonforandroid/recipe.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from urlparse import urlparse
1515
except ImportError:
1616
from urllib.parse import urlparse
17-
from pythonforandroid.logger import (logger, info, warning, error, shprint, info_main)
17+
from pythonforandroid.logger import (logger, info, warning, error, debug, shprint, info_main)
1818
from pythonforandroid.util import (urlretrieve, current_directory, ensure_dir)
1919

2020
# this import is necessary to keep imp.load_source from complaining :)
@@ -360,11 +360,15 @@ def download(self):
360360
if not exists(marker_filename):
361361
shprint(sh.rm, filename)
362362
elif self.md5sum:
363-
current_md5 = shprint(sh.md5sum, filename)
364-
print('downloaded md5: {}'.format(current_md5))
365-
print('expected md5: {}'.format(self.md5sum))
366-
print('md5 not handled yet, exiting')
367-
exit(1)
363+
current_md5 = shprint(sh.md5sum, filename).split()[0]
364+
if current_md5 == self.md5sum:
365+
debug('Downloaded expected content!')
366+
do_download = False
367+
else:
368+
info('Downloaded unexpected content...')
369+
debug('* Generated md5sum: {}'.format(current_md5))
370+
debug('* Expected md5sum: {}'.format(self.md5sum))
371+
368372
else:
369373
do_download = False
370374
info('{} download already cached, skipping'
@@ -375,17 +379,22 @@ def download(self):
375379

376380
# If we got this far, we will download
377381
if do_download:
378-
print('Downloading {} from {}'.format(self.name, url))
382+
debug('Downloading {} from {}'.format(self.name, url))
379383

380384
shprint(sh.rm, '-f', marker_filename)
381385
self.download_file(url, filename)
382386
shprint(sh.touch, marker_filename)
383387

384-
if self.md5sum is not None:
385-
print('downloaded md5: {}'.format(current_md5))
386-
print('expected md5: {}'.format(self.md5sum))
387-
print('md5 not handled yet, exiting')
388-
exit(1)
388+
if exists(filename) and isfile(filename) and self.md5sum:
389+
current_md5 = shprint(sh.md5sum, filename).split()[0]
390+
if self.md5sum is not None:
391+
if current_md5 == self.md5sum:
392+
debug('Downloaded expected content!')
393+
else:
394+
info('Downloaded unexpected content...')
395+
debug('* Generated md5sum: {}'.format(current_md5))
396+
debug('* Expected md5sum: {}'.format(self.md5sum))
397+
exit(1)
389398

390399
def unpack(self, arch):
391400
info_main('Unpacking {} for {}'.format(self.name, arch))

pythonforandroid/recipes/sdl2/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class LibSDL2Recipe(BootstrapNDKRecipe):
77
version = "2.0.4"
88
url = "https://www.libsdl.org/release/SDL2-{version}.tar.gz"
9+
md5sum = '44fc4a023349933e7f5d7a582f7b886e'
910

1011
dir_name = 'SDL'
1112

0 commit comments

Comments
 (0)