diff --git a/images/macos/provision/core/android-toolsets.sh b/images/macos/provision/core/android-toolsets.sh index 5673ad33..0589a5a4 100755 --- a/images/macos/provision/core/android-toolsets.sh +++ b/images/macos/provision/core/android-toolsets.sh @@ -126,7 +126,7 @@ sdkTools="android-sdk-tools.zip" sdkToolsVersion=$(get_toolset_value '.android."sdk-tools"') if [ "$sdkToolsVersion" != "null" ]; then download_with_retries "https://dl.google.com/android/repository/${sdkToolsVersion}" "." $sdkTools - unzip -qq $sdkTools -d ${ANDROID_SDK_ROOT} + unzip -o -qq $sdkTools -d ${ANDROID_SDK_ROOT} rm -f $sdkTools fi diff --git a/images/macos/provision/core/commonutils.sh b/images/macos/provision/core/commonutils.sh index 350f8705..cbe0b9c4 100644 --- a/images/macos/provision/core/commonutils.sh +++ b/images/macos/provision/core/commonutils.sh @@ -36,6 +36,7 @@ fi # System Preferences -> Security & Privacy -> General -> Unlock -> Allow -> Not now if is_Monterey; then if is_Veertu; then + echo "Executing AppleScript to change security preferences (with retries)" retry=5 while [ $retry -gt 0 ]; do { @@ -48,6 +49,7 @@ if is_Monterey; then sleep 10 done else + echo "Executing AppleScript to change security preferences" osascript $HOME/utils/confirm-identified-developers.scpt $USER_PASSWORD fi fi @@ -82,13 +84,5 @@ bazel # Install Azure DevOps extension for Azure Command Line Interface az extension add -n azure-devops -# Workaround https://github.com/actions/runner-images/issues/4931 -# by making Tcl/Tk paths the same on macOS 10.15 and macOS 11 -if is_Monterey; then - version=$(brew info tcl-tk --json | jq -r '.[].installed[].version') - ln -s /usr/local/Cellar/tcl-tk/$version/lib/libtcl8.6.dylib /usr/local/lib/libtcl8.6.dylib - ln -s /usr/local/Cellar/tcl-tk/$version/lib/libtk8.6.dylib /usr/local/lib/libtk8.6.dylib -fi - # Invoke tests for all basic tools invoke_tests "BasicTools" diff --git a/images/macos/provision/core/pypy.sh b/images/macos/provision/core/pypy.sh index eae5c389..6e12ed9c 100644 --- a/images/macos/provision/core/pypy.sh +++ b/images/macos/provision/core/pypy.sh @@ -11,7 +11,7 @@ function InstallPyPy PACKAGE_URL=$1 PACKAGE_TAR_NAME=$(echo $PACKAGE_URL | awk -F/ '{print $NF}') - echo "Downloading tar archive '$PACKAGE_TAR_NAME' - '$PACKAGE_URL'" + echo "Downloading tar archive '$PACKAGE_TAR_NAME'" PACKAGE_TAR_TEMP_PATH="/tmp/$PACKAGE_TAR_NAME" download_with_retries $PACKAGE_URL "/tmp" "$PACKAGE_TAR_NAME" @@ -89,4 +89,4 @@ for toolsetVersion in $toolsetVersions; do exit 1 fi InstallPyPy $latestMajorPyPyVersion -done \ No newline at end of file +done diff --git a/images/macos/provision/utils/utils.sh b/images/macos/provision/utils/utils.sh index 5cb86690..35daaef2 100755 --- a/images/macos/provision/utils/utils.sh +++ b/images/macos/provision/utils/utils.sh @@ -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" diff --git a/images/macos/tests/BasicTools.Tests.ps1 b/images/macos/tests/BasicTools.Tests.ps1 index 345772ff..c4b763cd 100644 --- a/images/macos/tests/BasicTools.Tests.ps1 +++ b/images/macos/tests/BasicTools.Tests.ps1 @@ -67,6 +67,13 @@ Describe "Helm" -Skip:($os.IsMonterey -or $os.IsVentura -or $os.IsVenturaArm64) } } +Describe "Tcl/Tk" { + It "libtcl" { + "file /usr/local/lib/libtcl8.6.dylib" | Should -ReturnZeroExitCode + "file /usr/local/lib/libtk8.6.dylib" | Should -ReturnZeroExitCode + } +} + Describe "bazelisk" { It "bazelisk" { "bazelisk version" | Should -ReturnZeroExitCode @@ -164,9 +171,9 @@ Describe "Homebrew" { } Describe "Kotlin" { - $kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlinc-jvm", "kotlin-dce-js") + $kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlinc-jvm", "kotlin-dce-js") - It " is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) { + It " is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) { "$toolName -version" | Should -ReturnZeroExitCode } } @@ -187,4 +194,4 @@ Describe "imagemagick" -Skip:($os.IsVentura -or $os.IsVenturaArm64) { It "imagemagick" { "magick -version" | Should -ReturnZeroExitCode } -} \ No newline at end of file +}