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

Side by Side Diff: build/download_sdk_extras.py

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase 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 unified diff | Download patch
« no previous file with comments | « build/download_nacl_toolchains.py ('k') | build/gyp_chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Script to download sdk/extras packages on the bots from google storage.
7
8 The script expects arguments that specify zips file in the google storage
9 bucket named: <dir in SDK extras>_<package name>_<version>.zip. The file will
10 be extracted in the android_tools/sdk/extras directory.
11 """
12
13 import json
14 import os
15 import shutil
16 import subprocess
17 import sys
18 import zipfile
19
20 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'android'))
21 from pylib import constants
22
23 GSUTIL_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
24 os.pardir, os.pardir, os.pardir, os.pardir, 'depot_tools', 'gsutil.py')
25 SDK_EXTRAS_BUCKET = 'gs://chrome-sdk-extras'
26 SDK_EXTRAS_PATH = os.path.join(constants.ANDROID_SDK_ROOT, 'extras')
27 SDK_EXTRAS_JSON_FILE = os.path.join(os.path.dirname(__file__),
28 'android_sdk_extras.json')
29
30
31 def clean_and_extract(dir_name, package_name, zip_file):
32 local_dir = '%s/%s/%s' % (SDK_EXTRAS_PATH, dir_name, package_name)
33 if os.path.exists(local_dir):
34 shutil.rmtree(local_dir)
35 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, zip_file)
36 with zipfile.ZipFile(local_zip) as z:
37 z.extractall(path=SDK_EXTRAS_PATH)
38
39
40 def main():
41 if not os.path.exists(GSUTIL_PATH) or not os.path.exists(SDK_EXTRAS_PATH):
42 # This is not a buildbot checkout.
43 return 0
44 # Update the android_sdk_extras.json file to update downloaded packages.
45 with open(SDK_EXTRAS_JSON_FILE) as json_file:
46 packages = json.load(json_file)
47 for package in packages:
48 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip'])
49 if not os.path.exists(local_zip):
50 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip'])
51 subprocess.check_call([GSUTIL_PATH, '--force-version', '4.7', 'cp',
52 package_zip, local_zip])
53 # Always clean dir and extract zip to ensure correct contents.
54 clean_and_extract(package['dir_name'], package['package'], package['zip'])
55
56
57 if __name__ == '__main__':
58 sys.exit(main())
OLDNEW
« no previous file with comments | « build/download_nacl_toolchains.py ('k') | build/gyp_chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698