| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 2 | |
| 3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 4 # for details. All rights reserved. Use of this source code is governed by a | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 | |
| 7 """Download archived multivm or dartium builds. | |
| 8 | |
| 9 Usage: download_multivm.py revision target_directory | |
| 10 """ | |
| 11 | |
| 12 import imp | |
| 13 import os | |
| 14 import platform | |
| 15 import shutil | |
| 16 import subprocess | |
| 17 import sys | |
| 18 import tempfile | |
| 19 | |
| 20 # We are in [checkout dir]/src/dart/tools/dartium in a dartium/multivm checkout | |
| 21 TOOLS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| 22 SRC_DIR = os.path.dirname(os.path.dirname(TOOLS_DIR)) | |
| 23 GS_BUCKET = 'gs://dartium-archive' | |
| 24 if platform.system() == 'Windows': | |
| 25 GSUTIL = 'e:\\b\\build\\scripts\\slave\\gsutil.bat' | |
| 26 if not os.path.exists(GSUTIL): | |
| 27 GSUTIL = 'c:\\b\\build\\scripts\\slave\\gsutil.bat' | |
| 28 else: | |
| 29 GSUTIL = '/b/build/scripts/slave/gsutil' | |
| 30 if not os.path.exists(GSUTIL): | |
| 31 GSUTIL = 'gsutil' | |
| 32 | |
| 33 class TempDir(object): | |
| 34 def __init__(self, prefix=''): | |
| 35 self._temp_dir = None | |
| 36 self._prefix = prefix | |
| 37 | |
| 38 def __enter__(self): | |
| 39 self._temp_dir = tempfile.mkdtemp(self._prefix) | |
| 40 return self._temp_dir | |
| 41 | |
| 42 def __exit__(self, *_): | |
| 43 shutil.rmtree(self._temp_dir, ignore_errors=True) | |
| 44 | |
| 45 def ExecuteCommand(cmd): | |
| 46 print 'Executing: ' + ' '.join(cmd) | |
| 47 subprocess.check_output(cmd) | |
| 48 | |
| 49 def main(): | |
| 50 revision = sys.argv[1] | |
| 51 target_dir = sys.argv[2] | |
| 52 archive_dir = (os.environ['BUILDBOT_BUILDERNAME'] | |
| 53 .replace('linux', 'lucid64') | |
| 54 .replace('multivm', 'multivm-dartium') | |
| 55 .replace('perf', 'build')) | |
| 56 with TempDir() as temp_dir: | |
| 57 archive_file = archive_dir + '-' + revision + '.zip' | |
| 58 gs_source = '/'.join([GS_BUCKET, archive_dir, archive_file]) | |
| 59 zip_file = os.path.join(temp_dir, archive_file) | |
| 60 ExecuteCommand([GSUTIL, 'cp', gs_source, zip_file]) | |
| 61 | |
| 62 unzip_dir = zip_file.replace('.zip', '') | |
| 63 if platform.system() == 'Windows': | |
| 64 executable = os.path.join(SRC_DIR, 'third_party', 'lzma_sdk', | |
| 65 'Executable', '7za.exe') | |
| 66 ExecuteCommand([executable, 'x', '-aoa', '-o' + temp_dir, zip_file]) | |
| 67 else: | |
| 68 ExecuteCommand(['unzip', zip_file, '-d', temp_dir]) | |
| 69 | |
| 70 if os.path.exists(target_dir): | |
| 71 shutil.rmtree(target_dir) | |
| 72 shutil.move(unzip_dir, target_dir) | |
| 73 | |
| 74 if __name__ == '__main__': | |
| 75 sys.exit(main()) | |
| OLD | NEW |