From 792312965893f1914070428720e4bb0b81bf629c Mon Sep 17 00:00:00 2001 From: "scottmg@chromium.org" Date: Tue, 28 Jan 2014 03:17:54 +0000 Subject: [PATCH] Pull toolchain isos from gs:// when on bots VS2013 isos are mirrored to gs://chrome-wintoolchain/ (which is googler- only accessible). This is used to isolate bots from external dependency as detected by CHROME_HEADLESS=1 in the environment. TBR=iannucci@chromium.org R=hinoka@chromium.org BUG=324987 Review URL: https://codereview.chromium.org/148613003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@247398 0039d316-1c4b-4281-b951-d872f2087c98 --- win_toolchain/toolchain2013.py | 37 ++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/win_toolchain/toolchain2013.py b/win_toolchain/toolchain2013.py index b1b389f54..4b14214f5 100755 --- a/win_toolchain/toolchain2013.py +++ b/win_toolchain/toolchain2013.py @@ -20,6 +20,10 @@ BASEDIR = os.path.dirname(os.path.abspath(__file__)) g_temp_dirs = [] +sys.path.append(os.path.join(BASEDIR, '..')) +import download_from_google_storage + + def GetLongPathName(path): """Converts any 8dot3 names in the path to the full name.""" buf = ctypes.create_unicode_buffer(260) @@ -56,7 +60,9 @@ def DeleteAllTempDirs(): def GetIsoUrl(pro): """Gets the .iso URL. - If |pro| is False, downloads the Express edition. + If |pro| is False, downloads the Express edition. If |CHROME_HEADLESS| is + set in the environment, then we assume we're on an internal bot, and download + from internal google storage instead. """ prefix = 'http://download.microsoft.com/download/' if pro: @@ -153,6 +159,31 @@ def DownloadSDK8(): raise SystemExit("After multiple retries, couldn't download Win8 SDK") +def DownloadUsingGsutil(filename): + """Downloads the given file from Google Storage chrome-wintoolchain bucket.""" + temp_dir = TempDir() + assert os.path.basename(filename) == filename + target_path = os.path.join(temp_dir, filename) + gsutil = download_from_google_storage.Gsutil( + download_from_google_storage.GSUTIL_DEFAULT_PATH, boto_path=None) + code = gsutil.call('cp', 'gs://chrome-wintoolchain/' + filename, target_path) + if code != 0: + raise SystemExit('gsutil failed') + return target_path + + +def GetVSInternal(): + """Uses gsutil to pull the toolchain from internal Google Storage bucket.""" + return DownloadUsingGsutil('VS2013_RTM_PRO_ENU.iso') + + +def GetSDKInternal(): + """Downloads a zipped copy of the SDK from internal Google Storage bucket, + and extracts it.""" + zip_file = DownloadUsingGsutil('Standalone.zip') + return ExtractIso(zip_file) + + class SourceImages(object): def __init__(self, vs_path, sdk8_path): self.vs_path = vs_path @@ -161,7 +192,9 @@ class SourceImages(object): def GetSourceImages(local_dir, pro): url = GetIsoUrl(pro) - if local_dir: + if os.environ.get('CHROME_HEADLESS'): + return SourceImages(GetVSInternal(), GetSDKInternal()) + elif local_dir: return SourceImages(os.path.join(local_dir, os.path.basename(url)), os.path.join(local_dir, 'Standalone')) else: