mirror of
https://github.com/actions/runner-images.git
synced 2026-01-06 18:19:54 +08:00
[MacOS] improve errexit option handling (#8432)
* [MacOS] improve errexit option handling * Prevent prompting for override when unzipping * Explicitly allow failing when installing virtualbox * Remove libtcl symlinks * Add debug output
This commit is contained in:
committed by
GitHub
parent
fc9431c2eb
commit
378c4d7511
@@ -15,15 +15,24 @@ download_with_retries() {
|
||||
local COMMAND="curl $URL -4 -sL -o '$DEST/$NAME' -w '%{http_code}'"
|
||||
fi
|
||||
|
||||
# Save current errexit state and disable it to prevent unexpected exit on error
|
||||
if echo $SHELLOPTS | grep '\(^\|:\)errexit\(:\|$\)' > /dev/null;
|
||||
then
|
||||
local ERR_EXIT_ENABLED=true
|
||||
else
|
||||
local ERR_EXIT_ENABLED=false
|
||||
fi
|
||||
set +e
|
||||
|
||||
echo "Downloading '$URL' to '${DEST}/${NAME}'..."
|
||||
retries=20
|
||||
interval=30
|
||||
while [ $retries -gt 0 ]; do
|
||||
((retries--))
|
||||
# Temporary disable exit on error to retry on non-zero exit code
|
||||
set +e
|
||||
test "$ERR_EXIT_ENABLED" = true && set +e
|
||||
http_code=$(eval $COMMAND)
|
||||
exit_code=$?
|
||||
test "$ERR_EXIT_ENABLED" = true && set -e
|
||||
if [ $http_code -eq 200 ] && [ $exit_code -eq 0 ]; then
|
||||
echo "Download completed"
|
||||
return 0
|
||||
@@ -31,8 +40,6 @@ download_with_retries() {
|
||||
echo "Error — Either HTTP response code for '$URL' is wrong - '$http_code' or exit code is not 0 - '$exit_code'. Waiting $interval seconds before the next attempt, $retries attempts left"
|
||||
sleep 30
|
||||
fi
|
||||
# Enable exit on error back
|
||||
set -e
|
||||
done
|
||||
|
||||
echo "Could not download $URL"
|
||||
|
||||
Reference in New Issue
Block a user