Allow forced deactivation -- best effort unlinking
spack deactivate -f will unlink even if Spack thinks the package isn't enabled. Made deactivate routines idempotent.
This commit is contained in:
parent
8aa3afcfde
commit
614c22fc1b
4 changed files with 15 additions and 4 deletions
|
@ -175,6 +175,10 @@ def unmerge(self, dest_root, **kwargs):
|
|||
kwargs['order'] = 'post'
|
||||
for src, dest in traverse_tree(self._root, dest_root, **kwargs):
|
||||
if os.path.isdir(src):
|
||||
# Skip non-existing links.
|
||||
if not os.path.exists(dest):
|
||||
continue
|
||||
|
||||
if not os.path.isdir(dest):
|
||||
raise ValueError("File blocks directory: %s" % dest)
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
description = "Deactivate a package extension."
|
||||
|
||||
def setup_parser(subparser):
|
||||
subparser.add_argument(
|
||||
'-f', '--force', action='store_true',
|
||||
help="Run deactivation even if spec is NOT currently activated.")
|
||||
subparser.add_argument(
|
||||
'spec', nargs=argparse.REMAINDER, help="spec of package extension to deactivate.")
|
||||
|
||||
|
@ -44,7 +47,7 @@ def deactivate(parser, args):
|
|||
spack.db.get(specs[0])
|
||||
|
||||
spec = spack.cmd.disambiguate_spec(specs[0])
|
||||
if not spec.package.activated:
|
||||
if not args.force and not spec.package.activated:
|
||||
tty.die("Package %s is not activated." % specs[0].short_spec)
|
||||
|
||||
spec.package.do_deactivate()
|
||||
spec.package.do_deactivate(force=args.force)
|
||||
|
|
|
@ -122,5 +122,8 @@ def find(parser, args):
|
|||
|
||||
if not args.mode:
|
||||
args.mode = 'short'
|
||||
|
||||
if sys.stdout.isatty():
|
||||
tty.msg("%d installed packages." % len(specs))
|
||||
display_specs(specs, mode=args.mode)
|
||||
|
||||
|
|
|
@ -155,5 +155,6 @@ def deactivate(self, ext_pkg, **args):
|
|||
super(Python, self).deactivate(ext_pkg, **args)
|
||||
|
||||
exts = spack.install_layout.extension_map(self.spec)
|
||||
del exts[ext_pkg.name]
|
||||
self.write_easy_install_pth(exts)
|
||||
if ext_pkg.name in exts: # Make deactivate idempotent.
|
||||
del exts[ext_pkg.name]
|
||||
self.write_easy_install_pth(exts)
|
||||
|
|
Loading…
Reference in a new issue