summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@googlemail.com>2016-10-11 09:42:31 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2016-10-11 00:42:31 -0700
commitb1a2728af691a42f4c7e9a923d3bd242bee8fd7b (patch)
treef4eae2d9d1589f85860e190e0fdc89d11c982838
parentc8bf8a5e6e9858010bfaf47485458f8bf677cea3 (diff)
downloadspack-b1a2728af691a42f4c7e9a923d3bd242bee8fd7b.tar.gz
spack-b1a2728af691a42f4c7e9a923d3bd242bee8fd7b.tar.bz2
spack-b1a2728af691a42f4c7e9a923d3bd242bee8fd7b.tar.xz
spack-b1a2728af691a42f4c7e9a923d3bd242bee8fd7b.zip
uninstall : permits to uninstall all installed software fixes #1477 (#1973)
-rw-r--r--lib/spack/spack/cmd/uninstall.py68
1 files changed, 38 insertions, 30 deletions
diff --git a/lib/spack/spack/cmd/uninstall.py b/lib/spack/spack/cmd/uninstall.py
index e42c5776b5..2d09b88c8e 100644
--- a/lib/spack/spack/cmd/uninstall.py
+++ b/lib/spack/spack/cmd/uninstall.py
@@ -54,9 +54,10 @@ def setup_parser(subparser):
subparser.add_argument(
'-a', '--all', action='store_true', dest='all',
help="USE CAREFULLY. Remove ALL installed packages that match each "
- "supplied spec. i.e., if you say uninstall libelf, ALL versions "
- "of libelf are uninstalled. This is both useful and dangerous, "
- "like rm -r.")
+ "supplied spec. i.e., if you say uninstall `libelf`,"
+ " ALL versions of `libelf` are uninstalled. If no spec is "
+ "supplied all installed software will be uninstalled. This "
+ "is both useful and dangerous, like rm -r.")
subparser.add_argument(
'-d', '--dependents', action='store_true', dest='dependents',
@@ -157,37 +158,44 @@ def do_uninstall(specs, force):
item.do_uninstall(force=force)
+def get_uninstall_list(args):
+ specs = [any]
+ if args.packages:
+ specs = spack.cmd.parse_specs(args.packages)
+ # Gets the list of installed specs that match the ones give via cli
+ # takes care of '-a' is given in the cli
+ uninstall_list = concretize_specs(specs, args.all, args.force)
+ # Takes care of '-d'
+ dependent_list = installed_dependents(uninstall_list)
+ # Process dependent_list and update uninstall_list
+ has_error = False
+ if dependent_list and not args.dependents and not args.force:
+ for spec, lst in dependent_list.items():
+ tty.error("Will not uninstall %s" %
+ spec.format("$_$@$%@$#", color=True))
+ print('')
+ print("The following packages depend on it:")
+ spack.cmd.display_specs(lst, **display_args)
+ print('')
+ has_error = True
+ elif args.dependents:
+ for key, lst in dependent_list.items():
+ uninstall_list.extend(lst)
+ uninstall_list = list(set(uninstall_list))
+ if has_error:
+ tty.die('You can use spack uninstall --dependents '
+ 'to uninstall these dependencies as well')
+
+ return uninstall_list
+
+
def uninstall(parser, args):
- if not args.packages:
+ if not args.packages and not args.all:
tty.die("uninstall requires at least one package argument.")
with spack.installed_db.write_transaction():
- specs = spack.cmd.parse_specs(args.packages)
- # Gets the list of installed specs that match the ones give via cli
- # takes care of '-a' is given in the cli
- uninstall_list = concretize_specs(specs, args.all, args.force)
- dependent_list = installed_dependents(
- uninstall_list) # takes care of '-d'
-
- # Process dependent_list and update uninstall_list
- has_error = False
- if dependent_list and not args.dependents and not args.force:
- for spec, lst in dependent_list.items():
- tty.error("Will not uninstall %s" %
- spec.format("$_$@$%@$#", color=True))
- print('')
- print("The following packages depend on it:")
- spack.cmd.display_specs(lst, **display_args)
- print('')
- has_error = True
- elif args.dependents:
- for key, lst in dependent_list.items():
- uninstall_list.extend(lst)
- uninstall_list = list(set(uninstall_list))
-
- if has_error:
- tty.die('You can use spack uninstall --dependents '
- 'to uninstall these dependencies as well')
+
+ uninstall_list = get_uninstall_list(args)
if not args.yes_to_all:
tty.msg("The following packages will be uninstalled : ")