summaryrefslogtreecommitdiff
path: root/lib
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 /lib
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
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/ci.py5
-rw-r--r--lib/spack/spack/cmd/buildcache.py38
2 files changed, 31 insertions, 12 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):