Merge pull request #554 from LLNL/features/sanity-check-paths
Add sanity check paths to packages; fix #505
This commit is contained in:
commit
39a792adda
@ -318,6 +318,17 @@ class SomePackage(Package):
|
||||
"""Most packages are NOT extendable. Set to True if you want extensions."""
|
||||
extendable = False
|
||||
|
||||
"""List of prefix-relative file paths. If these do not exist after
|
||||
install, or if they exist but are not files, sanity checks fail.
|
||||
"""
|
||||
sanity_check_files = []
|
||||
|
||||
"""List of prefix-relative directory paths. If these do not exist
|
||||
after install, or if they exist but are not directories, sanity
|
||||
checks will fail.
|
||||
"""
|
||||
sanity_check_dirs = []
|
||||
|
||||
|
||||
def __init__(self, spec):
|
||||
# this determines how the package should be built.
|
||||
@ -909,7 +920,7 @@ def build_process():
|
||||
raise e
|
||||
|
||||
# Ensure that something was actually installed.
|
||||
self._sanity_check_install()
|
||||
self.sanity_check_prefix()
|
||||
|
||||
# Copy provenance into the install directory on success
|
||||
log_install_path = spack.install_layout.build_log_path(self.spec)
|
||||
@ -952,7 +963,18 @@ def build_process():
|
||||
spack.hooks.post_install(self)
|
||||
|
||||
|
||||
def _sanity_check_install(self):
|
||||
def sanity_check_prefix(self):
|
||||
"""This function checks whether install succeeded."""
|
||||
def check_paths(path_list, filetype, predicate):
|
||||
for path in path_list:
|
||||
abs_path = os.path.join(self.prefix, path)
|
||||
if not predicate(abs_path):
|
||||
raise InstallError("Install failed for %s. No such %s in prefix: %s"
|
||||
% (self.name, filetype, path))
|
||||
|
||||
check_paths(self.sanity_check_files, 'file', os.path.isfile)
|
||||
check_paths(self.sanity_check_dirs, 'directory', os.path.isdir)
|
||||
|
||||
installed = set(os.listdir(self.prefix))
|
||||
installed.difference_update(spack.install_layout.hidden_file_paths)
|
||||
if not installed:
|
||||
|
@ -38,6 +38,9 @@ class Libelf(Package):
|
||||
|
||||
provides('elf')
|
||||
|
||||
sanity_check_files = ['include/libelf.h']
|
||||
sanity_check_dirs = ['lib']
|
||||
|
||||
def install(self, spec, prefix):
|
||||
configure("--prefix=" + prefix,
|
||||
"--enable-shared",
|
||||
|
Loading…
Reference in New Issue
Block a user