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