From 6f0bb7619afcdd28daba7e763dacd7035504be4c Mon Sep 17 00:00:00 2001 From: navabi Date: Tue, 30 Dec 2014 11:21:38 -0800 Subject: [PATCH] Add gclient hook to download SDK extras on bots. BUG=350151 TBR=cjhopman@chromium.org Review URL: https://codereview.chromium.org/709663002 Cr-Commit-Position: refs/heads/master@{#309763} --- DEPS | 10 +++++++ build/download_sdk_extras.py | 65 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 build/download_sdk_extras.py diff --git a/DEPS b/DEPS index 1a585dca74b5..fe827587b2db 100644 --- a/DEPS +++ b/DEPS @@ -553,6 +553,16 @@ hooks = [ ], }, { + # This downloads SDK extras and puts them in the + # third_party/android_tools/sdk/extras directory on the bots. Developers + # need to manually install these packages and accept the ToS. + 'name': 'sdkextras', + 'pattern': '.', + # Make sure to add package to .gitignore in third_party/android_tools. + 'action': ['python', 'src/build/download_sdk_extras.py', + 'google_google_play_services_21.0.0'], + }, + { # Downloads the Debian Wheezy sysroot to chrome/installer/linux if needed. # This sysroot updates at about the same rate that the chrome build deps # change. This script is a no-op except for linux users who are doing diff --git a/build/download_sdk_extras.py b/build/download_sdk_extras.py new file mode 100755 index 000000000000..1149d9d29641 --- /dev/null +++ b/build/download_sdk_extras.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""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: __. There will be a +correpsonding bucket in google storage with that name, and it will be downloaded +to android_tools/sdk/extras/. +""" + +import os +import subprocess +import sys + +sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'android')) +from pylib import constants + +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') + + +def GetCmdOutputAndStatus(cmd_lst): + process = subprocess.Popen(cmd_lst, stdout=subprocess.PIPE) + stdout, _ = process.communicate() + return stdout, process.returncode + +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 __ + first_underscore = arg.find('_') + last_underscore = arg.rfind('_') + folder = arg[0:first_underscore] + package = arg[first_underscore+1:last_underscore] + # Package bucket is /__ + # and in that bucket will be the directory / 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 __name__ == '__main__': + sys.exit(main(sys.argv)) -- 2.11.4.GIT