| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import tempfile | 10 import tempfile |
| 11 import urllib2 | 11 import urllib2 |
| 12 import zipfile | 12 import zipfile |
| 13 | 13 |
| 14 from update_from_chromium import chromium_rev_number | 14 from update_from_chromium import chromium_rev_number |
| 15 from utils import commit | 15 from utils import commit |
| 16 from utils import mojo_root_dir | 16 from utils import mojo_root_dir |
| 17 from utils import system | 17 from utils import system |
| 18 | 18 |
| 19 sys.path.insert(0, os.path.join(mojo_root_dir, "tools")) | 19 sys.path.insert(0, os.path.join(mojo_root_dir, "mojo/public/tools/pylib")) |
| 20 # pylint: disable=F0401 | 20 # pylint: disable=F0401 |
| 21 import gs | 21 import gs |
| 22 | 22 |
| 23 def roll(target_version): | 23 def roll(target_version): |
| 24 find_depot_tools_path = os.path.join(mojo_root_dir, "tools") |
| 25 sys.path.insert(0, find_depot_tools_path) |
| 26 # pylint: disable=F0401 |
| 27 import find_depot_tools |
| 28 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
| 29 |
| 24 try: | 30 try: |
| 25 chromium_rev = chromium_rev_number(target_version) | 31 chromium_rev = chromium_rev_number(target_version) |
| 26 except urllib2.HTTPError: | 32 except urllib2.HTTPError: |
| 27 print ("Failed to identify a Chromium revision associated with %s. " | 33 print ("Failed to identify a Chromium revision associated with %s. " |
| 28 "Ensure that target_version is a Chromium origin/master " | 34 "Ensure that target_version is a Chromium origin/master " |
| 29 "commit.") % (target_version) | 35 "commit.") % (target_version) |
| 30 return 1 | 36 return 1 |
| 31 | 37 |
| 32 mojoms_gs_path = "gs://mojo/network_service/%s/mojoms.zip" % (target_version,) | 38 mojoms_gs_path = "gs://mojo/network_service/%s/mojoms.zip" % (target_version,) |
| 33 network_service_path = os.path.join( | 39 network_service_path = os.path.join( |
| 34 mojo_root_dir, "mojo", "services", "network") | 40 mojo_root_dir, "mojo", "services", "network") |
| 35 mojoms_path = os.path.join(network_service_path, "public", "interfaces") | 41 mojoms_path = os.path.join(network_service_path, "public", "interfaces") |
| 36 mojo_public_tools_path = os.path.join( | 42 mojo_public_tools_path = os.path.join( |
| 37 mojo_root_dir, "mojo", "public", "tools") | 43 mojo_root_dir, "mojo", "public", "tools") |
| 38 version_path = os.path.join(mojo_public_tools_path, "NETWORK_SERVICE_VERSION") | 44 version_path = os.path.join(mojo_public_tools_path, "NETWORK_SERVICE_VERSION") |
| 39 | 45 |
| 40 try: | 46 try: |
| 41 with tempfile.NamedTemporaryFile() as temp_zip_file: | 47 with tempfile.NamedTemporaryFile() as temp_zip_file: |
| 42 gs.download_from_public_bucket(mojoms_gs_path, temp_zip_file.name) | 48 gs.download_from_public_bucket(mojoms_gs_path, temp_zip_file.name, |
| 49 depot_tools_path) |
| 43 | 50 |
| 44 try: | 51 try: |
| 45 system(["git", "rm", "-r", mojoms_path], cwd=mojo_root_dir) | 52 system(["git", "rm", "-r", mojoms_path], cwd=mojo_root_dir) |
| 46 except subprocess.CalledProcessError: | 53 except subprocess.CalledProcessError: |
| 47 print ("Could not remove %s. " | 54 print ("Could not remove %s. " |
| 48 "Ensure your local tree is in a clean state." % mojoms_path) | 55 "Ensure your local tree is in a clean state." % mojoms_path) |
| 49 return 1 | 56 return 1 |
| 50 | 57 |
| 51 with zipfile.ZipFile(temp_zip_file.name) as z: | 58 with zipfile.ZipFile(temp_zip_file.name) as z: |
| 52 z.extractall(mojoms_path) | 59 z.extractall(mojoms_path) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 description="Update the pinned version of the network service " + | 78 description="Update the pinned version of the network service " + |
| 72 "and the corresponding checked out mojoms.") | 79 "and the corresponding checked out mojoms.") |
| 73 parser.add_argument("version", help="version to roll to (a Chromium " | 80 parser.add_argument("version", help="version to roll to (a Chromium " |
| 74 "origin/master commit)") | 81 "origin/master commit)") |
| 75 args = parser.parse_args() | 82 args = parser.parse_args() |
| 76 roll(args.version) | 83 roll(args.version) |
| 77 return 0 | 84 return 0 |
| 78 | 85 |
| 79 if __name__ == "__main__": | 86 if __name__ == "__main__": |
| 80 sys.exit(main()) | 87 sys.exit(main()) |
| OLD | NEW |