summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-01-06 14:50:14 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2015-02-02 11:16:23 -0800
commitadb7d614e69a0c176c86b3b4aaa1e81d403d0a71 (patch)
treef033ff6fe9606ff5d3405fba521f0573eee643e2 /lib
parentebe0c1d83ac1380a6320a8dadcfa2ad4fc07c279 (diff)
downloadspack-adb7d614e69a0c176c86b3b4aaa1e81d403d0a71.tar.gz
spack-adb7d614e69a0c176c86b3b4aaa1e81d403d0a71.tar.bz2
spack-adb7d614e69a0c176c86b3b4aaa1e81d403d0a71.tar.xz
spack-adb7d614e69a0c176c86b3b4aaa1e81d403d0a71.zip
Add pre-install and pre-uninstall hooks.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/hooks/__init__.py7
-rw-r--r--lib/spack/spack/package.py8
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/spack/spack/hooks/__init__.py b/lib/spack/spack/hooks/__init__.py
index 98b7f2323f..1c44e8abaa 100644
--- a/lib/spack/spack/hooks/__init__.py
+++ b/lib/spack/spack/hooks/__init__.py
@@ -31,7 +31,9 @@
Currently the following hooks are supported:
+ * pre_install()
* post_install()
+ * pre_uninstall()
* post_uninstall()
This can be used to implement support for things like module
@@ -70,5 +72,8 @@ class HookRunner(object):
#
# Define some functions that can be called to fire off hooks.
#
-post_install = HookRunner('post_install')
+pre_install = HookRunner('pre_install')
+post_install = HookRunner('post_install')
+
+pre_uninstall = HookRunner('pre_uninstall')
post_uninstall = HookRunner('post_uninstall')
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index c256ea479f..aa79721266 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -768,6 +768,10 @@ class Package(object):
# package naming scheme it likes.
spack.install_layout.make_path_for_spec(self.spec)
+ # Run the pre-install hook in the child process after
+ # the directory is created.
+ spack.hooks.pre_install(self)
+
# Set up process's build environment before running install.
self.stage.chdir_to_source()
build_env.setup_package(self)
@@ -862,6 +866,10 @@ class Package(object):
"The following installed packages depend on it: %s" %
' '.join(formatted_deps))
+ # Pre-uninstall hook runs first.
+ spack.hooks.pre_uninstall(self)
+
+ # Uninstalling in Spack only requires removing the prefix.
self.remove_prefix()
tty.msg("Successfully uninstalled %s." % self.spec.short_spec)