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 """Tool to interact with recipe repositories. | 6 """Tool to interact with recipe repositories. |
7 | 7 |
8 This tool operates on the nearest ancestor directory containing an | 8 This tool operates on the nearest ancestor directory containing an |
9 infra/config/recipes.cfg. | 9 infra/config/recipes.cfg. |
10 """ | 10 """ |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 properties, stream_engine, | 140 properties, stream_engine, |
141 step_runner.SubprocessStepRunner(stream_engine), | 141 step_runner.SubprocessStepRunner(stream_engine), |
142 universe=universe) | 142 universe=universe) |
143 | 143 |
144 finally: | 144 finally: |
145 os.chdir(old_cwd) | 145 os.chdir(old_cwd) |
146 | 146 |
147 return handle_recipe_return(ret, args.output_result_json, stream_engine) | 147 return handle_recipe_return(ret, args.output_result_json, stream_engine) |
148 | 148 |
149 | 149 |
| 150 def remote_run(args): |
| 151 from recipe_engine import remote_run |
| 152 |
| 153 return remote_run.main(args) |
| 154 |
| 155 |
150 def autoroll(args): | 156 def autoroll(args): |
151 from recipe_engine import autoroll | 157 from recipe_engine import autoroll |
152 | 158 |
153 repo_root, config_file = get_package_config(args) | 159 repo_root, config_file = get_package_config(args) |
154 | 160 |
155 return autoroll.main(args, repo_root, config_file) | 161 return autoroll.main(args, repo_root, config_file) |
156 | 162 |
157 | 163 |
158 class ProjectOverrideAction(argparse.Action): | 164 class ProjectOverrideAction(argparse.Action): |
159 def __call__(self, parser, namespace, values, option_string=None): | 165 def __call__(self, parser, namespace, values, option_string=None): |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 help='The file to write the JSON serialized returned value \ | 286 help='The file to write the JSON serialized returned value \ |
281 of the recipe to') | 287 of the recipe to') |
282 run_p.add_argument( | 288 run_p.add_argument( |
283 'recipe', | 289 'recipe', |
284 help='The recipe to execute') | 290 help='The recipe to execute') |
285 run_p.add_argument( | 291 run_p.add_argument( |
286 'props', nargs=argparse.REMAINDER, | 292 'props', nargs=argparse.REMAINDER, |
287 help='A list of property pairs; e.g. mastername=chromium.linux ' | 293 help='A list of property pairs; e.g. mastername=chromium.linux ' |
288 'issue=12345') | 294 'issue=12345') |
289 | 295 |
| 296 remote_run_p = subp.add_parser( |
| 297 'remote_run', |
| 298 description='Run a recipe from specified repo and revision') |
| 299 remote_run_p.set_defaults(command='remote_run') |
| 300 remote_run_p.add_argument( |
| 301 '--repository', required=True, |
| 302 help='URL of a git repository to fetch') |
| 303 remote_run_p.add_argument( |
| 304 '--revision', default='FETCH_HEAD', |
| 305 help='Git commit hash to check out') |
| 306 remote_run_p.add_argument( |
| 307 '--workdir', |
| 308 help='The working directory of repo checkout') |
| 309 remote_run_p.add_argument( |
| 310 'run_args', nargs='*', |
| 311 help='Arguments to pass to fetched repo\'s recipes.py run') |
| 312 |
290 autoroll_p = subp.add_parser( | 313 autoroll_p = subp.add_parser( |
291 'autoroll', | 314 'autoroll', |
292 help='Roll dependencies of a recipe package forward (implies fetch)') | 315 help='Roll dependencies of a recipe package forward (implies fetch)') |
293 autoroll_p.set_defaults(command='autoroll') | 316 autoroll_p.set_defaults(command='autoroll') |
294 autoroll_p.add_argument( | 317 autoroll_p.add_argument( |
295 '--output-json', | 318 '--output-json', |
296 help='A json file to output information about the roll to.') | 319 help='A json file to output information about the roll to.') |
297 | 320 |
298 depgraph_p = subp.add_parser( | 321 depgraph_p = subp.add_parser( |
299 'depgraph', | 322 'depgraph', |
(...skipping 28 matching lines...) Expand all Loading... |
328 info_p.set_defaults(command='info') | 351 info_p.set_defaults(command='info') |
329 info_p.add_argument( | 352 info_p.add_argument( |
330 '--recipes-dir', action='store_true', | 353 '--recipes-dir', action='store_true', |
331 help='Get the subpath where the recipes live relative to repository root') | 354 help='Get the subpath where the recipes live relative to repository root') |
332 | 355 |
333 args = parser.parse_args() | 356 args = parser.parse_args() |
334 | 357 |
335 if args.verbose: | 358 if args.verbose: |
336 logging.getLogger().setLevel(logging.INFO) | 359 logging.getLogger().setLevel(logging.INFO) |
337 | 360 |
| 361 # Commands which do not require config_file, package_deps, and other objects |
| 362 # initialized later. |
| 363 if args.command == 'remote_run': |
| 364 return remote_run(args) |
| 365 |
338 repo_root, config_file = get_package_config(args) | 366 repo_root, config_file = get_package_config(args) |
339 | 367 |
340 try: | 368 try: |
341 # TODO(phajdan.jr): gracefully handle inconsistent deps when rolling. | 369 # TODO(phajdan.jr): gracefully handle inconsistent deps when rolling. |
342 # This fails if the starting point does not have consistent dependency | 370 # This fails if the starting point does not have consistent dependency |
343 # graph. When performing an automated roll, it'd make sense to attempt | 371 # graph. When performing an automated roll, it'd make sense to attempt |
344 # to automatically find a consistent state, rather than bailing out. | 372 # to automatically find a consistent state, rather than bailing out. |
345 # Especially that only some subcommands refer to package_deps. | 373 # Especially that only some subcommands refer to package_deps. |
346 package_deps = package.PackageDeps.create( | 374 package_deps = package.PackageDeps.create( |
347 repo_root, config_file, allow_fetch=not args.no_fetch, | 375 repo_root, config_file, allow_fetch=not args.no_fetch, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 ret = main() | 422 ret = main() |
395 if not isinstance(ret, int): | 423 if not isinstance(ret, int): |
396 if ret is None: | 424 if ret is None: |
397 ret = 0 | 425 ret = 0 |
398 else: | 426 else: |
399 print >> sys.stderr, ret | 427 print >> sys.stderr, ret |
400 ret = 1 | 428 ret = 1 |
401 sys.stdout.flush() | 429 sys.stdout.flush() |
402 sys.stderr.flush() | 430 sys.stderr.flush() |
403 os._exit(ret) | 431 os._exit(ret) |
OLD | NEW |