diff --git a/install_spack_env.sh b/install_spack_env.sh index a9a6fdc42a3359c34d2d16d043747dcb7eb11b39..807da0da06417d7e05b5d1c49cdd82492f714498 100644 --- a/install_spack_env.sh +++ b/install_spack_env.sh @@ -21,10 +21,9 @@ export OCI_CACHE_PREFIX=$7 # make sure spack uses the symlinked folder as path export CI_SPACK_ROOT=${INSTALLATION_ROOT}/spack -# specify location of .spack dir (by default in ~) -# this is where cache and configuration settings are stored -export SPACK_USER_CACHE_PATH=${CI_SPACK_ROOT}/.spack -export SPACK_USER_CONFIG_PATH=${CI_SPACK_ROOT}/.spack +# disable local configuration and cache directories +export SPACK_DISABLE_LOCAL_CONFIG=true +export SPACK_USER_CACHE_PATH=/tmp/spack # define SYSTEMNAME variable in sites where it's not already defined export SYSTEMNAME=${SYSTEMNAME:-${HPC_SYSTEM:-$BSC_MACHINE}} @@ -46,19 +45,14 @@ if [ ! -d ${CI_SPACK_ROOT} ]; then SPACK_ROOT_EXISTED=0 fi -if [[ $UPSTREAM_INSTANCE ]] -then - UPSTREAM_PREFIX=$(find $UPSTREAM_INSTANCE/spack/opt/spack/ -type d -name ".spack-db" 2>/dev/null | xargs -I {} dirname {}) - cat <<EOF > ${CI_SPACK_ROOT}/etc/spack/defaults/upstreams.yaml -upstreams: - upstream-spack-instance: - install_tree: $UPSTREAM_PREFIX -EOF -fi - # activate Spack source ${CI_SPACK_ROOT}/share/spack/setup-env.sh +if [[ $UPSTREAM_INSTANCE ]]; then + UPSTREAM_PREFIX=$(find $UPSTREAM_INSTANCE/spack/opt/spack/ -type d -name ".spack-db" 2>/dev/null | xargs -I {} dirname {}) + spack config add upstreams:upstream-spack-instance:install_tree:$UPSTREAM_PREFIX +fi + if [ "${SPACK_ROOT_EXISTED}" -eq 0 ]; then # for caching purposes it's nice if we can relocate into long paths, but we # can't do that for existing installations -> else path