From cc996d9d9f91772e31fd57680c4c7285b5e98886 Mon Sep 17 00:00:00 2001
From: Eleni Mathioulaki <emathioulaki@athenarc.gr>
Date: Fri, 28 Feb 2025 03:57:47 +0100
Subject: [PATCH 1/2] chore(CI): use spack config to set upstream

---
 install_spack_env.sh | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/install_spack_env.sh b/install_spack_env.sh
index a9a6fdc4..7e4fbe7a 100644
--- a/install_spack_env.sh
+++ b/install_spack_env.sh
@@ -46,19 +46,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
-- 
GitLab


From 905e1fb5fd2e85602672fb5d381ef967d1d346a2 Mon Sep 17 00:00:00 2001
From: Eleni Mathioulaki <emathioulaki@athenarc.gr>
Date: Fri, 28 Feb 2025 04:06:13 +0100
Subject: [PATCH 2/2] feat(CI): disable local configuration and cache
 directories

---
 install_spack_env.sh | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/install_spack_env.sh b/install_spack_env.sh
index 7e4fbe7a..807da0da 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}}
-- 
GitLab