Skip to content

Commit

Permalink
tools/refresh-submodules.sh: don't exit, but wait if called in parallel.
Browse files Browse the repository at this point in the history
Otherwise make thinks we're done, and we can get errors.  Include
primitive code if we abort build halfway and leave .refresh-submodules dir.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and niftynei committed Sep 1, 2020
1 parent 95a0249 commit b3d5220
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tools/refresh-submodules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ fi
[ -d .git ] || exit 0

# git submodule can't run in parallel. Really.
# Wait for it to finish if in parallel.
if ! mkdir .refresh-submodules 2>/dev/null ; then
exit 0
# If we don't make progress in ~60 seconds, force delete and retry.
LIMIT=$((50 + $$ % 20))
i=0
while [ $i -lt $LIMIT ]; do
[ -d .refresh-submodules ] || exit 0
sleep 1
i=$((i + 1))
done
rmdir .refresh-submodules
exec "$0" "$@" || exit 1
fi

trap "rmdir .refresh-submodules" EXIT
Expand Down

0 comments on commit b3d5220

Please sign in to comment.