summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-02-08 19:36:30 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2015-02-08 19:36:30 -0800
commitbefe72b9b9d1f4107eef8f24e6f194f27a15bca4 (patch)
treefaa01de362b7ebbd7673bac681938131e132f3ce
parent5cc369c2b831446f1afaaba41cbf0dbdba75b4ed (diff)
downloadspack-befe72b9b9d1f4107eef8f24e6f194f27a15bca4.tar.gz
spack-befe72b9b9d1f4107eef8f24e6f194f27a15bca4.tar.bz2
spack-befe72b9b9d1f4107eef8f24e6f194f27a15bca4.tar.xz
spack-befe72b9b9d1f4107eef8f24e6f194f27a15bca4.zip
directory_layout now raises an error when an install fails.
-rw-r--r--lib/spack/spack/directory_layout.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
index efc40a17a4..37740720a2 100644
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -109,12 +109,17 @@ class DirectoryLayout(object):
def remove_path_for_spec(self, spec):
- """Removes a prefix and any empty parent directories from the root."""
+ """Removes a prefix and any empty parent directories from the root.
+ Raised RemoveFailedError if something goes wrong.
+ """
path = self.path_for_spec(spec)
assert(path.startswith(self.root))
if os.path.exists(path):
- shutil.rmtree(path, True)
+ try:
+ shutil.rmtree(path)
+ except exceptions.OSError, e:
+ raise RemoveFailedError(spec, path, e)
path = os.path.dirname(path)
while path != self.root:
@@ -330,6 +335,15 @@ class SpecHashCollisionError(DirectoryLayoutError):
% installed_spec, new_spec)
+class RemoveFailedError(DirectoryLayoutError):
+ """Raised when a DirectoryLayout cannot remove an install prefix."""
+ def __init__(self, installed_spec, prefix, error):
+ super(RemoveFailedError, self).__init__(
+ 'Could not remove prefix %s for %s : %s'
+ % prefix, installed_spec.short_spec, error)
+ self.cause = error
+
+
class InconsistentInstallDirectoryError(DirectoryLayoutError):
"""Raised when a package seems to be installed to the wrong place."""
def __init__(self, message):
@@ -370,3 +384,5 @@ class NoSuchExtensionError(DirectoryLayoutError):
super(NoSuchExtensionError, self).__init__(
"%s cannot be removed from %s because it's not installed."% (
extension_spec.short_spec, spec.short_spec))
+
+