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

Unified Diff: third_party/libadblockplus/download_ndk.py

Issue 29670555: Issue 6264 - Can't prepare libadblockplus dependencies (Closed)
Patch Set: Renamed variable Created Jan. 18, 2018, 12:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..386f474ec557960cb00f80ebcb350b0944e939f8 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_third_party = os.path.join(cwd,
+ 'src', 'third_party',
+ 'libadblockplus', 'third_party')
+ ndk_dst = os.path.join(libadblockplus_third_party,
+ '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_third_party, 'android-ndk-r12b')
+ 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_third_party))
+ with zipfile.ZipFile(ndk_dst, 'r') as zf:
+ for info in zf.infolist():
+ zf.extract(info.filename, path=libadblockplus_third_party)
+ out_path = os.path.join(libadblockplus_third_party, 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)
« 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