| Index: third_party/libadblockplus/download_ndk.py |
| diff --git a/third_party/libadblockplus/download_ndk.py b/third_party/libadblockplus/download_ndk.py |
| index 77a77231004ae514e1cf3b4d9040aab847ef1d29..7184c704b1b736b22c41c04a4acebedba8b2f721 100644 |
| --- a/third_party/libadblockplus/download_ndk.py |
| +++ b/third_party/libadblockplus/download_ndk.py |
| @@ -2,39 +2,51 @@ import os |
| import urllib |
| import zipfile |
| import sys |
| +import shutil |
| -def main(argv): |
| - # Download |
| - ndk_src = 'https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip' |
| - |
| - cwd = os.getcwd() |
| - libadblockplus_root = os.path.join(cwd, 'src', 'third_party', 'libadblockplus', 'third_party') |
| - ndk_dst = os.path.join(libadblockplus_root, 'android-ndk-r12b-linux-x86_64.zip') |
| - if os.path.exists(ndk_dst): |
| +def main(argv): |
| + # Download |
| + ndk_src = 'https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip' |
| + |
| + cwd = os.getcwd() |
| + libadblockplus_root = os.path.join(cwd, |
|
sergei
2018/01/18 09:16:51
I think it's rather libadblockplus_third_party_dir
anton
2018/01/18 12:20:26
Done. See patch set #6
|
| + 'src', 'third_party', |
| + 'libadblockplus', 'third_party') |
|
sergei
2018/01/18 09:16:50
Why not to put it into cwd/src/third_party?
anton
2018/01/18 09:49:12
it's required for libadblockplus (and libadblockpl
|
| + ndk_dst = os.path.join(libadblockplus_root, |
| + 'android-ndk-r12b-linux-x86_64.zip') |
| + |
| + if os.path.exists(ndk_dst): |
| + os.remove(ndk_dst) |
| + |
| + print('Downloading {} to {}'.format(ndk_src, ndk_dst)) |
| + urllib.urlretrieve(ndk_src, ndk_dst) |
| + |
| + # Delete existing NDK directory |
| + ndk_dir = os.path.join(libadblockplus_root, 'android-ndk-r12b') |
|
anton
2018/01/18 08:25:45
Previously we deleted whole 'third_party' includin
|
| + if os.path.exists(ndk_dir): |
| + print('Deleting {}'.format(ndk_dir)) |
| + shutil.rmtree(ndk_dir) |
| + |
| + # Extract zip (preserving file permissions) |
| + print('Extracting {} to {}'.format(ndk_dst, libadblockplus_root)) |
| + with zipfile.ZipFile(ndk_dst, 'r') as zf: |
|
sergei
2018/01/18 09:16:50
Taking into account the number of files I would pr
anton
2018/01/18 09:49:12
zip python library does not keep permissions ("exe
|
| + for info in zf.infolist(): |
| + zf.extract(info.filename, path=libadblockplus_root) |
| + out_path = os.path.join(libadblockplus_root, info.filename) |
| + |
| + perm = info.external_attr >> 16L |
| + os.chmod(out_path, perm) |
| + |
| + # Delete zip |
| os.remove(ndk_dst) |
| - print('Downloading %s to %s' % (ndk_src, ndk_dst)) |
| - urllib.urlretrieve(ndk_src, ndk_dst) |
| - |
| - # Extract zip (preserving file permissions) |
| - print('Extracting %s to %s' % (ndk_dst, libadblockplus_root)) |
| - with zipfile.ZipFile(ndk_dst, 'r') as zf: |
| - for info in zf.infolist(): |
| - zf.extract(info.filename, path=libadblockplus_root) |
| - out_path = os.path.join(libadblockplus_root, info.filename) |
| - |
| - perm = info.external_attr >> 16L |
| - os.chmod(out_path, perm) |
| - |
| - # Delete zip |
| - os.remove(ndk_dst) |
| + return 0 |
| - return 0 |
| if '__main__' == __name__: |
| - try: |
| - sys.exit(main(sys.argv[1:])) |
| - except KeyboardInterrupt: |
| - sys.stderr.write('interrupted\n') |
| - sys.exit(1) |
| + try: |
| + sys.exit(main(sys.argv[1:])) |
| + except KeyboardInterrupt: |
| + sys.stderr.write('interrupted\n') |
| + sys.exit(1) |