Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 import os | 1 import os |
2 import urllib | 2 import urllib |
3 import zipfile | 3 import zipfile |
4 import sys | 4 import sys |
5 import shutil | 5 import shutil |
6 | 6 |
7 | 7 |
8 def main(argv): | 8 def main(argv): |
9 # Download | 9 # Download |
10 ndk_src = 'https://dl.google.com/android/repository/android-ndk-r12b-linux-x 86_64.zip' | 10 ndk_src = 'https://dl.google.com/android/repository/android-ndk-r12b-linux-x 86_64.zip' |
11 | 11 |
12 cwd = os.getcwd() | 12 cwd = os.getcwd() |
13 libadblockplus_root = os.path.join(cwd, | 13 libadblockplus_third_party = 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
| |
14 'src', 'third_party', | 14 'src', 'third_party', |
15 'libadblockplus', 'third_party') | 15 '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
| |
16 ndk_dst = os.path.join(libadblockplus_root, | 16 ndk_dst = os.path.join(libadblockplus_third_party, |
17 'android-ndk-r12b-linux-x86_64.zip') | 17 'android-ndk-r12b-linux-x86_64.zip') |
18 | 18 |
19 if os.path.exists(ndk_dst): | 19 if os.path.exists(ndk_dst): |
20 os.remove(ndk_dst) | 20 os.remove(ndk_dst) |
21 | 21 |
22 print('Downloading {} to {}'.format(ndk_src, ndk_dst)) | 22 print('Downloading {} to {}'.format(ndk_src, ndk_dst)) |
23 urllib.urlretrieve(ndk_src, ndk_dst) | 23 urllib.urlretrieve(ndk_src, ndk_dst) |
24 | 24 |
25 # Delete existing NDK directory | 25 # Delete existing NDK directory |
26 ndk_dir = os.path.join(libadblockplus_root, 'android-ndk-r12b') | 26 ndk_dir = os.path.join(libadblockplus_third_party, 'android-ndk-r12b') |
anton
2018/01/18 08:25:45
Previously we deleted whole 'third_party' includin
| |
27 if os.path.exists(ndk_dir): | 27 if os.path.exists(ndk_dir): |
28 print('Deleting {}'.format(ndk_dir)) | 28 print('Deleting {}'.format(ndk_dir)) |
29 shutil.rmtree(ndk_dir) | 29 shutil.rmtree(ndk_dir) |
30 | 30 |
31 # Extract zip (preserving file permissions) | 31 # Extract zip (preserving file permissions) |
32 print('Extracting {} to {}'.format(ndk_dst, libadblockplus_root)) | 32 print('Extracting {} to {}'.format(ndk_dst, libadblockplus_third_party)) |
33 with zipfile.ZipFile(ndk_dst, 'r') as zf: | 33 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
| |
34 for info in zf.infolist(): | 34 for info in zf.infolist(): |
35 zf.extract(info.filename, path=libadblockplus_root) | 35 zf.extract(info.filename, path=libadblockplus_third_party) |
36 out_path = os.path.join(libadblockplus_root, info.filename) | 36 out_path = os.path.join(libadblockplus_third_party, info.filename) |
37 | 37 |
38 perm = info.external_attr >> 16L | 38 perm = info.external_attr >> 16L |
39 os.chmod(out_path, perm) | 39 os.chmod(out_path, perm) |
40 | 40 |
41 # Delete zip | 41 # Delete zip |
42 os.remove(ndk_dst) | 42 os.remove(ndk_dst) |
43 | 43 |
44 return 0 | 44 return 0 |
45 | 45 |
46 | 46 |
47 if '__main__' == __name__: | 47 if '__main__' == __name__: |
48 try: | 48 try: |
49 sys.exit(main(sys.argv[1:])) | 49 sys.exit(main(sys.argv[1:])) |
50 except KeyboardInterrupt: | 50 except KeyboardInterrupt: |
51 sys.stderr.write('interrupted\n') | 51 sys.stderr.write('interrupted\n') |
52 sys.exit(1) | 52 sys.exit(1) |
LEFT | RIGHT |