Skip to content
Snippets Groups Projects
Commit 1bc72701 authored by Fabian.Jakub's avatar Fabian.Jakub
Browse files

use mktemp file instead of a lock file around spack/upstreams

parent ea767d8e
No related branches found
No related tags found
No related merge requests found
Pipeline #18786 failed
......@@ -6,26 +6,19 @@ 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
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))
cat << EOF >> $UPSTREAMS_CONFIG
spack-instance-$i:
install_tree: $UP
EOF
echo " spack-instance-$i:" >> $tmpfile
echo " install_tree: $UP" >> $tmpfile
done
rm ${UPSTREAMS_LOCK}
mv $tmpfile $UPSTREAMS_CONFIG
fi
if [ ! -z "${SPACK_EXTERNALS}" ] ; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment