Chromium Code Reviews| Index: mojo/public/tools/download_shell_binary.py |
| diff --git a/mojo/public/tools/download_shell_binary.py b/mojo/public/tools/download_shell_binary.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..e43f7d0e1e5f1eed19ceb7554a284faed42a7a1d |
| --- /dev/null |
| +++ b/mojo/public/tools/download_shell_binary.py |
| @@ -0,0 +1,43 @@ |
| +#!/usr/bin/env python |
| + |
| +import os |
| +import subprocess |
| +import sys |
| +import tempfile |
| +import zipfile |
| + |
| +if not sys.platform.startswith("linux"): |
| + print "Not supported for your platform" |
| + sys.exit(0) |
| + |
| +current_path = os.path.dirname(os.path.realpath(__file__)) |
| +version_path = os.path.join(current_path, "../VERSION") |
| +with open(version_path) as version_file: |
| + version = version_file.read().strip() |
| + |
| +prebuilt_file_path = os.path.join(current_path, "prebuilt") |
| +stamp_path = os.path.join(prebuilt_file_path, "VERSION") |
| + |
| +try: |
| + with open(stamp_path) as stamp_file: |
| + current_version = stamp_file.read().strip() |
| + if current_version == version: |
| + sys.exit(0) |
| +except IOError: |
| + pass |
| + |
| +platform = "linux-x64" # TODO: configurate |
| +basename = platform + ".zip" |
| + |
| +gs_path = "gs://mojo/shell/" + version + "/" + basename |
| + |
| +with tempfile.NamedTemporaryFile() as temp_zip_file: |
| + subprocess.check_call(["gsutil", "cp", gs_path, temp_zip_file.name]) |
|
jamesr
2014/10/20 22:49:03
this should use the gsutil binary in depot_tools -
|
| + with zipfile.ZipFile(temp_zip_file.name) as z: |
| + zi = z.getinfo("mojo_shell") |
| + mode = zi.external_attr >> 16L |
| + z.extract(zi, prebuilt_file_path) |
| + os.chmod(os.path.join(prebuilt_file_path, "mojo_shell"), mode) |
| + |
| +with open(stamp_path, 'w') as stamp_file: |
| + stamp_file.write(version + "\n") |