hooks take spec as an argument (instead of pkg) (#3967)
This commit is contained in:
parent
58f2a947db
commit
fc9896ed45
6 changed files with 27 additions and 23 deletions
|
@ -31,10 +31,11 @@
|
||||||
|
|
||||||
Currently the following hooks are supported:
|
Currently the following hooks are supported:
|
||||||
|
|
||||||
* pre_install()
|
* pre_run()
|
||||||
* post_install()
|
* pre_install(spec)
|
||||||
* pre_uninstall()
|
* post_install(spec)
|
||||||
* post_uninstall()
|
* pre_uninstall(spec)
|
||||||
|
* post_uninstall(spec)
|
||||||
|
|
||||||
This can be used to implement support for things like module
|
This can be used to implement support for things like module
|
||||||
systems (e.g. modules, dotkit, etc.) or to add other custom
|
systems (e.g. modules, dotkit, etc.) or to add other custom
|
||||||
|
|
|
@ -24,8 +24,9 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
def pre_uninstall(pkg):
|
def pre_uninstall(spec):
|
||||||
assert(pkg.spec.concrete)
|
pkg = spec.package
|
||||||
|
assert spec.concrete
|
||||||
|
|
||||||
if pkg.is_extension:
|
if pkg.is_extension:
|
||||||
if pkg.activated:
|
if pkg.activated:
|
||||||
|
|
|
@ -29,8 +29,9 @@
|
||||||
from llnl.util.filesystem import join_path, mkdirp
|
from llnl.util.filesystem import join_path, mkdirp
|
||||||
|
|
||||||
|
|
||||||
def pre_install(pkg):
|
def pre_install(spec):
|
||||||
"""This hook handles global license setup for licensed software."""
|
"""This hook handles global license setup for licensed software."""
|
||||||
|
pkg = spec.package
|
||||||
if pkg.license_required and not pkg.spec.external:
|
if pkg.license_required and not pkg.spec.external:
|
||||||
set_up_license(pkg)
|
set_up_license(pkg)
|
||||||
|
|
||||||
|
@ -142,9 +143,11 @@ def write_license_file(pkg, license_path):
|
||||||
license.close()
|
license.close()
|
||||||
|
|
||||||
|
|
||||||
def post_install(pkg):
|
def post_install(spec):
|
||||||
"""This hook symlinks local licenses to the global license for
|
"""This hook symlinks local licenses to the global license for
|
||||||
licensed software."""
|
licensed software.
|
||||||
|
"""
|
||||||
|
pkg = spec.package
|
||||||
if pkg.license_required and not pkg.spec.external:
|
if pkg.license_required and not pkg.spec.external:
|
||||||
symlink_license(pkg)
|
symlink_license(pkg)
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
|
|
||||||
def post_install(pkg):
|
def post_install(spec):
|
||||||
for item, cls in iteritems(spack.modules.module_types):
|
for item, cls in iteritems(spack.modules.module_types):
|
||||||
generator = cls(pkg.spec)
|
generator = cls(spec)
|
||||||
generator.write()
|
generator.write()
|
||||||
|
|
||||||
|
|
||||||
def post_uninstall(pkg):
|
def post_uninstall(spec):
|
||||||
for item, cls in iteritems(spack.modules.module_types):
|
for item, cls in iteritems(spack.modules.module_types):
|
||||||
generator = cls(pkg.spec)
|
generator = cls(spec)
|
||||||
generator.remove()
|
generator.remove()
|
||||||
|
|
|
@ -102,14 +102,14 @@ def filter_shebangs_in_directory(directory, filenames=None):
|
||||||
filter_shebang(path)
|
filter_shebang(path)
|
||||||
|
|
||||||
|
|
||||||
def post_install(pkg):
|
def post_install(spec):
|
||||||
"""This hook edits scripts so that they call /bin/bash
|
"""This hook edits scripts so that they call /bin/bash
|
||||||
$spack_prefix/bin/sbang instead of something longer than the
|
$spack_prefix/bin/sbang instead of something longer than the
|
||||||
shebang limit.
|
shebang limit.
|
||||||
"""
|
"""
|
||||||
if pkg.spec.external:
|
if spec.external:
|
||||||
tty.debug('SKIP: shebang filtering [external package]')
|
tty.debug('SKIP: shebang filtering [external package]')
|
||||||
return
|
return
|
||||||
|
|
||||||
for directory, _, filenames in os.walk(pkg.prefix):
|
for directory, _, filenames in os.walk(spec.prefix):
|
||||||
filter_shebangs_in_directory(directory, filenames)
|
filter_shebangs_in_directory(directory, filenames)
|
||||||
|
|
|
@ -1112,7 +1112,7 @@ def _process_external_package(self, explicit):
|
||||||
# post-install hooks to generate module files
|
# post-install hooks to generate module files
|
||||||
message = '{s.name}@{s.version} : generating module file'
|
message = '{s.name}@{s.version} : generating module file'
|
||||||
tty.msg(message.format(s=self))
|
tty.msg(message.format(s=self))
|
||||||
spack.hooks.post_install(self)
|
spack.hooks.post_install(self.spec)
|
||||||
# Add to the DB
|
# Add to the DB
|
||||||
message = '{s.name}@{s.version} : registering into DB'
|
message = '{s.name}@{s.version} : registering into DB'
|
||||||
tty.msg(message.format(s=self))
|
tty.msg(message.format(s=self))
|
||||||
|
@ -1248,7 +1248,7 @@ def build_process(input_stream):
|
||||||
with self._stage_and_write_lock():
|
with self._stage_and_write_lock():
|
||||||
# Run the pre-install hook in the child process after
|
# Run the pre-install hook in the child process after
|
||||||
# the directory is created.
|
# the directory is created.
|
||||||
spack.hooks.pre_install(self)
|
spack.hooks.pre_install(self.spec)
|
||||||
if fake:
|
if fake:
|
||||||
self.do_fake_install()
|
self.do_fake_install()
|
||||||
else:
|
else:
|
||||||
|
@ -1288,7 +1288,7 @@ def build_process(input_stream):
|
||||||
self.spec, self.prefix)
|
self.spec, self.prefix)
|
||||||
self.log()
|
self.log()
|
||||||
# Run post install hooks before build stage is removed.
|
# Run post install hooks before build stage is removed.
|
||||||
spack.hooks.post_install(self)
|
spack.hooks.post_install(self.spec)
|
||||||
|
|
||||||
# Stop timer.
|
# Stop timer.
|
||||||
self._total_time = time.time() - start_time
|
self._total_time = time.time() - start_time
|
||||||
|
@ -1526,9 +1526,9 @@ def uninstall_by_spec(spec, force=False):
|
||||||
|
|
||||||
# Pre-uninstall hook runs first.
|
# Pre-uninstall hook runs first.
|
||||||
with spack.store.db.prefix_write_lock(spec):
|
with spack.store.db.prefix_write_lock(spec):
|
||||||
# TODO: hooks should take specs, not packages.
|
|
||||||
if pkg is not None:
|
if pkg is not None:
|
||||||
spack.hooks.pre_uninstall(pkg)
|
spack.hooks.pre_uninstall(spec)
|
||||||
|
|
||||||
# Uninstalling in Spack only requires removing the prefix.
|
# Uninstalling in Spack only requires removing the prefix.
|
||||||
if not spec.external:
|
if not spec.external:
|
||||||
|
@ -1541,9 +1541,8 @@ def uninstall_by_spec(spec, force=False):
|
||||||
spack.store.db.remove(spec)
|
spack.store.db.remove(spec)
|
||||||
tty.msg("Successfully uninstalled %s" % spec.short_spec)
|
tty.msg("Successfully uninstalled %s" % spec.short_spec)
|
||||||
|
|
||||||
# TODO: refactor hooks to use specs, not packages.
|
|
||||||
if pkg is not None:
|
if pkg is not None:
|
||||||
spack.hooks.post_uninstall(pkg)
|
spack.hooks.post_uninstall(spec)
|
||||||
|
|
||||||
tty.msg("Successfully uninstalled %s" % spec.short_spec)
|
tty.msg("Successfully uninstalled %s" % spec.short_spec)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue