| 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 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 except urllib2.HTTPError: | 26 except urllib2.HTTPError: |
| 27 print ("Failed to identify a Chromium revision associated with %s. " | 27 print ("Failed to identify a Chromium revision associated with %s. " |
| 28 "Ensure that target_version is a Chromium origin/master " | 28 "Ensure that target_version is a Chromium origin/master " |
| 29 "commit.") % (target_version) | 29 "commit.") % (target_version) |
| 30 return 1 | 30 return 1 |
| 31 | 31 |
| 32 mojoms_gs_path = "gs://mojo/network_service/%s/mojoms.zip" % (target_version,) | 32 mojoms_gs_path = "gs://mojo/network_service/%s/mojoms.zip" % (target_version,) |
| 33 network_service_path = os.path.join( | 33 network_service_path = os.path.join( |
| 34 mojo_root_dir, "mojo", "services", "network") | 34 mojo_root_dir, "mojo", "services", "network") |
| 35 mojoms_path = os.path.join(network_service_path, "public", "interfaces") | 35 mojoms_path = os.path.join(network_service_path, "public", "interfaces") |
| 36 version_path = os.path.join(network_service_path, "VERSION") | 36 mojo_public_tools_path = os.path.join( |
| 37 mojo_root_dir, "mojo", "public", "tools") |
| 38 version_path = os.path.join(mojo_public_tools_path, "NETWORK_SERVICE_VERSION") |
| 37 | 39 |
| 38 try: | 40 try: |
| 39 with tempfile.NamedTemporaryFile() as temp_zip_file: | 41 with tempfile.NamedTemporaryFile() as temp_zip_file: |
| 40 gs.download_from_public_bucket(mojoms_gs_path, temp_zip_file.name) | 42 gs.download_from_public_bucket(mojoms_gs_path, temp_zip_file.name) |
| 41 | 43 |
| 42 try: | 44 try: |
| 43 system(["git", "rm", "-r", mojoms_path], cwd=mojo_root_dir) | 45 system(["git", "rm", "-r", mojoms_path], cwd=mojo_root_dir) |
| 44 except subprocess.CalledProcessError: | 46 except subprocess.CalledProcessError: |
| 45 print ("Could not remove %s. " | 47 print ("Could not remove %s. " |
| 46 "Ensure your local tree is in a clean state." % mojoms_path) | 48 "Ensure your local tree is in a clean state." % mojoms_path) |
| 47 return 1 | 49 return 1 |
| 48 | 50 |
| 49 with zipfile.ZipFile(temp_zip_file.name) as z: | 51 with zipfile.ZipFile(temp_zip_file.name) as z: |
| 50 z.extractall(mojoms_path) | 52 z.extractall(mojoms_path) |
| 51 # pylint: disable=C0302,bare-except | 53 # pylint: disable=C0302,bare-except |
| 52 except: | 54 except: |
| 53 print ("Failed to download the mojom files associated with %s. Ensure that " | 55 print ("Failed to download the mojom files associated with %s. Ensure that " |
| 54 "the corresponding network service artifacts were uploaded to " | 56 "the corresponding network service artifacts were uploaded to " |
| 55 "Google Storage.") % (target_version) | 57 "Google Storage.") % (target_version) |
| 56 return 1 | 58 return 1 |
| 57 | 59 |
| 58 with open(version_path, 'w') as stamp_file: | 60 with open(version_path, 'w') as stamp_file: |
| 59 stamp_file.write(target_version) | 61 stamp_file.write(target_version) |
| 60 | 62 |
| 61 system(["git", "add", "public"], cwd=network_service_path) | 63 system(["git", "add", "public"], cwd=network_service_path) |
| 62 system(["git", "add", "VERSION"], cwd=network_service_path) | 64 system(["git", "add", "NETWORK_SERVICE_VERSION"], cwd=mojo_public_tools_path) |
| 63 commit("Roll the network service to https://crrev.com/" + chromium_rev, | 65 commit("Roll the network service to https://crrev.com/" + chromium_rev, |
| 64 cwd=mojo_root_dir) | 66 cwd=mojo_root_dir) |
| 65 return 0 | 67 return 0 |
| 66 | 68 |
| 67 def main(): | 69 def main(): |
| 68 parser = argparse.ArgumentParser( | 70 parser = argparse.ArgumentParser( |
| 69 description="Update the pinned version of the network service " + | 71 description="Update the pinned version of the network service " + |
| 70 "and the corresponding checked out mojoms.") | 72 "and the corresponding checked out mojoms.") |
| 71 parser.add_argument("version", help="version to roll to (a Chromium " | 73 parser.add_argument("version", help="version to roll to (a Chromium " |
| 72 "origin/master commit)") | 74 "origin/master commit)") |
| 73 args = parser.parse_args() | 75 args = parser.parse_args() |
| 74 roll(args.version) | 76 roll(args.version) |
| 75 return 0 | 77 return 0 |
| 76 | 78 |
| 77 if __name__ == "__main__": | 79 if __name__ == "__main__": |
| 78 sys.exit(main()) | 80 sys.exit(main()) |
| OLD | NEW |