summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZack Galbreath <zack.galbreath@kitware.com>2018-04-10 11:00:14 -0400
committerTodd Gamblin <tgamblin@llnl.gov>2018-05-15 05:43:07 -0700
commitde01d70ae4746432270138881e3f8e573708c554 (patch)
tree7ce88d3409f01f86154a05d6c719501ec03a7715 /lib
parent6c5dbdd9cd73101c42252d400bc4168327633d3d (diff)
downloadspack-de01d70ae4746432270138881e3f8e573708c554.tar.gz
spack-de01d70ae4746432270138881e3f8e573708c554.tar.bz2
spack-de01d70ae4746432270138881e3f8e573708c554.tar.xz
spack-de01d70ae4746432270138881e3f8e573708c554.zip
Allow --overwrite and --log-format to be used together
Restructure the logic of the spack install command to allow these two command-line arguments to be used at the same time.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/install.py71
1 files changed, 35 insertions, 36 deletions
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index a4c6e5932e..99572a1ff2 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -216,41 +216,40 @@ def install(parser, args, **kwargs):
if len(specs) == 0:
tty.die('The `spack install` command requires a spec to install.')
- if args.overwrite:
- # If we asked to overwrite an existing spec we must ensure that:
- # 1. We have only one spec
- # 2. The spec is already installed
- assert len(specs) == 1, \
- "only one spec is allowed when overwriting an installation"
-
- spec = specs[0]
- t = spack.store.db.query(spec)
- assert len(t) == 1, "to overwrite a spec you must install it first"
-
- # Give the user a last chance to think about overwriting an already
- # existing installation
- if not args.yes_to_all:
- tty.msg('The following package will be reinstalled:\n')
-
- display_args = {
- 'long': True,
- 'show_flags': True,
- 'variants': True
- }
-
- spack.cmd.display_specs(t, **display_args)
- answer = tty.get_yes_or_no(
- 'Do you want to proceed?', default=False
- )
- if not answer:
- tty.die('Reinstallation aborted.')
-
- with fs.replace_directory_transaction(specs[0].prefix):
- install_spec(args, kwargs, specs[0])
-
- else:
-
- filename = args.log_file or default_log_file(specs[0])
- with spack.report.collect_info(specs, args.log_format, filename):
+ filename = args.log_file or default_log_file(specs[0])
+ with spack.report.collect_info(specs, args.log_format, filename):
+ if args.overwrite:
+ # If we asked to overwrite an existing spec we must ensure that:
+ # 1. We have only one spec
+ # 2. The spec is already installed
+ assert len(specs) == 1, \
+ "only one spec is allowed when overwriting an installation"
+
+ spec = specs[0]
+ t = spack.store.db.query(spec)
+ assert len(t) == 1, "to overwrite a spec you must install it first"
+
+ # Give the user a last chance to think about overwriting an already
+ # existing installation
+ if not args.yes_to_all:
+ tty.msg('The following package will be reinstalled:\n')
+
+ display_args = {
+ 'long': True,
+ 'show_flags': True,
+ 'variants': True
+ }
+
+ spack.cmd.display_specs(t, **display_args)
+ answer = tty.get_yes_or_no(
+ 'Do you want to proceed?', default=False
+ )
+ if not answer:
+ tty.die('Reinstallation aborted.')
+
+ with fs.replace_directory_transaction(specs[0].prefix):
+ install_spec(args, kwargs, specs[0])
+
+ else:
for spec in specs:
install_spec(args, kwargs, spec)