From a4f214e684aebaa6f7974ffe82bb1649f529f41b Mon Sep 17 00:00:00 2001
From: Eleni Mathioulaki <emathioulaki@athenarc.gr>
Date: Fri, 21 Feb 2025 12:04:43 +0100
Subject: [PATCH] fix(CI): find correct upstream prefix when it's padded

---
 install_spack_env.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/install_spack_env.sh b/install_spack_env.sh
index 3bb01936..bb7fb9be 100644
--- a/install_spack_env.sh
+++ b/install_spack_env.sh
@@ -52,10 +52,11 @@ 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_INSTANCE/spack/opt/spack
+    install_tree: $UPSTREAM_PREFIX
 EOF
 fi
 
-- 
GitLab