add --only option to buildcache create cmd (#14921)
* add --only option to buildcache create cmd replaces the --no-deps option
This commit is contained in:
		| @@ -947,8 +947,9 @@ def read_cdashid_from_mirror(spec, mirror_url): | ||||
| def push_mirror_contents(env, spec, yaml_path, mirror_url, build_id): | ||||
|     if mirror_url: | ||||
|         tty.debug('Creating buildcache') | ||||
|         buildcache._createtarball(env, yaml_path, None, mirror_url, None, | ||||
|                                   True, True, False, False, True, False) | ||||
|         buildcache._createtarball(env, yaml_path, None, True, False, | ||||
|                                   mirror_url, None, True, False, False, True, | ||||
|                                   False) | ||||
|         if build_id: | ||||
|             tty.debug('Writing cdashid ({0}) to remote mirror: {1}'.format( | ||||
|                 build_id, mirror_url)) | ||||
|   | ||||
| @@ -60,8 +60,14 @@ def setup_parser(subparser): | ||||
|                                             "building package(s)") | ||||
|     create.add_argument('-y', '--spec-yaml', default=None, | ||||
|                         help='Create buildcache entry for spec from yaml file') | ||||
|     create.add_argument('--no-deps', action='store_true', default='false', | ||||
|                         help='Create buildcache entry wo/ dependencies') | ||||
|     create.add_argument('--only', default='package,dependencies', | ||||
|                         dest='things_to_install', | ||||
|                         choices=['package', 'dependencies'], | ||||
|                         help=('Select the buildcache mode. the default is to' | ||||
|                               ' build a cache for the package along with all' | ||||
|                               ' its dependencies. Alternatively, one can' | ||||
|                               ' decide to build a cache for only the package' | ||||
|                               ' or only the dependencies')) | ||||
|     arguments.add_common_arguments(create, ['specs']) | ||||
|     create.set_defaults(func=createtarball) | ||||
| 
 | ||||
| @@ -304,8 +310,8 @@ def match_downloaded_specs(pkgs, allow_multiple_matches=False, force=False, | ||||
|     return specs_from_cli | ||||
| 
 | ||||
| 
 | ||||
| def _createtarball(env, spec_yaml, packages, directory, key, no_deps, force, | ||||
|                    rel, unsigned, allow_root, no_rebuild_index): | ||||
| def _createtarball(env, spec_yaml, packages, add_spec, add_deps, directory, | ||||
|                    key, force, rel, unsigned, allow_root, no_rebuild_index): | ||||
|     if spec_yaml: | ||||
|         packages = set() | ||||
|         with open(spec_yaml, 'r') as fd: | ||||
| @@ -347,14 +353,23 @@ def _createtarball(env, spec_yaml, packages, directory, key, no_deps, force, | ||||
|             tty.debug('skipping external or virtual spec %s' % | ||||
|                       match.format()) | ||||
|         else: | ||||
|             tty.debug('adding matching spec %s' % match.format()) | ||||
|             specs.add(match) | ||||
|             if no_deps is True: | ||||
|             if add_spec: | ||||
|                 tty.debug('adding matching spec %s' % match.format()) | ||||
|                 specs.add(match) | ||||
|             else: | ||||
|                 tty.debug('skipping matching spec %s' % match.format()) | ||||
| 
 | ||||
|             if not add_deps: | ||||
|                 continue | ||||
| 
 | ||||
|             tty.debug('recursing dependencies') | ||||
|             for d, node in match.traverse(order='post', | ||||
|                                           depth=True, | ||||
|                                           deptype=('link', 'run')): | ||||
|                 # skip root, since it's handled above | ||||
|                 if d == 0: | ||||
|                     continue | ||||
| 
 | ||||
|                 if node.external or node.virtual: | ||||
|                     tty.debug('skipping external or virtual dependency %s' % | ||||
|                               node.format()) | ||||
| @@ -377,9 +392,12 @@ def createtarball(args): | ||||
|     # restrict matching to current environment if one is active | ||||
|     env = ev.get_env(args, 'buildcache create') | ||||
| 
 | ||||
|     _createtarball(env, args.spec_yaml, args.specs, args.directory, | ||||
|                    args.key, args.no_deps, args.force, args.rel, args.unsigned, | ||||
|                    args.allow_root, args.no_rebuild_index) | ||||
|     add_spec = ('package' in args.things_to_install) | ||||
|     add_deps = ('dependencies' in args.things_to_install) | ||||
| 
 | ||||
|     _createtarball(env, args.spec_yaml, args.specs, add_spec, add_deps, | ||||
|                    args.directory, args.key, args.force, args.rel, | ||||
|                    args.unsigned, args.allow_root, args.no_rebuild_index) | ||||
| 
 | ||||
| 
 | ||||
| def installtarball(args): | ||||
|   | ||||
| @@ -382,7 +382,7 @@ _spack_buildcache() { | ||||
| _spack_buildcache_create() { | ||||
|     if $list_options | ||||
|     then | ||||
|         SPACK_COMPREPLY="-h --help -r --rel -f --force -u --unsigned -a --allow-root -k --key -d --directory --no-rebuild-index -y --spec-yaml --no-deps" | ||||
|         SPACK_COMPREPLY="-h --help -r --rel -f --force -u --unsigned -a --allow-root -k --key -d --directory --no-rebuild-index -y --spec-yaml --only" | ||||
|     else | ||||
|         _all_packages | ||||
|     fi | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Omar Padron
					Omar Padron