| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 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 shutil | 8 import shutil |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 if sys.platform.startswith('linux'): | 23 if sys.platform.startswith('linux'): |
| 24 return 'linux' | 24 return 'linux' |
| 25 | 25 |
| 26 return None | 26 return None |
| 27 | 27 |
| 28 | 28 |
| 29 def main(argv): | 29 def main(argv): |
| 30 parser = argparse.ArgumentParser() | 30 parser = argparse.ArgumentParser() |
| 31 parser.add_argument('--target-dir', required=True) | 31 parser.add_argument('--target-dir', required=True) |
| 32 parser.add_argument('--download-from-google-storage-path', required=True) | 32 parser.add_argument('--download-from-google-storage-path', required=True) |
| 33 parser.add_argument('--canary', action='store_true') | |
| 34 | 33 |
| 35 args = parser.parse_args() | 34 args = parser.parse_args() |
| 36 | 35 |
| 37 config = CONFIG[get_platform()] | 36 config = CONFIG[get_platform()] |
| 38 | 37 |
| 39 client_dir = args.target_dir | 38 client_dir = args.target_dir |
| 40 if not os.path.exists(client_dir): | 39 if not os.path.exists(client_dir): |
| 41 os.makedirs(client_dir) | 40 os.makedirs(client_dir) |
| 42 | 41 |
| 43 current_repo = subprocess.check_output( | 42 current_repo = subprocess.check_output( |
| 44 ['git', 'ls-remote', '--get-url'], cwd=client_dir).strip() | 43 ['git', 'ls-remote', '--get-url'], cwd=client_dir).strip() |
| 45 if current_repo != config['repo']: | 44 if current_repo != config['repo']: |
| 46 shutil.rmtree(client_dir) | 45 shutil.rmtree(client_dir) |
| 47 subprocess.check_call(['git', 'clone', config['repo'], client_dir]) | 46 subprocess.check_call(['git', 'clone', config['repo'], client_dir]) |
| 48 | 47 |
| 49 subprocess.check_call(['git', 'fetch'], cwd=client_dir) | 48 subprocess.check_call(['git', 'fetch'], cwd=client_dir) |
| 50 rev = config['revision'] | |
| 51 if arg.canary: | |
| 52 rev = 'refs/heads/master' | |
| 53 subprocess.check_call( | 49 subprocess.check_call( |
| 54 ['git', 'reset', '--hard', rev], cwd=client_dir) | 50 ['git', 'reset', '--hard', config['revision']], cwd=client_dir) |
| 55 | 51 |
| 56 subprocess.check_call([sys.executable, | 52 subprocess.check_call([sys.executable, |
| 57 args.download_from_google_storage_path, | 53 args.download_from_google_storage_path, |
| 58 '--directory', | 54 '--directory', |
| 59 '--recursive', | 55 '--recursive', |
| 60 '--bucket', 'chrome-goma', | 56 '--bucket', 'chrome-goma', |
| 61 client_dir]) | 57 client_dir]) |
| 62 | 58 |
| 63 subprocess.check_call( | 59 subprocess.check_call( |
| 64 [sys.executable, os.path.join(client_dir, 'fix_file_modes.py')]) | 60 [sys.executable, os.path.join(client_dir, 'fix_file_modes.py')]) |
| 65 | 61 |
| 66 return 0 | 62 return 0 |
| 67 | 63 |
| 68 | 64 |
| 69 if __name__ == '__main__': | 65 if __name__ == '__main__': |
| 70 sys.exit(main(sys.argv[1:])) | 66 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |