| 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 copy | 7 import copy |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 help='factory properties in b64 gz JSON format') | 75 help='factory properties in b64 gz JSON format') |
| 76 parser.add_argument('--leak', action='store_true', | 76 parser.add_argument('--leak', action='store_true', |
| 77 help='Refrain from cleaning up generated artifacts.') | 77 help='Refrain from cleaning up generated artifacts.') |
| 78 parser.add_argument('--verbose', action='store_true') | 78 parser.add_argument('--verbose', action='store_true') |
| 79 | 79 |
| 80 group = parser.add_argument_group('LogDog Bootstrap') | 80 group = parser.add_argument_group('LogDog Bootstrap') |
| 81 logdog_bootstrap.add_arguments(group) | 81 logdog_bootstrap.add_arguments(group) |
| 82 | 82 |
| 83 args = parser.parse_args(argv[1:]) | 83 args = parser.parse_args(argv[1:]) |
| 84 | 84 |
| 85 basedir = os.getcwd() | 85 # Keep CIPD directory between builds. |
| 86 cipd_path = os.path.join(basedir, '.remote_run_cipd') | 86 cipd_path = os.path.join(os.getcwd(), '.remote_run_cipd') |
| 87 _install_cipd_packages( | 87 _install_cipd_packages( |
| 88 cipd_path, cipd.CipdPackage('infra/recipes-py', 'latest')) | 88 cipd_path, cipd.CipdPackage('infra/recipes-py', 'latest')) |
| 89 | 89 |
| 90 with robust_tempdir.RobustTempdir( | 90 with robust_tempdir.RobustTempdir( |
| 91 prefix='.remote_run', leak=args.leak) as rt: | 91 prefix='.remote_run', leak=args.leak) as rt: |
| 92 # Use base directory inside system temporary directory - if we use slave |
| 93 # one (cwd), the paths get too long. Recipes which need different paths |
| 94 # or persistent directories should do so explicitly. |
| 95 basedir = tempfile.gettempdir() |
| 96 |
| 92 # Explicitly clean up possibly leaked temporary directories | 97 # Explicitly clean up possibly leaked temporary directories |
| 93 # from previous runs. | 98 # from previous runs. |
| 94 rt.cleanup(basedir) | 99 rt.cleanup(basedir) |
| 95 | 100 |
| 96 tempdir = rt.tempdir(basedir) | 101 tempdir = rt.tempdir(basedir) |
| 97 LOGGER.info('Using temporary directory: [%s].', tempdir) | 102 LOGGER.info('Using temporary directory: [%s].', tempdir) |
| 98 | 103 |
| 99 build_data_dir = rt.tempdir(basedir) | 104 build_data_dir = rt.tempdir(basedir) |
| 100 LOGGER.info('Using build data directory: [%s].', build_data_dir) | 105 LOGGER.info('Using build data directory: [%s].', build_data_dir) |
| 101 | 106 |
| 102 properties = copy.copy(args.factory_properties) | 107 properties = copy.copy(args.factory_properties) |
| 103 properties.update(args.build_properties) | 108 properties.update(args.build_properties) |
| 104 properties['build_data_dir'] = build_data_dir | 109 properties['build_data_dir'] = build_data_dir |
| 105 LOGGER.info('Using properties: %r', properties) | 110 LOGGER.info('Using properties: %r', properties) |
| 106 properties_file = os.path.join(tempdir, 'remote_run_properties.json') | 111 properties_file = os.path.join(tempdir, 'remote_run_properties.json') |
| 107 with open(properties_file, 'w') as f: | 112 with open(properties_file, 'w') as f: |
| 108 json.dump(properties, f) | 113 json.dump(properties, f) |
| 109 | 114 |
| 110 monitoring_utils.write_build_monitoring_event(build_data_dir, properties) | 115 monitoring_utils.write_build_monitoring_event(build_data_dir, properties) |
| 111 | 116 |
| 112 recipe_cmd = [ | 117 recipe_cmd = [ |
| 113 sys.executable, | 118 sys.executable, |
| 114 os.path.join(cipd_path, 'recipes.py'), | 119 os.path.join(cipd_path, 'recipes.py'), |
| 115 'remote_run', | 120 'remote_run', |
| 116 '--repository', args.repository, | 121 '--repository', args.repository, |
| 117 '--revision', args.revision, | 122 '--revision', args.revision, |
| 118 '--workdir', os.path.join(tempdir, 'remote_run_workdir'), | 123 '--workdir', os.path.join(tempdir, 'remote_run_workdir'), |
| 119 '--', | 124 '--', |
| 120 '--properties-file', properties_file, | 125 '--properties-file', properties_file, |
| 121 '--workdir', os.path.join(tempdir, 'run_workdir'), | 126 '--workdir', os.path.join(tempdir, 'work'), |
| 122 args.recipe, | 127 args.recipe, |
| 123 ] | 128 ] |
| 124 recipe_return_code = None | 129 recipe_return_code = None |
| 125 try: | 130 try: |
| 126 cmd = logdog_bootstrap.bootstrap(rt, args, basedir, tempdir, properties, | 131 cmd = logdog_bootstrap.bootstrap(rt, args, basedir, tempdir, properties, |
| 127 recipe_cmd) | 132 recipe_cmd) |
| 128 | 133 |
| 129 LOGGER.info('Bootstrapping through LogDog: %s', cmd) | 134 LOGGER.info('Bootstrapping through LogDog: %s', cmd) |
| 130 rc = _call(cmd) | 135 rc = _call(cmd) |
| 131 logdog_bootstrap.assert_not_bootstrap_return_code(rc) | 136 logdog_bootstrap.assert_not_bootstrap_return_code(rc) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 150 | 155 |
| 151 if update_scripts.update_scripts(): | 156 if update_scripts.update_scripts(): |
| 152 # Re-execute with the updated remote_run.py. | 157 # Re-execute with the updated remote_run.py. |
| 153 return _call([sys.executable] + argv) | 158 return _call([sys.executable] + argv) |
| 154 | 159 |
| 155 return main(argv) | 160 return main(argv) |
| 156 | 161 |
| 157 | 162 |
| 158 if __name__ == '__main__': | 163 if __name__ == '__main__': |
| 159 sys.exit(shell_main(sys.argv)) | 164 sys.exit(shell_main(sys.argv)) |
| OLD | NEW |