summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authornavabi <navabi@google.com>2015-01-06 12:46:56 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-06 20:47:38 +0000
commit24606e2106ec9029e042353feaa84555708aefd0 (patch)
treeeda79a582b3813585ee885f254e2d19a1d414a63 /build
parent17f542c223a72cdd2e759e199bfb8a730bdde890 (diff)
downloadchromium_src-24606e2106ec9029e042353feaa84555708aefd0.zip
chromium_src-24606e2106ec9029e042353feaa84555708aefd0.tar.gz
chromium_src-24606e2106ec9029e042353feaa84555708aefd0.tar.bz2
Always download google_play_services zip package instead of rsync.
On the bots the rsync technique to download packages (see bug for more details) takes too long. It takes almost 30 seconds even when the package is already on the bot. Instead always download the zip and unzip it. BUG=350151 Review URL: https://codereview.chromium.org/799673003 Cr-Commit-Position: refs/heads/master@{#310135}
Diffstat (limited to 'build')
-rwxr-xr-xbuild/download_sdk_extras.py63
1 files changed, 27 insertions, 36 deletions
diff --git a/build/download_sdk_extras.py b/build/download_sdk_extras.py
index 1149d9d..ca30775 100755
--- a/build/download_sdk_extras.py
+++ b/build/download_sdk_extras.py
@@ -5,15 +5,16 @@
"""Script to download sdk/extras packages on the bots from google storage.
-The script expects an argument that specifies the packet name in the following
-format: <dir_in_sdk_extras>_<package_name>_<version>. There will be a
-correpsonding bucket in google storage with that name, and it will be downloaded
-to android_tools/sdk/extras/.
+The script expects arguments that specify zips file in the google storage
+bucket named: <dir in SDK extras>_<package name>_<version>.zip. The file will
+be extracted in the android_tools/sdk/extras directory.
"""
import os
+import shutil
import subprocess
import sys
+import zipfile
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'android'))
from pylib import constants
@@ -24,41 +25,31 @@ SDK_EXTRAS_BUCKET = 'gs://chrome-sdk-extras'
SDK_EXTRAS_PATH = os.path.join(constants.ANDROID_SDK_ROOT, 'extras')
-def GetCmdOutputAndStatus(cmd_lst):
- process = subprocess.Popen(cmd_lst, stdout=subprocess.PIPE)
- stdout, _ = process.communicate()
- return stdout, process.returncode
+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('_')]
+ local_dir = '%s/%s/%s' % (SDK_EXTRAS_PATH, dir_name, package_name)
+ if os.path.exists(local_dir):
+ shutil.rmtree(local_dir)
+ local_zip = '%s/%s' % (SDK_EXTRAS_PATH, zip_file)
+ with zipfile.ZipFile(local_zip) as z:
+ z.extractall(path=SDK_EXTRAS_PATH)
-def is_android_buildbot_checkout():
- if not os.path.exists(GSUTIL_PATH) or not os.path.exists(SDK_EXTRAS_PATH):
- return False
- stdout, rc = GetCmdOutputAndStatus([GSUTIL_PATH, 'ls', SDK_EXTRAS_BUCKET])
- # If successfully read bucket, then this must be a bot with permissions
- return not rc
def main(args):
- if is_android_buildbot_checkout():
- success = True
- for arg in args[1:]:
- # Package is named <folder>_<package_name>_<version>
- first_underscore = arg.find('_')
- last_underscore = arg.rfind('_')
- folder = arg[0:first_underscore]
- package = arg[first_underscore+1:last_underscore]
- # Package bucket is <SDK_EXTRAS_BUCKET>/<folder>_<package_name>_<version>
- # and in that bucket will be the directory <folder>/<package_name> to cp.
- package_bucket = '%s/%s/%s/%s' % (SDK_EXTRAS_BUCKET, arg, folder, package)
- package_dir = '%s/%s/%s' % (SDK_EXTRAS_PATH, folder, package)
- if not os.path.exists(package_dir):
- os.makedirs(package_dir)
- # rsync is only supported by gsutil version 4.x
- cmd_lst = [GSUTIL_PATH, '--force-version', '4.6', '-m', 'rsync', '-r',
- '-d', package_bucket, package_dir]
- stdout, rc = GetCmdOutputAndStatus(cmd_lst)
- success = (rc == 0) and success
- if not success:
- return 1
- return 0
+ 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)
+ if not os.path.exists(local_zip):
+ package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, arg)
+ subprocess.check_call([GSUTIL_PATH, '--force-version', '4.7', 'cp',
+ package_zip, local_zip])
+ # Always clean dir and extract zip to ensure correct contents.
+ clean_and_extract(arg)
if __name__ == '__main__':