From e4613a60cfa47f30c67173e9298e9b2672d91603 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 29 Sep 2014 22:43:40 -0700 Subject: Fix for spack cd -i. --- lib/spack/spack/cmd/location.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'lib') 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 @@ -48,6 +48,9 @@ def setup_parser(subparser): directories.add_argument( '-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( @@ -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: -- cgit v1.2.3-70-g09d2