diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-03-10 01:12:25 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2016-03-15 17:16:04 -0700 |
commit | 7eca383b10f017666c320ffd7deb6cae83b5c26b (patch) | |
tree | 7e07336195ce2004efe35592f2dbec0c8bd39d58 /lib | |
parent | 108ea1522a6c852b08e7b0eb9cde4d6aef53758c (diff) | |
download | spack-7eca383b10f017666c320ffd7deb6cae83b5c26b.tar.gz spack-7eca383b10f017666c320ffd7deb6cae83b5c26b.tar.bz2 spack-7eca383b10f017666c320ffd7deb6cae83b5c26b.tar.xz spack-7eca383b10f017666c320ffd7deb6cae83b5c26b.zip |
Add sanity check paths to packages; fix #505
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/package.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 696adaf896..02fb3e5834 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -318,6 +318,17 @@ class Package(object): """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 @@ class Package(object): 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 @@ class Package(object): 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: |