summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Padron <omar.padron@kitware.com>2020-02-25 17:32:20 -0500
committerGitHub <noreply@github.com>2020-02-25 17:32:20 -0500
commit00090f8f97d3811d522f194911dc63c96dc81ce8 (patch)
treec65f0b958afbc9ec41f9a501b54c3e86b3ef3c0f
parent8d750db9de9948a33d8b7d2f30c6f24a53628d25 (diff)
downloadspack-00090f8f97d3811d522f194911dc63c96dc81ce8.tar.gz
spack-00090f8f97d3811d522f194911dc63c96dc81ce8.tar.bz2
spack-00090f8f97d3811d522f194911dc63c96dc81ce8.tar.xz
spack-00090f8f97d3811d522f194911dc63c96dc81ce8.zip
add --only option to buildcache create cmd (#14921)
* add --only option to buildcache create cmd replaces the --no-deps option
-rw-r--r--lib/spack/spack/ci.py5
-rw-r--r--lib/spack/spack/cmd/buildcache.py38
-rwxr-xr-xshare/spack/spack-completion.bash2
3 files changed, 32 insertions, 13 deletions
diff --git a/lib/spack/spack/ci.py b/lib/spack/spack/ci.py
index ed06524073..cbdfccb8bf 100644
--- a/lib/spack/spack/ci.py
+++ b/lib/spack/spack/ci.py
@@ -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))
diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py
index f837e6b8a3..6fd4a2c5b7 100644
--- a/lib/spack/spack/cmd/buildcache.py
+++ b/lib/spack/spack/cmd/buildcache.py
@@ -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):
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index 4082b7ff41..d2e4a28682 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -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