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:
parent
8d750db9de
commit
00090f8f97
@ -947,8 +947,9 @@ def read_cdashid_from_mirror(spec, mirror_url):
|
|||||||
def push_mirror_contents(env, spec, yaml_path, mirror_url, build_id):
|
def push_mirror_contents(env, spec, yaml_path, mirror_url, build_id):
|
||||||
if mirror_url:
|
if mirror_url:
|
||||||
tty.debug('Creating buildcache')
|
tty.debug('Creating buildcache')
|
||||||
buildcache._createtarball(env, yaml_path, None, mirror_url, None,
|
buildcache._createtarball(env, yaml_path, None, True, False,
|
||||||
True, True, False, False, True, False)
|
mirror_url, None, True, False, False, True,
|
||||||
|
False)
|
||||||
if build_id:
|
if build_id:
|
||||||
tty.debug('Writing cdashid ({0}) to remote mirror: {1}'.format(
|
tty.debug('Writing cdashid ({0}) to remote mirror: {1}'.format(
|
||||||
build_id, mirror_url))
|
build_id, mirror_url))
|
||||||
|
@ -60,8 +60,14 @@ def setup_parser(subparser):
|
|||||||
"building package(s)")
|
"building package(s)")
|
||||||
create.add_argument('-y', '--spec-yaml', default=None,
|
create.add_argument('-y', '--spec-yaml', default=None,
|
||||||
help='Create buildcache entry for spec from yaml file')
|
help='Create buildcache entry for spec from yaml file')
|
||||||
create.add_argument('--no-deps', action='store_true', default='false',
|
create.add_argument('--only', default='package,dependencies',
|
||||||
help='Create buildcache entry wo/ 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'])
|
arguments.add_common_arguments(create, ['specs'])
|
||||||
create.set_defaults(func=createtarball)
|
create.set_defaults(func=createtarball)
|
||||||
|
|
||||||
@ -304,8 +310,8 @@ def match_downloaded_specs(pkgs, allow_multiple_matches=False, force=False,
|
|||||||
return specs_from_cli
|
return specs_from_cli
|
||||||
|
|
||||||
|
|
||||||
def _createtarball(env, spec_yaml, packages, directory, key, no_deps, force,
|
def _createtarball(env, spec_yaml, packages, add_spec, add_deps, directory,
|
||||||
rel, unsigned, allow_root, no_rebuild_index):
|
key, force, rel, unsigned, allow_root, no_rebuild_index):
|
||||||
if spec_yaml:
|
if spec_yaml:
|
||||||
packages = set()
|
packages = set()
|
||||||
with open(spec_yaml, 'r') as fd:
|
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' %
|
tty.debug('skipping external or virtual spec %s' %
|
||||||
match.format())
|
match.format())
|
||||||
else:
|
else:
|
||||||
tty.debug('adding matching spec %s' % match.format())
|
if add_spec:
|
||||||
specs.add(match)
|
tty.debug('adding matching spec %s' % match.format())
|
||||||
if no_deps is True:
|
specs.add(match)
|
||||||
|
else:
|
||||||
|
tty.debug('skipping matching spec %s' % match.format())
|
||||||
|
|
||||||
|
if not add_deps:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tty.debug('recursing dependencies')
|
tty.debug('recursing dependencies')
|
||||||
for d, node in match.traverse(order='post',
|
for d, node in match.traverse(order='post',
|
||||||
depth=True,
|
depth=True,
|
||||||
deptype=('link', 'run')):
|
deptype=('link', 'run')):
|
||||||
|
# skip root, since it's handled above
|
||||||
|
if d == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
if node.external or node.virtual:
|
if node.external or node.virtual:
|
||||||
tty.debug('skipping external or virtual dependency %s' %
|
tty.debug('skipping external or virtual dependency %s' %
|
||||||
node.format())
|
node.format())
|
||||||
@ -377,9 +392,12 @@ def createtarball(args):
|
|||||||
# restrict matching to current environment if one is active
|
# restrict matching to current environment if one is active
|
||||||
env = ev.get_env(args, 'buildcache create')
|
env = ev.get_env(args, 'buildcache create')
|
||||||
|
|
||||||
_createtarball(env, args.spec_yaml, args.specs, args.directory,
|
add_spec = ('package' in args.things_to_install)
|
||||||
args.key, args.no_deps, args.force, args.rel, args.unsigned,
|
add_deps = ('dependencies' in args.things_to_install)
|
||||||
args.allow_root, args.no_rebuild_index)
|
|
||||||
|
_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):
|
def installtarball(args):
|
||||||
|
@ -382,7 +382,7 @@ _spack_buildcache() {
|
|||||||
_spack_buildcache_create() {
|
_spack_buildcache_create() {
|
||||||
if $list_options
|
if $list_options
|
||||||
then
|
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
|
else
|
||||||
_all_packages
|
_all_packages
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user