diff --git a/install_spack_env.sh b/install_spack_env.sh index 7510f389881e909af603804ee3d27b28d5fdd5f3..3bb01936104fd3cbee3465b541379927392d15fa 100644 --- a/install_spack_env.sh +++ b/install_spack_env.sh @@ -81,9 +81,12 @@ spack spec aida # rebuild spack's database (could be an debugging session) spack reindex -# TODO for newer spack versions, add: --autopush --unsigned, drop create cache command below -# (Note: spack expects `build_cache/` below the folder we specify here -spack mirror add local_cache ${SPACK_CACHE_BUILD} +# add local mirror if it does not exist +if [[ ! $(spack mirror list | grep local_cache) ]]; then + # TODO for newer spack versions, add: --autopush --unsigned, drop create cache command below + # (Note: spack expects `build_cache/` below the folder we specify here + spack mirror add local_cache ${SPACK_CACHE_BUILD} +fi # install platform compiler (extract version from packages.yaml) if [ $SYSTEMNAME == ebrainslab ] @@ -224,7 +227,9 @@ if [ $spack_install_ret -ne 0 ]; then fi # remove local cache content -spack mirror destroy --mirror-name local_cache +if [ -d ${SPACK_CACHE_BUILD} ]; then + spack mirror destroy --mirror-name local_cache +fi # TODO: when using spack remote OCI build caches require an index file #spack mirror add ebrains oci://docker-registry.ebrains.eu/esd/build_cache