OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import os |
| 7 import subprocess |
| 8 import sys |
| 9 import tempfile |
| 10 import zipfile |
| 11 |
| 12 current_path = os.path.dirname(os.path.realpath(__file__)) |
| 13 sys.path.insert(0, os.path.join(current_path, "..", "..", "..", "tools")) |
| 14 # pylint: disable=F0401 |
| 15 import find_depot_tools |
| 16 |
| 17 if not sys.platform.startswith("linux"): |
| 18 print "Not supported for your platform" |
| 19 sys.exit(0) |
| 20 |
| 21 version_path = os.path.join(current_path, "../VERSION") |
| 22 with open(version_path) as version_file: |
| 23 version = version_file.read().strip() |
| 24 |
| 25 prebuilt_file_path = os.path.join(current_path, "prebuilt") |
| 26 stamp_path = os.path.join(prebuilt_file_path, "VERSION") |
| 27 |
| 28 try: |
| 29 with open(stamp_path) as stamp_file: |
| 30 current_version = stamp_file.read().strip() |
| 31 if current_version == version: |
| 32 sys.exit(0) |
| 33 except IOError: |
| 34 pass |
| 35 |
| 36 platform = "linux-x64" # TODO: configurate |
| 37 basename = platform + ".zip" |
| 38 |
| 39 gs_path = "gs://mojo/shell/" + version + "/" + basename |
| 40 |
| 41 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
| 42 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") |
| 43 |
| 44 with tempfile.NamedTemporaryFile() as temp_zip_file: |
| 45 subprocess.check_call([gsutil_exe, "--bypass_prodaccess", |
| 46 "cp", gs_path, temp_zip_file.name]) |
| 47 with zipfile.ZipFile(temp_zip_file.name) as z: |
| 48 zi = z.getinfo("mojo_shell") |
| 49 mode = zi.external_attr >> 16L |
| 50 z.extract(zi, prebuilt_file_path) |
| 51 os.chmod(os.path.join(prebuilt_file_path, "mojo_shell"), mode) |
| 52 |
| 53 with open(stamp_path, 'w') as stamp_file: |
| 54 stamp_file.write(version + "\n") |
OLD | NEW |