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.
This commit is contained in:
parent
6c5dbdd9cd
commit
de01d70ae4
@ -216,41 +216,40 @@ def install(parser, args, **kwargs):
|
|||||||
if len(specs) == 0:
|
if len(specs) == 0:
|
||||||
tty.die('The `spack install` command requires a spec to install.')
|
tty.die('The `spack install` command requires a spec to install.')
|
||||||
|
|
||||||
if args.overwrite:
|
filename = args.log_file or default_log_file(specs[0])
|
||||||
# If we asked to overwrite an existing spec we must ensure that:
|
with spack.report.collect_info(specs, args.log_format, filename):
|
||||||
# 1. We have only one spec
|
if args.overwrite:
|
||||||
# 2. The spec is already installed
|
# If we asked to overwrite an existing spec we must ensure that:
|
||||||
assert len(specs) == 1, \
|
# 1. We have only one spec
|
||||||
"only one spec is allowed when overwriting an installation"
|
# 2. The spec is already installed
|
||||||
|
assert len(specs) == 1, \
|
||||||
|
"only one spec is allowed when overwriting an installation"
|
||||||
|
|
||||||
spec = specs[0]
|
spec = specs[0]
|
||||||
t = spack.store.db.query(spec)
|
t = spack.store.db.query(spec)
|
||||||
assert len(t) == 1, "to overwrite a spec you must install it first"
|
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
|
# Give the user a last chance to think about overwriting an already
|
||||||
# existing installation
|
# existing installation
|
||||||
if not args.yes_to_all:
|
if not args.yes_to_all:
|
||||||
tty.msg('The following package will be reinstalled:\n')
|
tty.msg('The following package will be reinstalled:\n')
|
||||||
|
|
||||||
display_args = {
|
display_args = {
|
||||||
'long': True,
|
'long': True,
|
||||||
'show_flags': True,
|
'show_flags': True,
|
||||||
'variants': True
|
'variants': True
|
||||||
}
|
}
|
||||||
|
|
||||||
spack.cmd.display_specs(t, **display_args)
|
spack.cmd.display_specs(t, **display_args)
|
||||||
answer = tty.get_yes_or_no(
|
answer = tty.get_yes_or_no(
|
||||||
'Do you want to proceed?', default=False
|
'Do you want to proceed?', default=False
|
||||||
)
|
)
|
||||||
if not answer:
|
if not answer:
|
||||||
tty.die('Reinstallation aborted.')
|
tty.die('Reinstallation aborted.')
|
||||||
|
|
||||||
with fs.replace_directory_transaction(specs[0].prefix):
|
with fs.replace_directory_transaction(specs[0].prefix):
|
||||||
install_spec(args, kwargs, specs[0])
|
install_spec(args, kwargs, specs[0])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
filename = args.log_file or default_log_file(specs[0])
|
|
||||||
with spack.report.collect_info(specs, args.log_format, filename):
|
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
install_spec(args, kwargs, spec)
|
install_spec(args, kwargs, spec)
|
||||||
|
Loading…
Reference in New Issue
Block a user