diff --git a/platforms/common/spack_utils.sh b/platforms/common/spack_utils.sh index fd32c0db87cf33923f1ec3f7c209d5125f2e3367..81fe4f06bee7c6f8f353a344166109c2932d04bd 100644 --- a/platforms/common/spack_utils.sh +++ b/platforms/common/spack_utils.sh @@ -14,17 +14,21 @@ function _install_spack() { if [ ! -z "${SPACK_UPSTREAMS}" ]; then UPSTREAMS_CONFIG=${SPACK_ROOT}/etc/spack/upstreams.yaml - tmpfile=$(mktemp) - - echo "upstreams:" > $tmpfile - i=0 - for UP in ${SPACK_UPSTREAMS}; do - echo "Adding upstream repo to config $UPSTREAMS_CONFIG <= $UP" - i=$((i+1)) - echo " spack-instance-$i:" >> $tmpfile - echo " install_tree: $UP" >> $tmpfile - done - mv $tmpfile $UPSTREAMS_CONFIG + # If the upstream file already exists, just skip it. + if [ ! -f ${UPSTREAMS_CONFIG} ]; then + tmpfile=$(mktemp) + echo "upstreams:" > $tmpfile + i=0 + for UP in ${SPACK_UPSTREAMS}; do + echo "Adding upstream repo to config $UPSTREAMS_CONFIG <= $UP" + i=$((i+1)) + echo " spack-instance-$i:" >> $tmpfile + echo " install_tree: $UP" >> $tmpfile + done + mv $tmpfile $UPSTREAMS_CONFIG + else + echo "upstreams was already present: ${UPSTREAMS_CONFIG}" + fi fi if [ ! -z "${SPACK_EXTERNALS}" ] ; then