OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The LUCI Authors. All rights reserved. | 2 # Copyright 2016 The LUCI Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
5 | 5 |
6 """Bundles a universe_view into a standalone folder. | 6 """Bundles a universe_view into a standalone folder. |
7 | 7 |
8 This captures the result of doing all the network operations that recipe_engine | 8 This captures the result of doing all the network operations that recipe_engine |
9 might do at startup to fetch repo code. | 9 might do at startup to fetch repo code. |
10 | 10 |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 | 618 |
619 pkg_path = package.InfraRepoConfig().to_recipes_cfg( | 619 pkg_path = package.InfraRepoConfig().to_recipes_cfg( |
620 '"%%~dp0\\%s"' % root_package.name) | 620 '"%%~dp0\\%s"' % root_package.name) |
621 recipes_bat.write(u' --package %s ^\n' % pkg_path) | 621 recipes_bat.write(u' --package %s ^\n' % pkg_path) |
622 for pkg in universe.packages: | 622 for pkg in universe.packages: |
623 recipes_bat.write(u' -O %s=%%~dp0/%s ^\n' % ( | 623 recipes_bat.write(u' -O %s=%%~dp0/%s ^\n' % ( |
624 pkg.name, pkg.name)) | 624 pkg.name, pkg.name)) |
625 recipes_bat.write(u' %*\n') | 625 recipes_bat.write(u' %*\n') |
626 | 626 |
627 | 627 |
628 def main(root_package, universe, destination): | 628 def add_subparser(parser): |
629 bundle_p = parser.add_parser( | |
630 'bundle', | |
631 description=( | |
632 'Create a hermetically runnable recipe bundle. This captures the result' | |
633 ' of all network operations the recipe_engine might normally do to' | |
634 ' bootstrap itself.')) | |
635 bundle_p.add_argument( | |
636 '--destination', default='./bundle', | |
637 type=os.path.abspath, | |
638 help='The directory of where to put the bundle (default: %(default)r).') | |
639 | |
640 bundle_p.set_defaults(command='bundle', func=main) | |
641 | |
642 | |
643 def main(package_deps, args): | |
629 """ | 644 """ |
630 Args: | 645 Args: |
631 root_package (package.Package) - The recipes script in the produced bundle | 646 root_package (package.Package) - The recipes script in the produced bundle |
dnj
2017/04/27 16:33:53
nit: update args
| |
632 will be tuned to run commands using this package. | 647 will be tuned to run commands using this package. |
633 universe (loader.RecipeUniverse) - All of the recipes necessary to support | 648 universe (loader.RecipeUniverse) - All of the recipes necessary to support |
634 root_package. | 649 root_package. |
635 destination (str) - Path to the bundle output folder. This folder should not | 650 destination (str) - Path to the bundle output folder. This folder should not |
636 exist before calling this function. | 651 exist before calling this function. |
637 """ | 652 """ |
638 check(root_package, package.Package) | 653 universe = loader.RecipeUniverse(package_deps, args.package) |
639 check(universe, loader.RecipeUniverse) | 654 destination = args.destination |
640 check(destination, str) | 655 root_package = package_deps.root_package |
641 | 656 |
642 logging.basicConfig() | 657 logging.basicConfig() |
643 destination = prepare_destination(destination) | 658 destination = prepare_destination(args.destination) |
644 for pkg in universe.packages: | 659 for pkg in universe.packages: |
645 export_package(pkg, destination, pkg == root_package) | 660 export_package(pkg, destination, pkg == root_package) |
646 prep_recipes_py(universe, root_package, destination) | 661 prep_recipes_py(universe, root_package, destination) |
647 LOGGER.info('done!') | 662 LOGGER.info('done!') |
OLD | NEW |