summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2016-03-18 10:26:34 +0100
committeralalazo <massimiliano.culpo@googlemail.com>2016-03-18 10:26:34 +0100
commitf9438c75d0b07a149224408793e9b63968bb276b (patch)
tree1a847b19ec30d6947f39dec0aaeb6d2e02cf5312 /lib
parente55880904376847ce767770344059eef1ba7707c (diff)
parent179ed7cce642040f07ad94140b1e3cf6867b6936 (diff)
downloadspack-f9438c75d0b07a149224408793e9b63968bb276b.tar.gz
spack-f9438c75d0b07a149224408793e9b63968bb276b.tar.bz2
spack-f9438c75d0b07a149224408793e9b63968bb276b.tar.xz
spack-f9438c75d0b07a149224408793e9b63968bb276b.zip
Merge branch 'develop' of https://github.com/LLNL/spack into features/env_objects_flying_around
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/docs/mirrors.rst2
-rw-r--r--lib/spack/docs/packaging_guide.rst84
-rw-r--r--lib/spack/spack/package.py30
3 files changed, 99 insertions, 17 deletions
diff --git a/lib/spack/docs/mirrors.rst b/lib/spack/docs/mirrors.rst
index b20fedb55f..dad04d053b 100644
--- a/lib/spack/docs/mirrors.rst
+++ b/lib/spack/docs/mirrors.rst
@@ -38,7 +38,7 @@ contains tarballs for each package, named after each package.
.. note::
- Archives are **not** named exactly they were in the package's fetch
+ Archives are **not** named exactly the way they were in the package's fetch
URL. They have the form ``<name>-<version>.<extension>``, where
``<name>`` is Spack's name for the package, ``<version>`` is the
version of the tarball, and ``<extension>`` is whatever format the
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst
index 169899212d..c1077e4497 100644
--- a/lib/spack/docs/packaging_guide.rst
+++ b/lib/spack/docs/packaging_guide.rst
@@ -1559,11 +1559,11 @@ you ask for a particular spec.
A user may have certain preferences for how packages should
be concretized on their system. For example, one user may prefer packages
built with OpenMPI and the Intel compiler. Another user may prefer
-packages be built with MVAPICH and GCC.
+packages be built with MVAPICH and GCC.
Spack can be configured to prefer certain compilers, package
versions, depends_on, and variants during concretization.
-The preferred configuration can be controlled via the
+The preferred configuration can be controlled via the
``~/.spack/packages.yaml`` file for user configuations, or the
``etc/spack/packages.yaml`` site configuration.
@@ -1582,32 +1582,32 @@ Here's an example packages.yaml file that sets preferred packages:
compiler: [gcc@4.4.7, gcc@4.6:, intel, clang, pgi]
providers:
mpi: [mvapich, mpich, openmpi]
-
+
At a high level, this example is specifying how packages should be
-concretized. The dyninst package should prefer using gcc 4.9 and
+concretized. The dyninst package should prefer using gcc 4.9 and
be built with debug options. The gperftools package should prefer version
2.2 over 2.4. Every package on the system should prefer mvapich for
-its MPI and gcc 4.4.7 (except for Dyninst, which overrides this by preferring gcc 4.9).
-These options are used to fill in implicit defaults. Any of them can be overwritten
+its MPI and gcc 4.4.7 (except for Dyninst, which overrides this by preferring gcc 4.9).
+These options are used to fill in implicit defaults. Any of them can be overwritten
on the command line if explicitly requested.
-Each packages.yaml file begins with the string ``packages:`` and
+Each packages.yaml file begins with the string ``packages:`` and
package names are specified on the next level. The special string ``all``
-applies settings to each package. Underneath each package name is
-one or more components: ``compiler``, ``variants``, ``version``,
-or ``providers``. Each component has an ordered list of spec
+applies settings to each package. Underneath each package name is
+one or more components: ``compiler``, ``variants``, ``version``,
+or ``providers``. Each component has an ordered list of spec
``constraints``, with earlier entries in the list being preferred over
later entries.
-Sometimes a package installation may have constraints that forbid
+Sometimes a package installation may have constraints that forbid
the first concretization rule, in which case Spack will use the first
legal concretization rule. Going back to the example, if a user
-requests gperftools 2.3 or later, then Spack will install version 2.4
+requests gperftools 2.3 or later, then Spack will install version 2.4
as the 2.4 version of gperftools is preferred over 2.3.
-An explicit concretization rule in the preferred section will always
-take preference over unlisted concretizations. In the above example,
+An explicit concretization rule in the preferred section will always
+take preference over unlisted concretizations. In the above example,
xlc isn't listed in the compiler list. Every listed compiler from
gcc to pgi will thus be preferred over the xlc compiler.
@@ -2160,6 +2160,62 @@ package, this allows us to avoid race conditions in the library's
build system.
+.. _sanity-checks:
+
+Sanity checking an intallation
+--------------------------------
+
+By default, Spack assumes that a build has failed if nothing is
+written to the install prefix, and that it has succeeded if anything
+(a file, a directory, etc.) is written to the install prefix after
+``install()`` completes.
+
+Consider a simple autotools build like this:
+
+.. code-block:: python
+
+ def install(self, spec, prefix):
+ configure("--prefix=" + prefix)
+ make()
+ make("install")
+
+If you are using using standard autotools or CMake, ``configure`` and
+``make`` will not write anything to the install prefix. Only ``make
+install`` writes the files, and only once the build is already
+complete. Not all builds are like this. Many builds of scientific
+software modify the install prefix *before* ``make install``. Builds
+like this can falsely report that they were successfully installed if
+an error occurs before the install is complete but after files have
+been written to the ``prefix``.
+
+
+``sanity_check_is_file`` and ``sanity_check_is_dir``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can optionally specify *sanity checks* to deal with this problem.
+Add properties like this to your package:
+
+.. code-block:: python
+
+ class MyPackage(Package):
+ ...
+
+ sanity_check_is_file = ['include/libelf.h']
+ sanity_check_is_dir = [lib]
+
+ def install(self, spec, prefix):
+ configure("--prefix=" + prefix)
+ make()
+ make("install")
+
+Now, after ``install()`` runs, Spack will check whether
+``$prefix/include/libelf.h`` exists and is a file, and whether
+``$prefix/lib`` exists and is a directory. If the checks fail, then
+the build will fail and the install prefix will be removed. If they
+succeed, Spack considers the build succeeful and keeps the prefix in
+place.
+
+
.. _file-manipulation:
File manipulation functions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index a7ab20137e..185e3ad2ee 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -312,6 +312,18 @@ class Package(object):
"""Most packages are NOT extendable. Set to True if you want extensions."""
extendable = False
+ """List of prefix-relative file paths (or a single path). If these do
+ not exist after install, or if they exist but are not files,
+ sanity checks fail.
+ """
+ sanity_check_is_file = []
+
+ """List of prefix-relative directory paths (or a single path). If
+ these do not exist after install, or if they exist but are not
+ directories, sanity checks will fail.
+ """
+ sanity_check_is_dir = []
+
def __init__(self, spec):
# this determines how the package should be built.
@@ -903,7 +915,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)
@@ -946,7 +958,21 @@ 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):
+ if isinstance(path_list, basestring):
+ path_list = [path_list]
+
+ 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_is_file, 'file', os.path.isfile)
+ check_paths(self.sanity_check_is_dir, 'directory', os.path.isdir)
+
installed = set(os.listdir(self.prefix))
installed.difference_update(spack.install_layout.hidden_file_paths)
if not installed: