Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: build/download_sdk_extras.py

Issue 842753002: Use json file to determine sdk packages to download. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add json file containing packages. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android_sdk_extras.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/download_sdk_extras.py
diff --git a/build/download_sdk_extras.py b/build/download_sdk_extras.py
index ca307751f62afd788640719ec8961c1c0e000c72..d38ee8651de5833924ea402c599ed80b10947583 100755
--- a/build/download_sdk_extras.py
+++ b/build/download_sdk_extras.py
@@ -10,6 +10,7 @@ bucket named: <dir in SDK extras>_<package name>_<version>.zip. The file will
be extracted in the android_tools/sdk/extras directory.
"""
+import json
import os
import shutil
import subprocess
@@ -23,13 +24,11 @@ GSUTIL_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
os.pardir, os.pardir, os.pardir, os.pardir, 'depot_tools', 'gsutil.py')
SDK_EXTRAS_BUCKET = 'gs://chrome-sdk-extras'
SDK_EXTRAS_PATH = os.path.join(constants.ANDROID_SDK_ROOT, 'extras')
+SDK_EXTRAS_JSON_FILE = os.path.join(os.path.dirname(__file__),
+ 'android_sdk_extras.json')
-def clean_and_extract(zip_file):
- # Extract the directory name and package name from zip file name. The format
- # of the zip file is <dir in sdk/extras>_<package_name>_<version>.zip.
- dir_name = zip_file[:zip_file.index('_')]
- package_name = zip_file[zip_file.index('_')+1:zip_file.rindex('_')]
+def clean_and_extract(dir_name, package_name, zip_file):
local_dir = '%s/%s/%s' % (SDK_EXTRAS_PATH, dir_name, package_name)
if os.path.exists(local_dir):
shutil.rmtree(local_dir)
@@ -38,19 +37,22 @@ def clean_and_extract(zip_file):
z.extractall(path=SDK_EXTRAS_PATH)
-def main(args):
+def main():
if not os.path.exists(GSUTIL_PATH) or not os.path.exists(SDK_EXTRAS_PATH):
# This is not a buildbot checkout.
return 0
- for arg in args[1:]:
- local_zip = '%s/%s' % (SDK_EXTRAS_PATH, arg)
+ # Update the android_sdk_extras.json file to update downloaded packages.
+ with open(SDK_EXTRAS_JSON_FILE) as json_file:
+ packages = json.load(json_file)
+ for package in packages:
+ local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip'])
if not os.path.exists(local_zip):
- package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, arg)
+ package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip'])
subprocess.check_call([GSUTIL_PATH, '--force-version', '4.7', 'cp',
- package_zip, local_zip])
+ package_zip, local_zip])
# Always clean dir and extract zip to ensure correct contents.
- clean_and_extract(arg)
+ clean_and_extract(package['dir_name'], package['package'], package['zip'])
if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ sys.exit(main())
« no previous file with comments | « build/android_sdk_extras.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698