Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 import os | |
| 4 import subprocess | |
| 5 import sys | |
| 6 import tempfile | |
| 7 import zipfile | |
| 8 | |
| 9 if not sys.platform.startswith("linux"): | |
| 10 print "Not supported for your platform" | |
| 11 sys.exit(0) | |
| 12 | |
| 13 current_path = os.path.dirname(os.path.realpath(__file__)) | |
| 14 version_path = os.path.join(current_path, "../VERSION") | |
| 15 with open(version_path) as version_file: | |
| 16 version = version_file.read().strip() | |
| 17 | |
| 18 prebuilt_file_path = os.path.join(current_path, "prebuilt") | |
| 19 stamp_path = os.path.join(prebuilt_file_path, "VERSION") | |
| 20 | |
| 21 try: | |
| 22 with open(stamp_path) as stamp_file: | |
| 23 current_version = stamp_file.read().strip() | |
| 24 if current_version == version: | |
| 25 sys.exit(0) | |
| 26 except IOError: | |
| 27 pass | |
| 28 | |
| 29 platform = "linux-x64" # TODO: configurate | |
| 30 basename = platform + ".zip" | |
| 31 | |
| 32 gs_path = "gs://mojo/shell/" + version + "/" + basename | |
| 33 | |
| 34 with tempfile.NamedTemporaryFile() as temp_zip_file: | |
| 35 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 -
| |
| 36 with zipfile.ZipFile(temp_zip_file.name) as z: | |
| 37 zi = z.getinfo("mojo_shell") | |
| 38 mode = zi.external_attr >> 16L | |
| 39 z.extract(zi, prebuilt_file_path) | |
| 40 os.chmod(os.path.join(prebuilt_file_path, "mojo_shell"), mode) | |
| 41 | |
| 42 with open(stamp_path, 'w') as stamp_file: | |
| 43 stamp_file.write(version + "\n") | |
| OLD | NEW |