summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-09-29 22:43:40 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2014-09-29 22:43:40 -0700
commite4613a60cfa47f30c67173e9298e9b2672d91603 (patch)
tree040a9b084b21f337ea5a5888961eec110a4fc686 /lib
parent70475d08c0c05176f9ba8bb36d71dd8b80a40f84 (diff)
downloadspack-e4613a60cfa47f30c67173e9298e9b2672d91603.tar.gz
spack-e4613a60cfa47f30c67173e9298e9b2672d91603.tar.bz2
spack-e4613a60cfa47f30c67173e9298e9b2672d91603.tar.xz
spack-e4613a60cfa47f30c67173e9298e9b2672d91603.zip
Fix for spack cd -i.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/location.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/spack/spack/cmd/location.py b/lib/spack/spack/cmd/location.py
index 074d984ee6..116cf6ee6c 100644
--- a/lib/spack/spack/cmd/location.py
+++ b/lib/spack/spack/cmd/location.py
@@ -49,6 +49,9 @@ def setup_parser(subparser):
'-p', '--package-dir', action='store_true',
help="Directory enclosing a spec's package.py file.")
directories.add_argument(
+ '-P', '--packages', action='store_true',
+ help="Top-level packages directory for Spack.")
+ directories.add_argument(
'-s', '--stage-dir', action='store_true', help="Stage directory for a spec.")
directories.add_argument(
'-b', '--build-dir', action='store_true',
@@ -65,21 +68,39 @@ def location(parser, args):
elif args.spack_root:
print spack.prefix
+ elif args.packages:
+ print spack.db.root
+
else:
- specs = spack.cmd.parse_specs(args.spec, concretize=True)
+ specs = spack.cmd.parse_specs(args.spec)
if not specs:
tty.die("You must supply a spec.")
if len(specs) != 1:
- tty.die("Too many specs. Need only one.")
+ tty.die("Too many specs. Supply only one.")
spec = specs[0]
if args.install_dir:
- print spec.prefix
+ # install_dir command matches against installed specs.
+ matching_specs = spack.db.get_installed(spec)
+ if not matching_specs:
+ tty.die("Spec '%s' matches no installed packages." % spec)
+
+ elif len(matching_specs) > 1:
+ args = ["%s matches multiple packages." % spec,
+ "Matching packages:"]
+ args += [" " + str(s) for s in matching_specs]
+ args += ["Use a more specific spec."]
+ tty.die(*args)
+
+ print matching_specs[0].prefix
elif args.package_dir:
+ # This one just needs the spec name.
print join_path(spack.db.root, spec.name)
else:
+ # These versions need concretized specs.
+ spec.concretize()
pkg = spack.db.get(spec)
if args.stage_dir: