Add sanity check paths to packages; fix #505
This commit is contained in:
@@ -318,6 +318,17 @@ class SomePackage(Package):
|
|||||||
"""Most packages are NOT extendable. Set to True if you want extensions."""
|
"""Most packages are NOT extendable. Set to True if you want extensions."""
|
||||||
extendable = False
|
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):
|
def __init__(self, spec):
|
||||||
# this determines how the package should be built.
|
# this determines how the package should be built.
|
||||||
@@ -909,7 +920,7 @@ def build_process():
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
# Ensure that something was actually installed.
|
# Ensure that something was actually installed.
|
||||||
self._sanity_check_install()
|
self.sanity_check_prefix()
|
||||||
|
|
||||||
# Copy provenance into the install directory on success
|
# Copy provenance into the install directory on success
|
||||||
log_install_path = spack.install_layout.build_log_path(self.spec)
|
log_install_path = spack.install_layout.build_log_path(self.spec)
|
||||||
@@ -952,7 +963,18 @@ def build_process():
|
|||||||
spack.hooks.post_install(self)
|
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 = set(os.listdir(self.prefix))
|
||||||
installed.difference_update(spack.install_layout.hidden_file_paths)
|
installed.difference_update(spack.install_layout.hidden_file_paths)
|
||||||
if not installed:
|
if not installed:
|
||||||
|
Reference in New Issue
Block a user