summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rw-r--r--share/spack/csh/pathadd.csh5
-rw-r--r--share/spack/csh/spack.csh55
-rw-r--r--share/spack/docker/Dockerfile132
-rwxr-xr-xshare/spack/docker/build-image.sh84
-rw-r--r--share/spack/docker/config/arch.bash18
-rw-r--r--share/spack/docker/config/centos.bash16
-rw-r--r--share/spack/docker/config/fedora.bash16
-rw-r--r--share/spack/docker/config/opensuse.bash16
-rw-r--r--share/spack/docker/config/scilinux.bash17
-rw-r--r--share/spack/docker/config/ubuntu.bash15
-rwxr-xr-xshare/spack/docker/dpp.bash77
-rwxr-xr-xshare/spack/docker/entrypoint.bash43
-rw-r--r--share/spack/docker/handle-prompt.sh169
-rw-r--r--share/spack/docker/handle-ssh.sh41
-rw-r--r--share/spack/docker/modules.yaml6
l---------share/spack/docker/push-image.sh1
l---------share/spack/docker/render-image-template.sh1
l---------share/spack/docker/run-image.sh1
-rw-r--r--share/spack/docs/docker/module-file-tutorial/Dockerfile3
-rw-r--r--share/spack/docs/docker/module-file-tutorial/spack.sh5
-rwxr-xr-xshare/spack/qa/run-build-tests15
-rwxr-xr-xshare/spack/qa/run-doc-tests6
-rwxr-xr-xshare/spack/qa/run-flake8-tests10
-rwxr-xr-xshare/spack/qa/run-unit-tests15
-rwxr-xr-xshare/spack/qa/setup.sh10
-rwxr-xr-xshare/spack/setup-env.csh38
-rwxr-xr-xshare/spack/setup-env.sh118
-rwxr-xr-xshare/spack/spack-completion.bash396
-rw-r--r--share/spack/templates/modules/modulefile.dk31
-rw-r--r--share/spack/templates/modules/modulefile.lua91
-rw-r--r--share/spack/templates/modules/modulefile.tcl82
-rw-r--r--share/spack/templates/reports/cdash/Build.xml27
-rw-r--r--share/spack/templates/reports/cdash/Configure.xml8
-rw-r--r--share/spack/templates/reports/cdash/Site.xml7
-rw-r--r--share/spack/templates/reports/cdash/Update.xml11
-rw-r--r--share/spack/templates/reports/junit.xml51
36 files changed, 1466 insertions, 171 deletions
diff --git a/share/spack/csh/pathadd.csh b/share/spack/csh/pathadd.csh
index 1e0800c5f3..5e94d4a4c0 100644
--- a/share/spack/csh/pathadd.csh
+++ b/share/spack/csh/pathadd.csh
@@ -1,3 +1,8 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
########################################################################
# Prepends directories to path, if they exist.
# pathadd /path/to/dir # add to PATH
diff --git a/share/spack/csh/spack.csh b/share/spack/csh/spack.csh
index 5acd190449..a773dd216b 100644
--- a/share/spack/csh/spack.csh
+++ b/share/spack/csh/spack.csh
@@ -1,3 +1,8 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
########################################################################
# This is a wrapper around the spack command that forwards calls to
# 'spack use' and 'spack unuse' to shell functions. This in turn
@@ -58,6 +63,47 @@ case cd:
cd `\spack location $_sp_arg $_sp_args`
endif
breaksw
+case env:
+ shift _sp_args # get rid of 'env'
+
+ set _sp_arg=""
+ [ $#_sp_args -gt 0 ] && set _sp_arg = ($_sp_args[1])
+
+ if ( "$_sp_arg" == "-h" ) then
+ \spack env -h
+ else
+ switch ($_sp_arg)
+ case activate:
+ set _sp_env_arg=""
+ [ $#_sp_args -gt 1 ] && set _sp_env_arg = ($_sp_args[2])
+
+ if ( "$_sp_env_arg" == "" || "$_sp_args" =~ "*--sh*" || "$_sp_args" =~ "*--csh*" || "$_sp_args" =~ "*-h*" ) then
+ # no args or args contain -h/--help, --sh, or --csh: just execute
+ \spack $_sp_flags env $_sp_args
+ else
+ shift _sp_args # consume 'activate' or 'deactivate'
+ # actual call to activate: source the output
+ eval `\spack $_sp_flags env activate --csh $_sp_args`
+ endif
+ breaksw
+ case deactivate:
+ set _sp_env_arg=""
+ [ $#_sp_args -gt 1 ] && set _sp_env_arg = ($_sp_args[2])
+
+ if ( "$_sp_env_arg" != "" ) then
+ # with args: execute the command
+ \spack $_sp_flags env $_sp_args
+ else
+ # no args: source the output
+ eval `\spack $_sp_flags env deactivate --csh`
+ endif
+ breaksw
+ default:
+ echo default
+ \spack $_sp_flags env $_sp_args
+ breaksw
+ endsw
+ endif
case use:
case unuse:
case load:
@@ -74,25 +120,25 @@ case unload:
# tool's commands to add/remove the result from the environment.
switch ($_sp_subcommand)
case "use":
- set _sp_full_spec = ( "`\spack $_sp_flags module find --module-type dotkit $_sp_spec`" )
+ set _sp_full_spec = ( "`\spack $_sp_flags module dotkit find $_sp_spec`" )
if ( $? == 0 ) then
use $_sp_module_args $_sp_full_spec
endif
breaksw
case "unuse":
- set _sp_full_spec = ( "`\spack $_sp_flags module find --module-type dotkit $_sp_spec`" )
+ set _sp_full_spec = ( "`\spack $_sp_flags module dotkit find $_sp_spec`" )
if ( $? == 0 ) then
unuse $_sp_module_args $_sp_full_spec
endif
breaksw
case "load":
- set _sp_full_spec = ( "`\spack $_sp_flags module find --module-type tcl $_sp_spec`" )
+ set _sp_full_spec = ( "`\spack $_sp_flags module tcl find $_sp_spec`" )
if ( $? == 0 ) then
module load $_sp_module_args $_sp_full_spec
endif
breaksw
case "unload":
- set _sp_full_spec = ( "`\spack $_sp_flags module find --module-type tcl $_sp_spec`" )
+ set _sp_full_spec = ( "`\spack $_sp_flags module tcl find $_sp_spec`" )
if ( $? == 0 ) then
module unload $_sp_module_args $_sp_full_spec
endif
@@ -108,3 +154,4 @@ endsw
_sp_end:
unset _sp_args _sp_full_spec _sp_modtype _sp_module_args
unset _sp_sh_cmd _sp_spec _sp_subcommand _sp_flags
+unset _sp_arg _sp_env_arg
diff --git a/share/spack/docker/Dockerfile b/share/spack/docker/Dockerfile
new file mode 100644
index 0000000000..0c3b49f366
--- /dev/null
+++ b/share/spack/docker/Dockerfile
@@ -0,0 +1,132 @@
+ARG BASE
+
+FROM $BASE
+MAINTAINER Spack Maintainers <maintainers@spack.io>
+
+ARG BASE
+ARG DISTRO
+ARG DISTRO_VERSION
+
+ENV DOCKERFILE_BASE=$BASE \
+ DOCKERFILE_DISTRO=$DISTRO \
+ DOCKERFILE_DISTRO_VERSION=$DISTRO_VERSION \
+ SPACK_ROOT=/spack \
+ FORCE_UNSAFE_CONFIGURE=1 \
+ DEBIAN_FRONTEND=noninteractive \
+ container=docker
+
+COPY bin $SPACK_ROOT/bin
+COPY etc $SPACK_ROOT/etc
+COPY lib $SPACK_ROOT/lib
+COPY share $SPACK_ROOT/share
+COPY var $SPACK_ROOT/var
+RUN mkdir -p $SPACK_ROOT/opt/spack
+
+MASK PUSH
+MASK [[ $DISTRO == arch ]]
+RUN pacman -Sy --noconfirm \
+ base-devel ca-certificates curl gcc \
+ gcc-fortran git gnupg2 iproute2 \
+ make openssh python python-pip \
+ sudo tcl \
+ && echo 'nobody ALL=(ALL) NOPASSWD: ALL' > \
+ /etc/sudoers.d/nobody-sudo \
+ && sudo -u nobody git clone --depth 1 \
+ https://aur.archlinux.org/lua-posix.git /tmp/lua-posix \
+ && sudo -u nobody git clone --depth 1 \
+ https://aur.archlinux.org/lmod.git /tmp/lmod \
+ && ( cd /tmp/lua-posix \
+ && sudo -u nobody makepkg -si --asdeps --noconfirm ) \
+ && ( cd /tmp/lmod \
+ && sudo -u nobody makepkg -si --noconfirm ) \
+ && rm -rf /tmp/lua-posix /tmp/lmod /etc/sudoers.d/nobody-sudo
+
+MASK [[ $DISTRO =~ (centos|rhel.*) ]]
+RUN yum update -y
+
+ MASK PUSH
+ MASK [[ $DISTRO =~ rhel.* ]]
+ RUN yum install -y yum-conf-repos.noarch \
+ && yum update -y
+ MASK POP
+
+RUN yum install -y epel-release \
+ && yum update -y \
+ && yum --enablerepo epel groupinstall -y "Development Tools" \
+ && yum --enablerepo epel install -y \
+ curl findutils gcc-c++ gcc \
+ gcc-gfortran git gnupg2 hostname \
+ iproute Lmod make patch \
+ openssh-server python python-pip tcl \
+ && rm -rf /var/cache/yum \
+ && yum clean all
+
+MASK [[ $DISTRO == fedora ]]
+RUN dnf update -y \
+ && dnf group install -y "C Development Tools and Libraries" \
+ && dnf install -y \
+ @development-tools \
+ curl findutils gcc-c++ gcc \
+ gcc-gfortran git gnupg2 hostname \
+ iproute Lmod make patch \
+ openssh-server python tcl \
+ && dnf clean all
+
+MASK [[ $DISTRO == opensuse ]]
+RUN zypper -n ref \
+ && zypper -n up --skip-interactive --no-recommends \
+ && zypper -n install -l --no-recommends --type pattern \
+ devel_basis devel_C_C++ \
+ && zypper -n install -l --no-recommends \
+ bash bash-completion ca-certificates curl \
+ findutils gcc gcc-locale gcc-c++ \
+ gcc-fortran git glibc-locale gpg2 \
+ hostname iproute lua-lmod make \
+ patch openssh python python-pip \
+ python-xml tcl \
+ && zypper clean \
+ && rm -rf /var/cache/zypp/*
+
+MASK [[ $DISTRO == ubuntu ]]
+RUN apt-get -yqq update \
+ && apt-get -yqq install \
+ build-essential ca-certificates curl g++ \
+ gcc gfortran git gnupg2 \
+ iproute2 lmod lua-posix make \
+ openssh-server python python-pip tcl
+
+ MASK PUSH
+ MASK [[ $DISTRO_VERSION == bionic ]]
+ # [WORKAROUND]
+ # https://bugs.launchpad.net/ubuntu/+source/lua-posix/+bug/1752082
+ RUN ln -s posix_c.so /usr/lib/x86_64-linux-gnu/lua/5.2/posix.so
+ MASK POP
+
+RUN rm -rf /var/lib/apt/lists/*
+
+MASK POP
+
+RUN rm -rf $SPACK_ROOT/.git \
+ && pip install boto3 \
+ && ( echo ". /usr/share/lmod/lmod/init/bash" \
+ && echo ". $SPACK_ROOT/share/spack/setup-env.sh" \
+ && echo ". $SPACK_ROOT/share/spack/spack-completion.bash" ) \
+ >> /etc/profile.d/spack.sh \
+ && ln -s $SPACK_ROOT/share/spack/docker/handle-ssh.sh \
+ /etc/profile.d/handle-ssh.sh \
+ && ln -s $SPACK_ROOT/share/spack/docker/handle-prompt.sh \
+ /etc/profile.d/handle-prompt.sh \
+ && mkdir -p /root/.spack \
+ && cp $SPACK_ROOT/share/spack/docker/modules.yaml \
+ /root/.spack/modules.yaml \
+ && rm -rf /root/*.*
+
+MASK PUSH
+MASK [[ $DISTRO_VERSION =~ (centos|fedora|opensuse|rhel.*) ]]
+RUN rm -f /run/nologin
+MASK POP
+
+WORKDIR /root
+ENTRYPOINT ["bash", "/spack/share/spack/docker/entrypoint.bash"]
+CMD ["docker-shell"]
+
diff --git a/share/spack/docker/build-image.sh b/share/spack/docker/build-image.sh
new file mode 100755
index 0000000000..fb12bdb833
--- /dev/null
+++ b/share/spack/docker/build-image.sh
@@ -0,0 +1,84 @@
+#! /usr/bin/env bash
+#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+script="$( basename "$0" )"
+cd "$( dirname "$0" )"
+
+if [ -z "$BASE_IMAGE" ] ; then
+ BASE_IMAGE="ubuntu"
+fi
+
+if [ -z "$BASE_TAG" ] ; then
+ BASE_TAG="latest"
+fi
+
+if [ -z "$DISTRO" ] ; then
+ DISTRO="${BASE_IMAGE}"
+fi
+
+if [ -z "$DISTRO_VERSION" ] ; then
+ DISTRO_VERSION="${BASE_TAG}"
+fi
+
+if [ -z "$BASE_NAME" ] ; then
+ BASE_NAME="${DISTRO}"
+fi
+
+if [ "$BASE_TAG" '=' 'latest' ] ; then
+ BASE_TAG=""
+fi
+
+if [ -n "$BASE_TAG" ] ; then
+ BASE_TAG=":${BASE_TAG}"
+fi
+
+TAG="spack/${BASE_NAME}${BASE_TAG}"
+
+export BASE_IMAGE BASE_TAG DISTRO DISTRO_VERSION BASE_NAME TAG
+
+if [ "$script" '=' 'run-image.sh' ] ; then
+ com="docker run --rm -ti"
+
+ if [ -z "$DISABLE_MOUNT" ] ; then
+ DISABLE_MOUNT=1
+ if [ -z "$*" ] ; then
+ DISABLE_MOUNT=0
+ fi
+ fi
+
+ if [ "$DISABLE_MOUNT" '==' 0 ] ; then
+ com="${com} -v \"$( readlink -f ../../.. ):/spack\""
+ fi
+
+ eval "exec ${com}" "${TAG}" "$@"
+elif [ "$script" '=' 'render-image-template.sh' ] ; then
+ ./dpp.bash Dockerfile
+elif [ "$script" '=' 'push-image.sh' ] ; then
+ docker push "${TAG}"
+ for tag in ${EXTRA_TAGS} ; do
+ docker push "spack/${BASE_NAME}:${tag}"
+ done
+else
+ tag_options="-t ${TAG}"
+ for tag in ${EXTRA_TAGS} ; do
+ tag_options="${tag_options} -t spack/${BASE_NAME}:${tag}"
+ done
+
+ cache_options=""
+ if docker pull "${TAG}" ; then
+ cache_options="--cache-from ${TAG}"
+ fi
+
+ exec ./render-image-template.sh |
+ docker build -f - \
+ ${cache_options} \
+ ${tag_options} \
+ --build-arg BASE="${BASE_IMAGE}${BASE_TAG}" \
+ --build-arg DISTRO="${DISTRO}" \
+ --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \
+ ../../..
+fi
diff --git a/share/spack/docker/config/arch.bash b/share/spack/docker/config/arch.bash
new file mode 100644
index 0000000000..3cb2951c4b
--- /dev/null
+++ b/share/spack/docker/config/arch.bash
@@ -0,0 +1,18 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset DISTRO_VERSION
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE="base/archlinux"
+export BASE_NAME="archlinux"
+export BASE_TAG="2018.10.01"
+export DISTRO="arch"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/centos.bash b/share/spack/docker/config/centos.bash
new file mode 100644
index 0000000000..bef7ad276b
--- /dev/null
+++ b/share/spack/docker/config/centos.bash
@@ -0,0 +1,16 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset DISTRO_VERSION
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=centos
+export BASE_TAG="7"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/fedora.bash b/share/spack/docker/config/fedora.bash
new file mode 100644
index 0000000000..fcf7425693
--- /dev/null
+++ b/share/spack/docker/config/fedora.bash
@@ -0,0 +1,16 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset DISTRO_VERSION
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=fedora
+export BASE_TAG="24"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/opensuse.bash b/share/spack/docker/config/opensuse.bash
new file mode 100644
index 0000000000..b0e11c17ac
--- /dev/null
+++ b/share/spack/docker/config/opensuse.bash
@@ -0,0 +1,16 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset DISTRO_VERSION
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=opensuse
+export BASE_TAG="tumbleweed"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/scilinux.bash b/share/spack/docker/config/scilinux.bash
new file mode 100644
index 0000000000..71fd737f69
--- /dev/null
+++ b/share/spack/docker/config/scilinux.bash
@@ -0,0 +1,17 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=sl
+export BASE_TAG="7"
+export BASE_NAME=scilinux
+export DISTRO=rhel7
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/ubuntu.bash b/share/spack/docker/config/ubuntu.bash
new file mode 100644
index 0000000000..588848fb40
--- /dev/null
+++ b/share/spack/docker/config/ubuntu.bash
@@ -0,0 +1,15 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=ubuntu
+export BASE_TAG="bionic"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/dpp.bash b/share/spack/docker/dpp.bash
new file mode 100755
index 0000000000..f41a9c5260
--- /dev/null
+++ b/share/spack/docker/dpp.bash
@@ -0,0 +1,77 @@
+#! /usr/bin/env bash
+#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+function prefix_tokens() {
+ line="$1" ; shift
+ nprefix="$1"
+
+ line="${line::$nprefix} "
+ echo "${line::$nprefix}"
+}
+
+
+# read file contents, or stdin
+cat "$1" |
+
+# remove blank lines
+grep -v '^ *$' |
+
+# remove leading whitespace
+sed 's/^ *//g' |
+
+# remove comments
+grep -v '^#.*' |
+
+# remove trailing whitespace
+sed 's/ *$//g' |
+
+# remove extraneous whitespace
+sed 's/ */ /g' |
+
+# mask out subsections
+(
+ stack_level=1
+ mask_level=1
+
+ while read LINE ; do
+ try_print=1
+
+ if [ "$( prefix_tokens "$LINE" 10 )" '=' 'MASK PUSH ' ] ; then
+ tmp="$stack_level"
+ stack_level="$(( stack_level + 1 ))"
+ if [ "$mask_level" '=' "$tmp" ] ; then
+ mask_level="$stack_level"
+ fi
+ try_print=0
+ elif [ "$( prefix_tokens "$LINE" 9 )" '=' 'MASK POP ' ] ; then
+ stack_level="$(( stack_level - 1 ))"
+ if [ "$mask_level" -gt "$stack_level" ] ; then
+ mask_level="$stack_level"
+ fi
+ try_print=0
+ elif [ "$( prefix_tokens "$LINE" 5 )" '=' 'MASK ' ] ; then
+ if [ "$(( mask_level + 1 ))" -ge "$stack_level" ] ; then
+ mask_level="$stack_level"
+ eval "${LINE:5}"
+ if [ "$?" '!=' 0 ] ; then
+ mask_level="$(( mask_level - 1 ))"
+ fi
+ fi
+ try_print=0
+ fi
+
+ if [ "$stack_level" -lt 1 ] ; then
+ stack_level=1
+ mask_level=0
+ fi
+
+ if [ "$try_print" '=' 1 -a "$mask_level" '=' "$stack_level" ] ; then
+ echo "$LINE"
+ fi
+ done
+)
+
diff --git a/share/spack/docker/entrypoint.bash b/share/spack/docker/entrypoint.bash
new file mode 100755
index 0000000000..58d6281084
--- /dev/null
+++ b/share/spack/docker/entrypoint.bash
@@ -0,0 +1,43 @@
+#! /usr/bin/env bash -e
+#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+if [ "$1" '=' 'docker-shell' ] ; then
+ if [ -t 0 ] ; then
+ exec bash -il
+ else
+ (
+ echo -n "It looks like you're trying to run an intractive shell"
+ echo -n " session, but either no psuedo-TTY is allocateed for this"
+ echo -n " container's STDIN, or it is closed."
+ echo
+
+ echo -n "Make sure you run docker with the --interactive and --tty"
+ echo -n " options."
+ echo
+ ) >&2
+
+ exit 1
+ fi
+else
+ exec 3>&1
+ exec 4>&2
+
+ exec 1>&-
+ exec 2>&-
+
+ source /etc/profile.d/spack.sh
+ source /etc/profile.d/handle-ssh.sh
+
+ exec 1>&3
+ exec 2>&4
+
+ exec 3>&-
+ exec 4>&-
+
+ spack "$@"
+ exit $?
+fi
diff --git a/share/spack/docker/handle-prompt.sh b/share/spack/docker/handle-prompt.sh
new file mode 100644
index 0000000000..d523ac3a31
--- /dev/null
+++ b/share/spack/docker/handle-prompt.sh
@@ -0,0 +1,169 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+if [ x$SPACK_PROMPT '!=' x0 ] ; then
+
+__tmp="`mktemp -d`"
+
+__trylock() {
+ local dir
+ dir="$__tmp/$1.lock"
+ mkdir "$dir" &>/dev/null
+ return $?
+}
+
+__queue_init() {
+ local r
+ local w
+
+ mkdir "$__tmp/$1.read.lock" ; r=$?
+ mkdir "$__tmp/$1.write.lock" ; w=$?
+
+ if [ "$r" '=' '0' -a "$w" '=' '0' ] ; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+__queue_try_read() {
+ __trylock "$1.read"
+ return $?
+}
+
+__queue_try_write() {
+ __trylock "$1.write"
+ return $?
+}
+
+__queue_make_readable() {
+ rm -r "$__tmp/$1.read.lock" &>/dev/null
+ return $?
+}
+
+__queue_make_writable() {
+ rm -r "$__tmp/$1.write.lock" &>/dev/null
+ return $?
+}
+
+__read() {
+ cat "$__tmp/$1" 2> /dev/null
+ return $?
+}
+
+__write() {
+ cat > "$__tmp/$1" 2> /dev/null
+ return $?
+}
+
+__revparse_head() {
+ head="`git -C /spack rev-parse $@ HEAD 2>/dev/null`"
+ result="$?"
+ if [ "$result" '!=' '0' ] ; then
+ head="`git --git-dir=/spack/.git \\
+ --work-tree=/spack rev-parse $@ HEAD 2>/dev/null`"
+ result="$?"
+ fi
+
+ echo "$head"
+ return $result
+}
+
+__git_head() {
+ head="`__revparse_head --abbrev-ref`"
+ if [ "$?" '=' '0' ] ; then
+ if [ "$head" '=' 'HEAD' ] ; then
+ head="`__revparse_head | cut -c1-8`..."
+ fi
+
+ echo "$head"
+ fi
+}
+
+__update_prompt() {
+ local prompt
+ prompt=''
+ linux_distro="$DOCKERFILE_DISTRO"
+ if [ -n "$linux_distro" ] ; then
+ linux_distro='\[\e[1;34m\][\[\e[0;34m\]'"$linux_distro"'\[\e[1;34m\]]'
+ if [ -n "$prompt" ] ; then
+ prompt="$prompt "
+ fi
+ prompt="$prompt$linux_distro"
+ fi
+
+ git_head="`__git_head`"
+
+ if [ -n "$git_head" ] ; then
+ git_head='\[\e[1;32m\](\[\e[0;32m\]'"$git_head"'\[\e[1;32m\])'
+ if [ -n "$prompt" ] ; then
+ prompt="$prompt "
+ fi
+ prompt="$prompt$git_head"
+ fi
+
+ if [ -n "$prompt" ] ; then
+ prompt="$prompt "
+ fi
+ prompt="$prompt"'\[\e[0;m\]\W: '
+ echo "$prompt" | __write prompt
+}
+
+set -m
+(
+ __queue_init query
+ __queue_init prompt
+
+ __update_prompt
+ __queue_make_readable prompt
+
+ __queue_make_writable query
+
+ while sleep 0.010 ; do
+ last_q_time=''
+
+ while sleep 0.010 ; do
+ q_time="`date +%s%N`"
+ if __queue_try_read query ; then
+ last_q_time="$q_time"
+ __queue_make_writable query
+ fi
+
+ if [ -n "$last_q_time" -a \
+ "$(( (q_time - last_q_time)/10000000 > 100 ))" '=' '1' ] ; then
+ break
+ fi
+ done
+
+ __update_prompt
+ __queue_make_readable prompt
+ done
+) &>/dev/null &
+set +m
+
+__update_prompt_main_first_call=1
+__update_prompt_main() {
+ if [ "$__update_prompt_main_first_call" '=' '1' ] ; then
+ while sleep 0.001 ; do
+ if __queue_try_read prompt ; then
+ PS1="`__read prompt`"
+ break
+ fi
+ done
+ __update_prompt_main_first_call=0
+ else
+ if __queue_try_read prompt ; then
+ PS1="`__read prompt`"
+ fi
+ fi
+
+ if __queue_try_write query ; then
+ __queue_make_readable query
+ fi
+}
+
+PROMPT_COMMAND=__update_prompt_main
+
+fi # [ x$SPACK_PROMPT '!=' x0 ]
diff --git a/share/spack/docker/handle-ssh.sh b/share/spack/docker/handle-ssh.sh
new file mode 100644
index 0000000000..f2139897cb
--- /dev/null
+++ b/share/spack/docker/handle-ssh.sh
@@ -0,0 +1,41 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+uid="`id -u`"
+if [ "$uid" '=' '0' ] ; then
+ for key_type in dsa ecdsa ed25519 rsa ; do
+ private_key_file="/etc/ssh/ssh_host_${key_type}_key"
+ public_key_file="$private_key_file.pub"
+
+ if [ '!' -f "$private_key_file" ] ; then
+ ssh-keygen \
+ -q -t "$key_type" -N "" -f "$private_key_file"
+ chmod 600 "$private_key_file"
+ chmod 644 "$public_key_file"
+ fi
+ done
+
+ mkdir -p /var/run/sshd
+
+ pgrep -u 0 -U 0 sshd &> /dev/null
+ if [ '!' "$?" '=' '0' ] ; then
+ nohup /usr/sbin/sshd -f /etc/ssh/sshd_config < /dev/null &> /dev/null
+ fi
+fi
+
+if [ '!' -f "$HOME/.ssh/id_rsa" ] ; then
+ ssh-keygen \
+ -t rsa -C "spack.developer@docker.host" -N "" -f "$HOME/.ssh/id_rsa"
+ cat "$HOME/.ssh/id_rsa.pub" >> "$HOME/.ssh/authorized_keys"
+ chmod 600 "$HOME/.ssh/authorized_keys"
+
+ docker_ip="`ip address show dev eth0 |
+ grep inet |
+ cut -d' ' -f 6 |
+ cut -d/ -f 1`"
+
+ ssh-keyscan -t rsa 127.0.0.1 localhost "$docker_ip" "`hostname`" \
+ > "$HOME/.ssh/known_hosts" 2> /dev/null
+fi
diff --git a/share/spack/docker/modules.yaml b/share/spack/docker/modules.yaml
new file mode 100644
index 0000000000..02907ecc40
--- /dev/null
+++ b/share/spack/docker/modules.yaml
@@ -0,0 +1,6 @@
+modules:
+ enable:
+ - lmod
+ lmod:
+ core_compilers:
+ - gcc
diff --git a/share/spack/docker/push-image.sh b/share/spack/docker/push-image.sh
new file mode 120000
index 0000000000..9e5dfdf52d
--- /dev/null
+++ b/share/spack/docker/push-image.sh
@@ -0,0 +1 @@
+./build-image.sh \ No newline at end of file
diff --git a/share/spack/docker/render-image-template.sh b/share/spack/docker/render-image-template.sh
new file mode 120000
index 0000000000..9e5dfdf52d
--- /dev/null
+++ b/share/spack/docker/render-image-template.sh
@@ -0,0 +1 @@
+./build-image.sh \ No newline at end of file
diff --git a/share/spack/docker/run-image.sh b/share/spack/docker/run-image.sh
new file mode 120000
index 0000000000..b3fd71be24
--- /dev/null
+++ b/share/spack/docker/run-image.sh
@@ -0,0 +1 @@
+build-image.sh \ No newline at end of file
diff --git a/share/spack/docs/docker/module-file-tutorial/Dockerfile b/share/spack/docs/docker/module-file-tutorial/Dockerfile
index a012492a98..8dfd51bf31 100644
--- a/share/spack/docs/docker/module-file-tutorial/Dockerfile
+++ b/share/spack/docs/docker/module-file-tutorial/Dockerfile
@@ -36,8 +36,7 @@ RUN spack install lmod && spack clean -a
# Build a compiler
RUN spack install gcc@7.2.0 && spack clean -a
RUN /bin/bash -l -c ' \
- spack load gcc@7.2.0 \
- && spack compiler add'
+ spack compiler add $(spack location -i gcc@7.2.0)/bin'
# Build the software on top of the compiler
RUN spack install netlib-scalapack ^openmpi ^openblas %gcc@7.2.0 \
diff --git a/share/spack/docs/docker/module-file-tutorial/spack.sh b/share/spack/docs/docker/module-file-tutorial/spack.sh
index 54d095c717..a59bc7575f 100644
--- a/share/spack/docs/docker/module-file-tutorial/spack.sh
+++ b/share/spack/docs/docker/module-file-tutorial/spack.sh
@@ -1,3 +1,8 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
source $SPACK_ROOT/share/spack/setup-env.sh
LMOD_DIR=$(spack location -i lmod)
diff --git a/share/spack/qa/run-build-tests b/share/spack/qa/run-build-tests
index b5d5aed28f..315c0b8e99 100755
--- a/share/spack/qa/run-build-tests
+++ b/share/spack/qa/run-build-tests
@@ -1,5 +1,11 @@
#!/bin/bash -e
#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+#
# Description:
# Runs Spack build smoke tests. This installs a few packages that
# cover different parts of the build system. It is not an exhaustive
@@ -11,6 +17,12 @@
. "$(dirname $0)/setup.sh"
check_dependencies ${coverage} git hg svn
+# Fetch the sources in a mirror, and add it to Spack
+mkdir -p ~/.mirror
+bin/spack mirror add travis ~/.mirror
+bin/spack mirror create -D -d ~/.mirror ${SPEC}
+
+
# Move to root directory of Spack
# Allows script to be run from anywhere
cd "$SPACK_ROOT"
@@ -25,5 +37,4 @@ fi
spack config get compilers
# Run some build smoke tests, potentially with code coverage
-${coverage_run} bin/spack install -v ${SPEC}
-${coverage_combine}
+${coverage_run} bin/spack install ${SPEC}
diff --git a/share/spack/qa/run-doc-tests b/share/spack/qa/run-doc-tests
index c43779fcaf..6129243676 100755
--- a/share/spack/qa/run-doc-tests
+++ b/share/spack/qa/run-doc-tests
@@ -1,5 +1,11 @@
#!/bin/bash -e
#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+#
# Description:
# Builds Spack documentation and checks for
# possible syntax errors. Treats warnings as
diff --git a/share/spack/qa/run-flake8-tests b/share/spack/qa/run-flake8-tests
index 29fc15f9d7..f98cdb919c 100755
--- a/share/spack/qa/run-flake8-tests
+++ b/share/spack/qa/run-flake8-tests
@@ -1,5 +1,11 @@
#!/bin/bash -e
#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+#
# Description:
# Runs source code style checks on Spack.
# See $SPACK_ROOT/.flake8 for a list of
@@ -11,4 +17,8 @@
. "$(dirname $0)/setup.sh"
check_dependencies flake8
+# verify that the code style is correct
spack flake8
+
+# verify that the license headers are present
+spack license verify
diff --git a/share/spack/qa/run-unit-tests b/share/spack/qa/run-unit-tests
index 87203ba915..7aae551f03 100755
--- a/share/spack/qa/run-unit-tests
+++ b/share/spack/qa/run-unit-tests
@@ -1,5 +1,11 @@
#!/bin/bash -e
#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+#
# Description:
# Runs Spack unit tests.
#
@@ -25,8 +31,11 @@ ${coverage_run} bin/spack -h
${coverage_run} bin/spack help -a
# Profile and print top 20 lines for a simple call to spack spec
-${coverage_run} bin/spack -p --lines 20 spec mpileaks
+${coverage_run} bin/spack -p --lines 20 spec mpileaks%gcc ^elfutils@0.170
# Run unit tests with code coverage
-${coverage_run} bin/spack test "$@"
-${coverage_combine}
+extra_args=""
+if [[ -n "$@" ]]; then
+ extra_args="-k $@"
+fi
+${coverage_run} bin/spack test --verbose "$extra_args"
diff --git a/share/spack/qa/setup.sh b/share/spack/qa/setup.sh
index 98c79a0457..4f40904433 100755
--- a/share/spack/qa/setup.sh
+++ b/share/spack/qa/setup.sh
@@ -1,5 +1,11 @@
#!/bin/bash -e
#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+#
# Description:
# Common setup code to be sourced by Spack's test scripts.
#
@@ -11,14 +17,12 @@ SPACK_ROOT="$QA_DIR/../../.."
. "$SPACK_ROOT/share/spack/setup-env.sh"
# Set up some variables for running coverage tests.
-if [[ "$COVERAGE" == true ]]; then
+if [[ "$TEST_SUITE" == "unit" || "$TEST_SUITE" == "build" ]]; then
coverage=coverage
coverage_run="coverage run"
- coverage_combine="coverage combine"
else
coverage=""
coverage_run=""
- coverage_combine=""
fi
#
diff --git a/share/spack/setup-env.csh b/share/spack/setup-env.csh
index 6fc728daa8..4e471b1121 100755
--- a/share/spack/setup-env.csh
+++ b/share/spack/setup-env.csh
@@ -1,27 +1,8 @@
-##############################################################################
-# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
-# Produced at the Lawrence Livermore National Laboratory.
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
-# This file is part of Spack.
-# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
-# LLNL-CODE-647188
-#
-# For details, see https://github.com/spack/spack
-# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License (as
-# published by the Free Software Foundation) version 2.1, February 1999.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
-# conditions of the GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##############################################################################
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
#
# This file is part of Spack and sets up the spack environment for
@@ -39,15 +20,14 @@ if ($?SPACK_ROOT) then
alias spack 'set _sp_args = (\!*); source $_spack_share_dir/csh/spack.csh'
alias _spack_pathadd 'set _pa_args = (\!*) && source $_spack_share_dir/csh/pathadd.csh'
- # Shamelessly stolen from setup-env.sh
- set _sp_sys_type = `$SPACK_ROOT/bin/spack python -c 'print(spack.architecture.sys_type())'`
- set _sp_dotkit_root = `$SPACK_ROOT/bin/spack python -c "print(spack.util.path.canonicalize_path(spack.config.get_config('config').get('module_roots').get('dotkit')))"`
- set _sp_tcl_root = `$SPACK_ROOT/bin/spack python -c "print(spack.util.path.canonicalize_path(spack.config.get_config('config').get('module_roots').get('tcl')))"`
+ # Set variables needed by this script
+ _spack_pathadd PATH "$SPACK_ROOT/bin"
+ eval `spack --print-shell-vars csh`
# Set up modules and dotkit search paths in the user environment
_spack_pathadd DK_NODE "$_sp_dotkit_root/$_sp_sys_type"
_spack_pathadd MODULEPATH "$_sp_tcl_root/$_sp_sys_type"
- _spack_pathadd PATH "$SPACK_ROOT/bin"
else
- echo "ERROR: Sourcing spack setup-env.csh requires setting SPACK_ROOT to the root of your spack installation"
+ echo "ERROR: Sourcing spack setup-env.csh requires setting SPACK_ROOT to "
+ echo " the root of your spack installation."
endif
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 21a7e00345..79688455bf 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -1,27 +1,8 @@
-##############################################################################
-# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
-# Produced at the Lawrence Livermore National Laboratory.
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
-# This file is part of Spack.
-# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
-# LLNL-CODE-647188
-#
-# For details, see https://github.com/spack/spack
-# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License (as
-# published by the Free Software Foundation) version 2.1, February 1999.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
-# conditions of the GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##############################################################################
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
########################################################################
#
@@ -80,14 +61,22 @@ function spack {
return
fi
- _sp_subcommand=$1; shift
- _sp_spec="$@"
+ _sp_subcommand=""
+ if [ -n "$1" ]; then
+ _sp_subcommand="$1"
+ shift
+ fi
+ _sp_spec=("$@")
# Filter out use and unuse. For any other commands, just run the
# command.
case $_sp_subcommand in
"cd")
- _sp_arg="$1"; shift
+ _sp_arg=""
+ if [ -n "$1" ]; then
+ _sp_arg="$1"
+ shift
+ fi
if [ "$_sp_arg" = "-h" ]; then
command spack cd -h
else
@@ -100,6 +89,43 @@ function spack {
fi
return
;;
+ "env")
+ _sp_arg=""
+ if [ -n "$1" ]; then
+ _sp_arg="$1"
+ shift
+ fi
+
+ if [ "$_sp_arg" = "-h" ]; then
+ command spack env -h
+ else
+ case $_sp_arg in
+ activate)
+ _a="$@"
+ if [ -z "$1" -o "${_a#*--sh}" != "$_a" -o "${_a#*--csh}" != "$_a" -o "${_a#*-h}" != "$_a" ]; then
+ # no args or args contain -h/--help, --sh, or --csh: just execute
+ command spack "${args[@]}"
+ else
+ # actual call to activate: source the output
+ eval $(command spack $_sp_flags env activate --sh "$@")
+ fi
+ ;;
+ deactivate)
+ if [ -n "$1" ]; then
+ # with args: execute the command
+ command spack "${args[@]}"
+ else
+ # no args: source the output.
+ eval $(command spack $_sp_flags env deactivate --sh)
+ fi
+ ;;
+ *)
+ command spack "${args[@]}"
+ ;;
+ esac
+ fi
+ return
+ ;;
"use"|"unuse"|"load"|"unload")
# Shift any other args for use off before parsing spec.
_sp_subcommand_args=""
@@ -113,7 +139,7 @@ function spack {
shift
done
- _sp_spec="$@"
+ _sp_spec=("$@")
# Here the user has run use or unuse with a spec. Find a matching
# spec using 'spack module find', then use the appropriate module
@@ -121,20 +147,28 @@ function spack {
# If spack module command comes back with an error, do nothing.
case $_sp_subcommand in
"use")
- if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type dotkit $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module dotkit find $_sp_subcommand_args "${_sp_spec[@]}"); then
use $_sp_module_args $_sp_full_spec
+ else
+ $(exit 1)
fi ;;
"unuse")
- if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type dotkit $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module dotkit find $_sp_subcommand_args "${_sp_spec[@]}"); then
unuse $_sp_module_args $_sp_full_spec
+ else
+ $(exit 1)
fi ;;
"load")
- if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type tcl $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module tcl find $_sp_subcommand_args "${_sp_spec[@]}"); then
module load $_sp_module_args $_sp_full_spec
+ else
+ $(exit 1)
fi ;;
"unload")
- if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type tcl $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module tcl find $_sp_subcommand_args "${_sp_spec[@]}"); then
module unload $_sp_module_args $_sp_full_spec
+ else
+ $(exit 1)
fi ;;
esac
;;
@@ -202,7 +236,7 @@ export SPACK_ROOT=${_sp_prefix}
# Determine which shell is being used
#
function _spack_determine_shell() {
- ps -p $$ | tail -n 1 | awk '{print $4}' | sed 's/^-//' | xargs basename
+ PS_FORMAT= ps -p $$ | tail -n 1 | awk '{print $4}' | sed 's/^-//' | xargs basename
}
export SPACK_SHELL=$(_spack_determine_shell)
@@ -218,27 +252,27 @@ if ! _spack_fn_exists use && ! _spack_fn_exists module; then
need_module="yes"
fi;
+
#
-# build and make available environment-modules
+# make available environment-modules
#
if [ "${need_module}" = "yes" ]; then
- #check if environment-modules is installed
- module_prefix="$(spack location -i "environment-modules" 2>&1 || echo "not_installed")"
- module_prefix=$(echo "${module_prefix}" | tail -n 1)
- if [ "${module_prefix}" != "not_installed" ]; then
+ eval `spack --print-shell-vars sh,modules`
+
+ # _sp_module_prefix is set by spack --print-sh-vars
+ if [ "${_sp_module_prefix}" != "not_installed" ]; then
#activate it!
- export MODULE_PREFIX=${module_prefix}
+ export MODULE_PREFIX=${_sp_module_prefix}
_spack_pathadd PATH "${MODULE_PREFIX}/Modules/bin"
module() { eval `${MODULE_PREFIX}/Modules/bin/modulecmd ${SPACK_SHELL} $*`; }
fi;
+else
+ eval `spack --print-shell-vars sh`
fi;
#
-# Set up modules and dotkit search paths in the user environment
+# set module system roots
#
-_sp_sys_type=$(spack-python -c 'print(spack.architecture.sys_type())')
-_sp_dotkit_root=$(spack-python -c "print(spack.util.path.canonicalize_path(spack.config.get_config('config').get('module_roots', {}).get('dotkit')))")
-_sp_tcl_root=$(spack-python -c "print(spack.util.path.canonicalize_path(spack.config.get_config('config').get('module_roots', {}).get('tcl')))")
_spack_pathadd DK_NODE "${_sp_dotkit_root%/}/$_sp_sys_type"
_spack_pathadd MODULEPATH "${_sp_tcl_root%/}/$_sp_sys_type"
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index 56cbfef792..c157d836a4 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -1,27 +1,8 @@
-##############################################################################
-# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
-# Produced at the Lawrence Livermore National Laboratory.
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
-# This file is part of Spack.
-# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
-# LLNL-CODE-647188
-#
-# For details, see https://github.com/spack/spack
-# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License (as
-# published by the Free Software Foundation) version 2.1, February 1999.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
-# conditions of the GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##############################################################################
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
# The following global variables are used/set by Bash programmable completion
# COMP_CWORD: An index into ${COMP_WORDS} of the word containing the
@@ -114,9 +95,9 @@ function _bash_completion_spack {
function _spack {
if $list_options
then
- compgen -W "-h --help -d --debug -D --pdb -k --insecure -m --mock -p
- --profile -v --verbose -s --stacktrace -V --version
- --color --color=always --color=auto --color=never" -- "$cur"
+ compgen -W "-h --help --color -d --debug -D --pdb -k --insecure
+ -m --mock -p --profile -P --sorted-profile --lines
+ -v --verbose -s --stacktrace -V --version" -- "$cur"
else
compgen -W "$(_subcommands)" -- "$cur"
fi
@@ -125,24 +106,31 @@ function _spack {
function _spack_activate {
if $list_options
then
- compgen -W "-h --help -f --force" -- "$cur"
+ compgen -W "-h --help -f --force -v --view" -- "$cur"
else
compgen -W "$(_installed_packages)" -- "$cur"
fi
}
function _spack_arch {
- compgen -W "-h --help -p --platform" -- "$cur"
+ compgen -W "-h --help -p --platform -o --operating-system
+ -t --target" -- "$cur"
}
-function _spack_bootstrap {
- # FIXME: What does this command even do?
+function _spack_blame {
if $list_options
then
- compgen -W "-h --help -r --remote" -- "$cur"
+ compgen -W "-h --help -t --time -p --percent -g --git" -- "$cur"
+ else
+ compgen -W "$(_all_packages)" -- "$cur"
fi
}
+function _spack_bootstrap {
+ compgen -W "-h --help -j --jobs --keep-prefix --keep-stage -n --no-checksum
+ -v --verbose --clean --dirty --run-tests" -- "$cur"
+}
+
function _spack_build {
if $list_options
then
@@ -164,8 +152,8 @@ function _spack_buildcache {
function _spack_buildcache_create {
if $list_options
then
- compgen -W "-h --help -r --rel -f --force -y --yes-to-all -k --key
- -d --directory" -- "$cur"
+ compgen -W "-h --help -r --rel -f --force -u --unsigned -a --allow-root
+ -k --key -d --directory" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
@@ -174,23 +162,21 @@ function _spack_buildcache_create {
function _spack_buildcache_install {
if $list_options
then
- compgen -W "-h --help -f --force -y --yes-to-all" -- "$cur"
+ compgen -W "-h --help -f --force -m --multiple -a --allow-root -u
+ --unsigned" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
}
function _spack_buildcache_keys {
- if $list_options
- then
- compgen -W "-h --help -i --install -y --yes-to-all" -- "$cur"
- fi
+ compgen -W "-h --help -i --install -t --trust -f --force" -- "$cur"
}
function _spack_buildcache_list {
if $list_options
then
- compgen -W "-h --help" -- "$cur"
+ compgen -W "-h --help -f --force" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
@@ -220,12 +206,26 @@ function _spack_clean {
if $list_options
then
compgen -W "-h --help -s --stage -d --downloads
- -m --misc-cache -a --all" -- "$cur"
+ -m --misc-cache -a --all" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
}
+function _spack_clone {
+ if $list_options
+ then
+ compgen -W "-h --help -r --remote" -- "$cur"
+ fi
+}
+
+function _spack_commands {
+ if $list_options
+ then
+ compgen -W "-h --help --format" -- "$cur"
+ fi
+}
+
function _spack_compiler {
if $list_options
then
@@ -315,14 +315,17 @@ function _spack_configure {
}
function _spack_create {
- compgen -W "-h --help --keep-stage -n --name -t --template -r --repo
- -N --namespace -f --force" -- "$cur"
+ if $list_options
+ then
+ compgen -W "-h --help --keep-stage -n --name -t --template -r --repo
+ -N --namespace -f --force" -- "$cur"
+ fi
}
function _spack_deactivate {
if $list_options
then
- compgen -W "-h --help -f --force -a --all" -- "$cur"
+ compgen -W "-h --help -f --force -v --view -a --all" -- "$cur"
else
compgen -W "$(_installed_packages)" -- "$cur"
fi
@@ -341,10 +344,20 @@ function _spack_debug_create_db_tarball {
compgen -W "-h --help" -- "$cur"
}
+function _spack_dependencies {
+ if $list_options
+ then
+ compgen -W "-h --help -i --installed -t --transitive -V
+ --no-expand-virtuals" -- "$cur"
+ else
+ compgen -W "$(_all_packages)" -- "$cur"
+ fi
+}
+
function _spack_dependents {
if $list_options
then
- compgen -W "-h --help" -- "$cur"
+ compgen -W "-h --help -i --installed -t --transitive" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
@@ -360,16 +373,15 @@ function _spack_diy {
fi
}
-function _spack_doc {
- # FIXME: What does this command even do?
+function _spack_docs {
compgen -W "-h --help" -- "$cur"
}
function _spack_edit {
if $list_options
then
- compgen -W "-h --help -b --build-system -c --command -t --test -m --module
- -r --repo -N --namespace" -- "$cur"
+ compgen -W "-h --help -b --build-system -c --command -d --docs -t
+ --test -m --module -r --repo -N --namespace" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
@@ -378,7 +390,7 @@ function _spack_edit {
function _spack_env {
if $list_options
then
- compgen -W "-h --help" -- "$cur"
+ compgen -W "-h --help --clean --dirty" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
@@ -387,9 +399,11 @@ function _spack_env {
function _spack_extensions {
if $list_options
then
- compgen -W "-h --help -l --long -p --paths -d --deps" -- "$cur"
+ compgen -W "-h --help -l --long -p --paths -d --deps
+ -s --show -v --view" -- "$cur"
else
- compgen -W "go-bootstrap go lua octave python r ruby rust" -- "$cur"
+ compgen -W "aspell go-bootstrap go lua matlab octave perl python r ruby
+ rust tcl yorick" -- "$cur"
fi
}
@@ -406,10 +420,11 @@ function _spack_fetch {
function _spack_find {
if $list_options
then
- compgen -W "-h --help -s --short -p --paths -d --deps -l --long
- -L --very-long -f --show-flags --show-full-compiler
+ compgen -W "-h --help -s --short -p --paths -d --deps -l --long -L
+ --very-long -t --tags -f --show-flags --show-full-compiler
-e --explicit -E --implicit -u --unknown -m --missing
- -v --variants -M --only-missing -N --namespace" -- "$cur"
+ -v --variants -M --only-missing -N --namespace --start-date
+ --end-date" -- "$cur"
else
compgen -W "$(_installed_packages)" -- "$cur"
fi
@@ -418,11 +433,74 @@ function _spack_find {
function _spack_flake8 {
if $list_options
then
- compgen -W "-h --help -k --keep-temp -o --output
+ compgen -W "-h --help -b --base -k --keep-temp -a --all -o --output
-r --root-relative -U --no-untracked" -- "$cur"
fi
}
+function _spack_gpg {
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ else
+ compgen -W "create export init list sign trust untrust verify" -- "$cur"
+ fi
+}
+
+function _spack_gpg_create {
+ if $list_options
+ then
+ compgen -W "-h --help --comment --expires --export" -- "$cur"
+ fi
+}
+
+function _spack_gpg_export {
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ fi
+}
+
+function _spack_gpg_init {
+ compgen -W "-h --help" -- "$cur"
+}
+
+function _spack_gpg_list {
+ compgen -W "-h --help --trusted --signing" -- "$cur"
+}
+
+function _spack_gpg_sign {
+ if $list_options
+ then
+ compgen -W "-h --help --output --key --clearsign" -- "$cur"
+ else
+ compgen -W "$(installed_packages)" -- "$cur"
+ fi
+}
+
+function _spack_gpg_trust {
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ fi
+}
+
+function _spack_gpg_untrust {
+ if $list_options
+ then
+ compgen -W "-h --help --signing" -- "$cur"
+ fi
+}
+
+function _spack_gpg_verify {
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ else
+ compgen -W "$(installed_packages)" -- "$cur"
+ fi
+}
+
function _spack_graph {
if $list_options
then
@@ -436,7 +514,7 @@ function _spack_graph {
function _spack_help {
if $list_options
then
- compgen -W "-h --help" -- "$cur"
+ compgen -W "-h --help -a --all --spec" -- "$cur"
else
compgen -W "$(_subcommands)" -- "$cur"
fi
@@ -454,9 +532,11 @@ function _spack_info {
function _spack_install {
if $list_options
then
- compgen -W "-h --help --only -j --jobs --keep-prefix --keep-stage
- -n --no-checksum -v --verbose --fake --clean --dirty
- --run-tests --log-format --log-file --source" -- "$cur"
+ compgen -W "-h --help --only -j --jobs --overwrite --keep-prefix
+ --keep-stage --dont-restage --use-cache --show-log-on-error
+ --source -n --no-checksum -v --verbose --fake -f --file
+ --clean --dirty --test --log-format --log-file
+ -y --yes-to-all" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
@@ -465,7 +545,8 @@ function _spack_install {
function _spack_list {
if $list_options
then
- compgen -W "-h --help -d --search-description --format" -- "$cur"
+ compgen -W "-h --help -d --search-description --format
+ -t --tags" -- "$cur"
else
compgen -W "$(_all_packages)" -- "$cur"
fi
@@ -491,10 +572,11 @@ function _spack_location {
fi
}
-function _spack_md5 {
+function _spack_log_parse {
if $list_options
then
- compgen -W "-h --help" -- "$cur"
+ compgen -W "-h --help --show -c --context -p --profile -w --width
+ -j --jobs" -- "$cur"
fi
}
@@ -537,49 +619,168 @@ function _spack_mirror_remove {
fi
}
+function _spack_mirror_rm {
+ # Alias to `spack mirror remove`
+ _spack_mirror_remove
+}
+
function _spack_module {
if $list_options
then
compgen -W "-h --help" -- "$cur"
else
- compgen -W "find loads refresh rm" -- "$cur"
+ compgen -W "lmod tcl dotkit" -- "$cur"
fi
}
-function _spack_module_find {
+function _spack_module_tcl {
if $list_options
then
- compgen -W "-h --help -m --module-type" -- "$cur"
+ compgen -W "-h --help" -- "$cur"
+ else
+ compgen -W "refresh find rm loads" -- "$cur"
+ fi
+}
+
+
+function _spack_module_tcl_find {
+ if $list_options
+ then
+ compgen -W "-h --help --full-path -r --dependencies" -- "$cur"
else
compgen -W "$(_installed_packages)" -- "$cur"
fi
}
-function _spack_module_loads {
+function _spack_module_tcl_loads {
if $list_options
then
compgen -W "-h --help --input-only -p --prefix -x --exclude
- -m --module-type -r --dependencies" -- "$cur"
+ -r --dependencies" -- "$cur"
else
compgen -W "$(_installed_packages)" -- "$cur"
fi
}
-function _spack_module_refresh {
+function _spack_module_tcl_refresh {
if $list_options
then
- compgen -W "-h --help --delete-tree -m --module-type
- -y --yes-to-all" -- "$cur"
+ compgen -W "-h --help --delete-tree -y --yes-to-all" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+}
+
+function _spack_module_tcl_rm {
+ if $list_options
+ then
+ compgen -W "-h --help -y --yes-to-all" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+}
+
+function _spack_module_dotkit {
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ else
+ compgen -W "refresh find rm loads" -- "$cur"
+ fi
+}
+
+
+function _spack_module_dotkit_find {
+ if $list_options
+ then
+ compgen -W "-h --help --full-path -r --dependencies" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+}
+
+function _spack_module_dotkit_loads {
+ if $list_options
+ then
+ compgen -W "-h --help --input-only -p --prefix -x --exclude
+ -r --dependencies" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+
+}
+
+function _spack_module_dotkit_refresh {
+ if $list_options
+ then
+ compgen -W "-h --help --delete-tree -y --yes-to-all" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+}
+
+function _spack_module_dotkit_rm {
+ if $list_options
+ then
+ compgen -W "-h --help -y --yes-to-all" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+}
+
+function _spack_module_lmod {
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ else
+ compgen -W "refresh find rm loads setdefault" -- "$cur"
+ fi
+}
+
+
+function _spack_module_lmod_find {
+ if $list_options
+ then
+ compgen -W "-h --help --full-path -r --dependencies" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+}
+
+function _spack_module_lmod_loads {
+ if $list_options
+ then
+ compgen -W "-h --help --input-only -p --prefix -x --exclude
+ -r --dependencies" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+
+}
+
+function _spack_module_lmod_refresh {
+ if $list_options
+ then
+ compgen -W "-h --help --delete-tree -y --yes-to-all" -- "$cur"
+ else
+ compgen -W "$(_installed_packages)" -- "$cur"
+ fi
+}
+
+function _spack_module_lmod_rm {
+ if $list_options
+ then
+ compgen -W "-h --help -y --yes-to-all" -- "$cur"
else
compgen -W "$(_installed_packages)" -- "$cur"
fi
}
-function _spack_module_rm {
+function _spack_module_lmod_setdefault {
if $list_options
then
- compgen -W "-h --help -m --module-type -y --yes-to-all" -- "$cur"
+ compgen -W "-h --help" -- "$cur"
else
compgen -W "$(_installed_packages)" -- "$cur"
fi
@@ -595,7 +796,6 @@ function _spack_patch {
}
function _spack_pkg {
- # FIXME: What does this subcommand even do?
if $list_options
then
compgen -W "-h --help" -- "$cur"
@@ -615,22 +815,34 @@ function _spack_pkg_add {
function _spack_pkg_added {
# FIXME: How to list git revisions?
- compgen -W "-h --help" -- "$cur"
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ fi
}
function _spack_pkg_diff {
# FIXME: How to list git revisions?
- compgen -W "-h --help" -- "$cur"
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ fi
}
function _spack_pkg_list {
# FIXME: How to list git revisions?
- compgen -W "-h --help" -- "$cur"
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ fi
}
function _spack_pkg_removed {
# FIXME: How to list git revisions?
- compgen -W "-h --help" -- "$cur"
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
+ fi
}
function _spack_providers {
@@ -638,8 +850,14 @@ function _spack_providers {
then
compgen -W "-h --help" -- "$cur"
else
- compgen -W "awk blas daal elf golang ipp lapack mkl
- mpe mpi opencl openfoam pil scalapack" -- "$cur"
+ compgen -W "$(_providers)" -- "$cur"
+ fi
+}
+
+function _spack_pydoc {
+ if $list_options
+ then
+ compgen -W "-h --help" -- "$cur"
fi
}
@@ -787,7 +1005,10 @@ function _spack_url_list {
}
function _spack_url_parse {
- compgen -W "-h --help -s --spider" -- "$cur"
+ if $list_options
+ then
+ compgen -W "-h --help -s --spider" -- "$cur"
+ fi
}
function _spack_url_summary {
@@ -841,14 +1062,14 @@ function _spack_view_hard {
function _spack_view_hardlink {
if $list_options
then
- compgen -W "-h --help" -- "$cur"
+ compgen -W "-h --help -i --ignore-conflicts" -- "$cur"
fi
}
function _spack_view_remove {
if $list_options
then
- compgen -W "-h --help" -- "$cur"
+ compgen -W "-h --help --no-remove-dependents -a --all" -- "$cur"
fi
}
@@ -877,14 +1098,14 @@ function _spack_view_status {
function _spack_view_symlink {
if $list_options
then
- compgen -W "-h --help" -- "$cur"
+ compgen -W "-h --help --ignore-conflicts" -- "$cur"
fi
}
# Helper functions for subcommands
function _subcommands {
- spack help --all | grep "^ [a-z]" | awk '{print $1}' | grep -v spack
+ spack commands
}
function _all_packages {
@@ -892,14 +1113,17 @@ function _all_packages {
}
function _installed_packages {
- # Perl one-liner used to strip out color codes
- spack find | grep -v "^--" | perl -pe 's/\e\[?.*?[\@-~]//g'
+ spack --color=never find | grep -v "^--"
}
function _installed_compilers {
spack compilers | egrep -v "^(-|=)"
}
+function _providers {
+ spack providers
+}
+
function _mirrors {
spack mirror list | awk '{print $1}'
}
diff --git a/share/spack/templates/modules/modulefile.dk b/share/spack/templates/modules/modulefile.dk
new file mode 100644
index 0000000000..c3f6d2dce1
--- /dev/null
+++ b/share/spack/templates/modules/modulefile.dk
@@ -0,0 +1,31 @@
+{% block header %}
+{% if category %}
+#c {{ category }}
+{% endif %}
+{% if short_description %}
+#d {{ short_description }}
+{% endif %}
+{% if long_description %}
+{{ long_description| textwrap(72)| prepend_to_line('#h ')| join() }}
+{% endif %}
+{% endblock %}
+
+{% block autoloads %}
+{% for module in autoload %}
+dk_op {{ module }}
+{% endfor %}
+{% endblock %}
+
+{% block environment %}
+{% for command_name, cmd in environment_modifications %}
+{% if command_name == 'PrependPath' %}
+dk_alter {{ cmd.name }} {{ cmd.value }}
+{% endif %}
+{% if command_name == 'RemovePath' %}
+dk_unalter {{ cmd.name }} {{ cmd.value }}
+{% endif %}
+{% if command_name == 'SetEnv' %}
+dk_setenv {{ cmd.name }} {{ cmd.value }}
+{% endif %}
+{% endfor %}
+{% endblock %}
diff --git a/share/spack/templates/modules/modulefile.lua b/share/spack/templates/modules/modulefile.lua
new file mode 100644
index 0000000000..a8eae9bef1
--- /dev/null
+++ b/share/spack/templates/modules/modulefile.lua
@@ -0,0 +1,91 @@
+-- -*- lua -*-
+-- Module file created by spack (https://github.com/spack/spack) on {{ timestamp }}
+--
+-- {{ spec.short_spec }}
+--
+
+{% block header %}
+{% if short_description %}
+whatis([[Name : {{ spec.name }}]])
+whatis([[Version : {{ spec.version }}]])
+whatis([[Short description : {{ short_description }}]])
+{% endif %}
+{% if configure_options %}
+whatis([[Configure options : {{ configure_options }}]])
+{% endif %}
+
+{% if long_description %}
+help([[{{ long_description| textwrap(72)| join() }}]])
+{% endif %}
+{% endblock %}
+
+{% block provides %}
+{# Prepend the path I unlock as a provider of #}
+{# services and set the families of services I provide #}
+{% if has_modulepath_modifications %}
+-- Services provided by the package
+{% for name in provides %}
+family("{{ name }}")
+{% endfor %}
+
+-- Loading this module unlocks the path below unconditionally
+{% for path in unlocked_paths %}
+prepend_path("MODULEPATH", "{{ path }}")
+{% endfor %}
+
+{# Try to see if missing providers have already #}
+{# been loaded into the environment #}
+{% if has_conditional_modifications %}
+-- Try to load variables into path to see if providers are there
+{% for name in missing %}
+local {{ name }}_name = os.getenv("LMOD_{{ name|upper() }}_NAME")
+local {{ name }}_version = os.getenv("LMOD_{{ name|upper() }}_VERSION")
+{% endfor %}
+
+-- Change MODULEPATH based on the result of the tests above
+{% for condition, path in conditionally_unlocked_paths %}
+if {{ condition }} then
+ local t = pathJoin({{ path }})
+ prepend_path("MODULEPATH", t)
+end
+{% endfor %}
+
+-- Set variables to notify the provider of the new services
+{% for name in provides %}
+setenv("LMOD_{{ name|upper() }}_NAME", "{{ name_part }}")
+setenv("LMOD_{{ name|upper() }}_VERSION", "{{ version_part }}")
+{% endfor %}
+{% endif %}
+{% endif %}
+{% endblock %}
+
+{% block autoloads %}
+{% for module in autoload %}
+if not isloaded("{{ module }}") then
+{% if verbose %}
+ LmodMessage("Autoloading {{ module }}")
+{% endif %}
+ load("{{ module }}")
+end
+{% endfor %}
+{% endblock %}
+
+{% block environment %}
+{% for command_name, cmd in environment_modifications %}
+{% if command_name == 'PrependPath' %}
+prepend_path("{{ cmd.name }}", "{{ cmd.value }}", "{{ cmd.separator }}")
+{% elif command_name == 'AppendPath' %}
+append_path("{{ cmd.name }}", "{{ cmd.value }}", "{{ cmd.separator }}")
+{% elif command_name == 'RemovePath' %}
+remove_path("{{ cmd.name }}", "{{ cmd.value }}", "{{ cmd.separator }}")
+{% elif command_name == 'SetEnv' %}
+setenv("{{ cmd.name }}", "{{ cmd.value }}")
+{% elif command_name == 'UnsetEnv' %}
+unsetenv("{{ cmd.name }}")
+{% endif %}
+{% endfor %}
+{% endblock %}
+
+{% block footer %}
+{# In case the module needs to be extended with custom LUA code #}
+{% endblock %}
diff --git a/share/spack/templates/modules/modulefile.tcl b/share/spack/templates/modules/modulefile.tcl
new file mode 100644
index 0000000000..87edc10a64
--- /dev/null
+++ b/share/spack/templates/modules/modulefile.tcl
@@ -0,0 +1,82 @@
+#%Module1.0
+## Module file created by spack (https://github.com/spack/spack) on {{ timestamp }}
+##
+## {{ spec.short_spec }}
+##
+{% if configure_options %}
+## Configure options: {{ configure_options }}
+##
+{% endif %}
+
+
+{% block header %}
+{% if short_description %}
+module-whatis "{{ short_description }}"
+{% endif %}
+
+{% if long_description %}
+proc ModulesHelp { } {
+{{ long_description| textwrap(72)| quote()| prepend_to_line('puts stderr ')| join() }}
+}
+{% endif %}
+{% endblock %}
+
+{% block autoloads %}
+{% for module in autoload %}
+if {{ '{' }} [ module-info mode load ] && ![ is-loaded {{ module }} ] {{ '}' }} {{ '{' }}
+{% if verbose %}
+ puts stderr "Autoloading {{ module }}"
+{% endif %}
+ module load {{ module }}
+{{ '}' }}
+{% endfor %}
+{% endblock %}
+{# #}
+{% block prerequisite %}
+{% for module in prerequisites %}
+prereq {{ module }}
+{% endfor %}
+{% endblock %}
+{# #}
+{% block conflict %}
+{% for name in conflicts %}
+conflict {{ name }}
+{% endfor %}
+{% endblock %}
+
+{% block environment %}
+{% for command_name, cmd in environment_modifications %}
+{% if cmd.separator != ':' %}
+{# A non-standard separator is required #}
+{% if command_name == 'PrependPath' %}
+prepend-path --delim "{{ cmd.separator }}" {{ cmd.name }} "{{ cmd.value }}"
+{% elif command_name == 'AppendPath' %}
+append-path --delim "{{ cmd.separator }}" {{ cmd.name }} "{{ cmd.value }}"
+{% elif command_name == 'RemovePath' %}
+remove-path --delim "{{ cmd.separator }}" {{ cmd.name }} "{{ cmd.value }}"
+{% elif command_name == 'SetEnv' %}
+setenv --delim "{{ cmd.separator }}" {{ cmd.name }} "{{ cmd.value }}"
+{% elif command_name == 'UnsetEnv' %}
+unsetenv {{ cmd.name }}
+{% endif %}
+{% else %}
+{# We are using the usual separator #}
+{% if command_name == 'PrependPath' %}
+prepend-path {{ cmd.name }} "{{ cmd.value }}"
+{% elif command_name == 'AppendPath' %}
+append-path {{ cmd.name }} "{{ cmd.value }}"
+{% elif command_name == 'RemovePath' %}
+remove-path {{ cmd.name }} "{{ cmd.value }}"
+{% elif command_name == 'SetEnv' %}
+setenv {{ cmd.name }} "{{ cmd.value }}"
+{% elif command_name == 'UnsetEnv' %}
+unsetenv {{ cmd.name }}
+{% endif %}
+{# #}
+{% endif %}
+{% endfor %}
+{% endblock %}
+
+{% block footer %}
+{# In case he module needs to be extended with custom TCL code #}
+{% endblock %}
diff --git a/share/spack/templates/reports/cdash/Build.xml b/share/spack/templates/reports/cdash/Build.xml
new file mode 100644
index 0000000000..1d184349b3
--- /dev/null
+++ b/share/spack/templates/reports/cdash/Build.xml
@@ -0,0 +1,27 @@
+ <Build>
+ <StartBuildTime>{{ build.starttime }}</StartBuildTime>
+ <BuildCommand>{{ install_command }}</BuildCommand>
+{% for warning in build.warnings %}
+ <Warning>
+ <BuildLogLine>{{ warning.line_no }}</BuildLogLine>
+ <Text>{{ warning.text }}</Text>
+ <SourceFile>{{ warning.source_file }}</SourceFile>
+ <SourceLineNumber>{{ warning.source_line_no }}</SourceLineNumber>
+ <PreContext>{{ warning.pre_context }}</PreContext>
+ <PostContext>{{ warning.post_context }}</PostContext>
+ </Warning>
+{% endfor %}
+{% for error in build.errors %}
+ <Error>
+ <BuildLogLine>{{ error.line_no }}</BuildLogLine>
+ <Text>{{ error.text }}</Text>
+ <SourceFile>{{ error.source_file }}</SourceFile>
+ <SourceLineNumber>{{ error.source_line_no }}</SourceLineNumber>
+ <PreContext>{{ error.pre_context }}</PreContext>
+ <PostContext>{{ error.post_context }}</PostContext>
+ </Error>
+{% endfor %}
+ <EndBuildTime>{{ build.endtime }}</EndBuildTime>
+ <ElapsedMinutes>0</ElapsedMinutes>
+ </Build>
+</Site>
diff --git a/share/spack/templates/reports/cdash/Configure.xml b/share/spack/templates/reports/cdash/Configure.xml
new file mode 100644
index 0000000000..0451279563
--- /dev/null
+++ b/share/spack/templates/reports/cdash/Configure.xml
@@ -0,0 +1,8 @@
+ <Configure>
+ <StartConfigureTime>{{ configure.starttime }}</StartConfigureTime>
+ <ConfigureCommand>{{ install_command }}</ConfigureCommand>
+ <Log>{{ configure.log }}</Log>
+ <ConfigureStatus>{{ configure.status }}</ConfigureStatus>
+ <EndConfigureTime>{{ configure.endtime }}</EndConfigureTime>
+ </Configure>
+</Site>
diff --git a/share/spack/templates/reports/cdash/Site.xml b/share/spack/templates/reports/cdash/Site.xml
new file mode 100644
index 0000000000..a47ffd34e6
--- /dev/null
+++ b/share/spack/templates/reports/cdash/Site.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Site BuildName="{{ install_command }}"
+ BuildStamp="{{ buildstamp }}"
+ Name="{{ hostname }}"
+ OSName="{{ osname }}"
+>
+
diff --git a/share/spack/templates/reports/cdash/Update.xml b/share/spack/templates/reports/cdash/Update.xml
new file mode 100644
index 0000000000..39f3d6a337
--- /dev/null
+++ b/share/spack/templates/reports/cdash/Update.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Update>
+ <Site>{{ hostname }}</Site>
+ <BuildName>{{ install_command }}</BuildName>
+ <BuildStamp>{{ buildstamp }}</BuildStamp>
+ <StartTime>{{ starttime }}</StartTime>
+ <EndTime>{{ endtime }}</EndTime>
+{% if msg %}
+ <UpdateReturnStatus>{{ msg }}</UpdateReturnStatus>
+{% endif %}
+</Update>
diff --git a/share/spack/templates/reports/junit.xml b/share/spack/templates/reports/junit.xml
new file mode 100644
index 0000000000..62e6db40c8
--- /dev/null
+++ b/share/spack/templates/reports/junit.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This file has been modeled after the basic
+ specifications at this url:
+
+ http://help.catchsoftware.com/display/ET/JUnit+Format
+-->
+<testsuites>
+{% for spec in specs %}
+ <testsuite name="{{ spec.name }}"
+ errors="{{ spec.nerrors }}"
+ tests="{{ spec.npackages }}"
+ failures="{{ spec.nfailures }}"
+ time="{{ spec.time }}"
+ timestamp="{{ spec.timestamp }}" >
+ <properties>
+{% for property in spec.properties %}
+ <property name="{{ property.name }}" value="{{ property.value }}" />
+{% endfor %}
+ </properties>
+{% for package in spec.packages %}
+ <testcase classname="{{ package.name }}"
+ name="{{ package.id }}"
+ time="{{ package.elapsed_time }}">
+{% if package.result == 'failure' %}
+ <failure message="{{ package.message }}">
+{{ package.exception }}
+ </failure>
+{% elif package.result == 'error' %}
+ <error message="{{ package.message }}">
+{{ package.exception }}
+ </error>
+{% elif package.result == 'skipped' %}
+ <skipped />
+{% endif %}
+{% if package.stdout %}
+ <system-out>
+{{ package.stdout }}
+ </system-out>
+{% endif %}
+{% if package.stderr %}
+ <system-err>
+{{ package.stderr }}
+ </system-err>
+{% endif %}
+ </testcase>
+{% endfor %}
+{# Add an error tag? #}
+ </testsuite>
+{% endfor %}
+</testsuites>