From ea767d8e963428a7622a074384ce86c2e91e6c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de> Date: Wed, 24 May 2023 10:33:23 +0200 Subject: [PATCH] Trying to use a lock file. --- platforms/common/spack_utils.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platforms/common/spack_utils.sh b/platforms/common/spack_utils.sh index 66cec0b..e441424 100644 --- a/platforms/common/spack_utils.sh +++ b/platforms/common/spack_utils.sh @@ -6,7 +6,14 @@ function _install_spack() { _init_spack "$SPACK_INIT_CMD" "$SPACK_ROOT" + # Adding a lock file to prevent race conditions. + UPSTREAMS_LOCK=${SPACK_ROOT}/etc/spack/upstreams.lock + while [ -f "${UPSTREAMS_LOCK}" ]; do + sleep 1 + done + if [ ! -z "${SPACK_UPSTREAMS}" ]; then + touch ${UPSTREAMS_LOCK} UPSTREAMS_CONFIG=${SPACK_ROOT}/etc/spack/upstreams.yaml echo "upstreams:" > $UPSTREAMS_CONFIG i=0 @@ -18,6 +25,7 @@ function _install_spack() { install_tree: $UP EOF done + rm ${UPSTREAMS_LOCK} fi if [ ! -z "${SPACK_EXTERNALS}" ] ; then -- GitLab