diff options
-rw-r--r-- | lib/spack/spack/cmd/location.py | 27 |
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: |