From 944c5d75cdebc045be7065ec27e34b9ae0aea006 Mon Sep 17 00:00:00 2001 From: Carson Woods Date: Tue, 16 Jul 2019 14:03:00 -0600 Subject: [PATCH] Add --global flag to install cmd to install to globally accessible location --- lib/spack/spack/cmd/install.py | 21 ++++++++------------- lib/spack/spack/package.py | 1 + 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py index 22a76d5ddc5..993ebcdb08c 100644 --- a/lib/spack/spack/cmd/install.py +++ b/lib/spack/spack/cmd/install.py @@ -38,7 +38,8 @@ def update_kwargs_from_args(args, kwargs): 'verbose': args.verbose, 'fake': args.fake, 'dirty': args.dirty, - 'use_cache': args.use_cache + 'use_cache': args.use_cache, + 'global': args.install_global }) if hasattr(args, 'setup'): setups = set() @@ -102,6 +103,9 @@ def setup_parser(subparser): '-f', '--file', action='append', default=[], dest='specfiles', metavar='SPEC_YAML_FILE', help="install from file. Read specs to install from .yaml files") + subparser.add_argument( + '-g', '--global', action='store_true', default=False, + dest='install_global', help='install package to globally accesible location') cd_group = subparser.add_mutually_exclusive_group() arguments.add_common_arguments(cd_group, ['clean', 'dirty']) @@ -177,18 +181,9 @@ def default_log_file(spec): fmt = 'test-{x.name}-{x.version}-{hash}.xml' basename = fmt.format(x=spec, hash=spec.dag_hash()) - if spack.config.get('config:shared'): - if 'SPACK_PATH' in os.environ: - spack_path = os.environ['SPACK_PATH'] - else: - spack_path = os.path.expanduser('~/.spack/') - - if spack.config.get('config:shared'): - dirname = fs.os.path.join(spack_path, - 'var/', - 'junit-report') - else: - dirname = fs.os.path.join(spack.paths.var_path, 'junit-report') + dirname = fs.os.path.join(spack.paths.user_config_path, + 'var/spack', + 'junit-report') fs.mkdirp(dirname) return fs.os.path.join(dirname, basename) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 742d83cb722..5e9a8ee329b 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1491,6 +1491,7 @@ def do_install(self, **kwargs): tests = kwargs.get('tests', False) dirty = kwargs.get('dirty', False) restage = kwargs.get('restage', False) + install_global = kwargs.get('install_global', False) # For external packages the workflow is simplified, and basically # consists in module file generation and registration in the DB