Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: third_party/libadblockplus/download_ndk.py

Issue 29670555: Issue 6264 - Can't prepare libadblockplus dependencies (Closed)
Patch Set: Deleting NDK directory before extracting. Formatted with respect to eyeo python code style Created Jan. 18, 2018, 8:23 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libadblockplus/delete_dir.py ('k') | third_party/libadblockplus_android/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
6
5 7
6 def main(argv): 8 def main(argv):
7 # Download 9 # Download
8 ndk_src = 'https://dl.google.com/android/repository/android-ndk-r12b-linux-x86 _64.zip' 10 ndk_src = 'https://dl.google.com/android/repository/android-ndk-r12b-linux-x 86_64.zip'
9 11
10 cwd = os.getcwd() 12 cwd = os.getcwd()
11 libadblockplus_root = os.path.join(cwd, 'src', 'third_party', 'libadblockplus' , 'third_party') 13 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
12 ndk_dst = os.path.join(libadblockplus_root, 'android-ndk-r12b-linux-x86_64.zip ') 14 'src', '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,
17 'android-ndk-r12b-linux-x86_64.zip')
13 18
14 if os.path.exists(ndk_dst): 19 if os.path.exists(ndk_dst):
20 os.remove(ndk_dst)
21
22 print('Downloading {} to {}'.format(ndk_src, ndk_dst))
23 urllib.urlretrieve(ndk_src, ndk_dst)
24
25 # Delete existing NDK directory
26 ndk_dir = os.path.join(libadblockplus_root, 'android-ndk-r12b')
anton 2018/01/18 08:25:45 Previously we deleted whole 'third_party' includin
27 if os.path.exists(ndk_dir):
28 print('Deleting {}'.format(ndk_dir))
29 shutil.rmtree(ndk_dir)
30
31 # Extract zip (preserving file permissions)
32 print('Extracting {} to {}'.format(ndk_dst, libadblockplus_root))
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():
35 zf.extract(info.filename, path=libadblockplus_root)
36 out_path = os.path.join(libadblockplus_root, info.filename)
37
38 perm = info.external_attr >> 16L
39 os.chmod(out_path, perm)
40
41 # Delete zip
15 os.remove(ndk_dst) 42 os.remove(ndk_dst)
16 43
17 print('Downloading %s to %s' % (ndk_src, ndk_dst)) 44 return 0
18 urllib.urlretrieve(ndk_src, ndk_dst)
19 45
20 # Extract zip (preserving file permissions)
21 print('Extracting %s to %s' % (ndk_dst, libadblockplus_root))
22 with zipfile.ZipFile(ndk_dst, 'r') as zf:
23 for info in zf.infolist():
24 zf.extract(info.filename, path=libadblockplus_root)
25 out_path = os.path.join(libadblockplus_root, info.filename)
26
27 perm = info.external_attr >> 16L
28 os.chmod(out_path, perm)
29
30 # Delete zip
31 os.remove(ndk_dst)
32
33 return 0
34 46
35 if '__main__' == __name__: 47 if '__main__' == __name__:
36 try: 48 try:
37 sys.exit(main(sys.argv[1:])) 49 sys.exit(main(sys.argv[1:]))
38 except KeyboardInterrupt: 50 except KeyboardInterrupt:
39 sys.stderr.write('interrupted\n') 51 sys.stderr.write('interrupted\n')
40 sys.exit(1) 52 sys.exit(1)
OLDNEW
« no previous file with comments | « third_party/libadblockplus/delete_dir.py ('k') | third_party/libadblockplus_android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld