OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The LUCI Authors. All rights reserved. | 2 # Copyright 2017 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 |
11 THIS IS A HACK. However, the API is solid. The general principle is that the | 11 THIS IS A HACK. However, the API is solid. The general principle is that the |
12 input to bundle is: | 12 input to bundle is: |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 add_subparser(parser): | 628 def add_subparser(parser): |
629 bundle_p = parser.add_parser( | 629 bundle_p = parser.add_parser( |
630 'bundle', | 630 'bundle', |
631 description=( | 631 help='Create a hermetically runnable recipe bundle.', |
632 'Create a hermetically runnable recipe bundle. This captures the result' | 632 description=( |
633 ' of all network operations the recipe_engine might normally do to' | 633 'Create a hermetically runnable recipe bundle. This captures the result' |
634 ' bootstrap itself.')) | 634 ' of all network operations the recipe_engine might normally do to' |
| 635 ' bootstrap itself.')) |
635 bundle_p.add_argument( | 636 bundle_p.add_argument( |
636 '--destination', default='./bundle', | 637 '--destination', default='./bundle', |
637 type=os.path.abspath, | 638 type=os.path.abspath, |
638 help='The directory of where to put the bundle (default: %(default)r).') | 639 help='The directory of where to put the bundle (default: %(default)r).') |
639 | 640 |
640 bundle_p.set_defaults(command='bundle', func=main) | 641 bundle_p.set_defaults(command='bundle', func=main) |
641 | 642 |
642 | 643 |
643 def main(package_deps, args): | 644 def main(package_deps, args): |
644 """ | 645 """ |
645 Args: | 646 Args: |
646 root_package (package.Package) - The recipes script in the produced bundle | 647 root_package (package.Package) - The recipes script in the produced bundle |
647 will be tuned to run commands using this package. | 648 will be tuned to run commands using this package. |
648 universe (loader.RecipeUniverse) - All of the recipes necessary to support | 649 universe (loader.RecipeUniverse) - All of the recipes necessary to support |
649 root_package. | 650 root_package. |
650 destination (str) - Path to the bundle output folder. This folder should not | 651 destination (str) - Path to the bundle output folder. This folder should not |
651 exist before calling this function. | 652 exist before calling this function. |
652 """ | 653 """ |
653 universe = loader.RecipeUniverse(package_deps, args.package) | 654 universe = loader.RecipeUniverse(package_deps, args.package) |
654 destination = args.destination | 655 destination = args.destination |
655 root_package = package_deps.root_package | 656 root_package = package_deps.root_package |
656 | 657 |
657 logging.basicConfig() | 658 logging.basicConfig() |
658 destination = prepare_destination(args.destination) | 659 destination = prepare_destination(args.destination) |
659 for pkg in universe.packages: | 660 for pkg in universe.packages: |
660 export_package(pkg, destination, pkg == root_package) | 661 export_package(pkg, destination, pkg == root_package) |
661 prep_recipes_py(universe, root_package, destination) | 662 prep_recipes_py(universe, root_package, destination) |
662 LOGGER.info('done!') | 663 LOGGER.info('done!') |
OLD | NEW |