Add pre-install and pre-uninstall hooks.

This commit is contained in:
Todd Gamblin 2015-01-06 14:50:14 -05:00
parent ebe0c1d83a
commit adb7d614e6
2 changed files with 14 additions and 1 deletions

View file

@ -31,7 +31,9 @@
Currently the following hooks are supported: Currently the following hooks are supported:
* pre_install()
* post_install() * post_install()
* pre_uninstall()
* post_uninstall() * post_uninstall()
This can be used to implement support for things like module This can be used to implement support for things like module
@ -70,5 +72,8 @@ def __call__(self, pkg):
# #
# Define some functions that can be called to fire off hooks. # 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') post_uninstall = HookRunner('post_uninstall')

View file

@ -768,6 +768,10 @@ def do_install(self, **kwargs):
# package naming scheme it likes. # package naming scheme it likes.
spack.install_layout.make_path_for_spec(self.spec) 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. # Set up process's build environment before running install.
self.stage.chdir_to_source() self.stage.chdir_to_source()
build_env.setup_package(self) build_env.setup_package(self)
@ -862,6 +866,10 @@ def do_uninstall(self, **kwargs):
"The following installed packages depend on it: %s" % "The following installed packages depend on it: %s" %
' '.join(formatted_deps)) ' '.join(formatted_deps))
# Pre-uninstall hook runs first.
spack.hooks.pre_uninstall(self)
# Uninstalling in Spack only requires removing the prefix.
self.remove_prefix() self.remove_prefix()
tty.msg("Successfully uninstalled %s." % self.spec.short_spec) tty.msg("Successfully uninstalled %s." % self.spec.short_spec)