diff --git a/images/macos/scripts/build/configure-autologin.sh b/images/macos/scripts/build/configure-autologin.sh index f281237e4..16bdc9242 100644 --- a/images/macos/scripts/build/configure-autologin.sh +++ b/images/macos/scripts/build/configure-autologin.sh @@ -7,9 +7,7 @@ ################################################################################ echo "Enabling automatic GUI login for the '$USERNAME' user.." - python3 $HOME/bootstrap/kcpassword.py "$PASSWORD" - /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser "$USERNAME" : ' diff --git a/images/macos/scripts/build/configure-machine.sh b/images/macos/scripts/build/configure-machine.sh index e8eda5c47..11488e76a 100644 --- a/images/macos/scripts/build/configure-machine.sh +++ b/images/macos/scripts/build/configure-machine.sh @@ -43,7 +43,6 @@ defaults write com.apple.VoiceOver4/default SCREnableAppleScript -bool YES swiftc -suppress-warnings "${HOME}/image-generation/add-certificate.swift" - certs=( AppleWWDRCAG3.cer DeveloperIDG2CA.cer @@ -52,9 +51,7 @@ for cert in ${certs[@]}; do echo "Adding ${cert} certificate" cert_path="${HOME}/${cert}" curl -fsSL "https://www.apple.com/certificateauthority/${cert}" --output ${cert_path} - sudo ./add-certificate ${cert_path} - rm ${cert_path} done diff --git a/images/macos/scripts/build/configure-max-files-limitation.sh b/images/macos/scripts/build/configure-max-files-limitation.sh index de9d13f0c..6877bf50c 100644 --- a/images/macos/scripts/build/configure-max-files-limitation.sh +++ b/images/macos/scripts/build/configure-max-files-limitation.sh @@ -41,5 +41,4 @@ echo "limit.maxfiles.plist permissions changing" chown root:wheel "${Launch_Daemons}/limit.maxfiles.plist" chmod 0644 "${Launch_Daemons}/limit.maxfiles.plist" - echo "Done, limit.maxfiles has been updated" diff --git a/images/macos/scripts/build/configure-network-interface-detection.sh b/images/macos/scripts/build/configure-network-interface-detection.sh index c60cd636f..87808eba5 100644 --- a/images/macos/scripts/build/configure-network-interface-detection.sh +++ b/images/macos/scripts/build/configure-network-interface-detection.sh @@ -30,7 +30,6 @@ EOF /bin/chmod 644 "${PLIST}" /usr/sbin/chown root:wheel "${PLIST}" - : ' The MIT License (MIT) Copyright (c) 2013-2017 Timothy Sutton diff --git a/images/macos/scripts/build/configure-windows.sh b/images/macos/scripts/build/configure-windows.sh index 02da5fadb..92cb9aa98 100644 --- a/images/macos/scripts/build/configure-windows.sh +++ b/images/macos/scripts/build/configure-windows.sh @@ -13,11 +13,10 @@ if is_Arm64; then fi retry=10 -while [ $retry -gt 0 ]; do +while [[ $retry -gt 0 ]]; do openwindows=$(osascript -e 'tell application "System Events" to get every window of (every process whose class of windows contains window)') && break - retry=$((retry-1)) - if [ $retry -eq 0 ]; then + if [[ $retry -eq 0 ]]; then echo "No retry attempts left" exit 1 fi diff --git a/images/macos/scripts/build/configure-xcode.sh b/images/macos/scripts/build/configure-xcode.sh index 23b054f6f..bde270381 100644 --- a/images/macos/scripts/build/configure-xcode.sh +++ b/images/macos/scripts/build/configure-xcode.sh @@ -5,6 +5,7 @@ ################################################################################ source ~/utils/utils.sh + XCODE_LIST=($(get_toolset_value '.xcode.versions | reverse | .[].link')) DEFAULT_XCODE_VERSION=$(get_toolset_value '.xcode.default') diff --git a/images/macos/scripts/build/install-actions-cache.sh b/images/macos/scripts/build/install-actions-cache.sh index 02a4c39dc..4871bf86a 100644 --- a/images/macos/scripts/build/install-actions-cache.sh +++ b/images/macos/scripts/build/install-actions-cache.sh @@ -12,7 +12,7 @@ if [ ! -d $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE ]; then mkdir -p $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE fi -download_url=$(get_github_package_download_url "actions/action-versions" "contains(\"action-versions.tar.gz\")" "latest") +download_url=$(resolve_github_release_asset_url "actions/action-versions" "contains(\"action-versions.tar.gz\")" "latest") echo "Downloading action-versions $download_url" archive_path=$(download_with_retry "$download_url") tar -xzf "$archive_path" -C "$ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE" diff --git a/images/macos/scripts/build/install-chrome.sh b/images/macos/scripts/build/install-chrome.sh index 22dfe4178..ace3ee728 100644 --- a/images/macos/scripts/build/install-chrome.sh +++ b/images/macos/scripts/build/install-chrome.sh @@ -11,40 +11,40 @@ echo "Installing Google Chrome..." brew install --cask google-chrome # Parse Google Chrome version -FULL_CHROME_VERSION=$("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --version) -FULL_CHROME_VERSION=${FULL_CHROME_VERSION#Google Chrome } -CHROME_VERSION=${FULL_CHROME_VERSION%.*} -echo "Google Chrome version is $FULL_CHROME_VERSION" +full_chrome_version=$("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --version) +full_chrome_version=${full_chrome_version#Google Chrome } +chrome_version=${full_chrome_version%.*} +echo "Google Chrome version is $full_chrome_version" # Get Google Chrome versions information -CHROME_PLATFORM="mac-$arch" +chrome_platform="mac-$arch" CHROME_VERSIONS_URL="https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json" -CHROME_VERSIONS_JSON="$(cat "$(download_with_retry "$CHROME_VERSIONS_URL")")" +chrome_versions_json="$(cat "$(download_with_retry "$CHROME_VERSIONS_URL")")" # Download and unpack the latest release of Chrome Driver -CHROMEDRIVER_VERSION=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].version') -echo "Installing Chrome Driver version $CHROMEDRIVER_VERSION" +chromedriver_version=$(echo "${chrome_versions_json}" | jq -r '.builds["'"$chrome_version"'"].version') +echo "Installing Chrome Driver version $chromedriver_version" -CHROMEDRIVER_URL=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].downloads.chromedriver[] | select(.platform=="'"${CHROME_PLATFORM}"'").url') -CHROMEDRIVER_DIR="/usr/local/share/chromedriver-${CHROME_PLATFORM}" -CHROMEDRIVER_BIN="$CHROMEDRIVER_DIR/chromedriver" +chromedriver_url=$(echo "${chrome_versions_json}" | jq -r '.builds["'"$chrome_version"'"].downloads.chromedriver[] | select(.platform=="'"${chrome_platform}"'").url') +chromedriver_dir="/usr/local/share/chromedriver-${chrome_platform}" +chromedriver_bin="$chromedriver_dir/chromedriver" -CHROMEDRIVER_ARCHIVE_PATH=$(download_with_retry "$CHROMEDRIVER_URL") -unzip -qq "$CHROMEDRIVER_ARCHIVE_PATH" -d /tmp/ -sudo mv "/tmp/chromedriver-${CHROME_PLATFORM}" "$CHROMEDRIVER_DIR" -ln -s "$CHROMEDRIVER_BIN" /usr/local/bin/chromedriver -echo "export CHROMEWEBDRIVER=$CHROMEDRIVER_DIR" >> "${HOME}/.bashrc" +chromedriver_archive_path=$(download_with_retry "$chromedriver_url") +unzip -qq "$chromedriver_archive_path" -d /tmp/ +sudo mv "/tmp/chromedriver-${chrome_platform}" "$chromedriver_dir" +ln -s "$chromedriver_bin" /usr/local/bin/chromedriver +echo "export CHROMEWEBDRIVER=$chromedriver_dir" >> "${HOME}/.bashrc" # Download and unpack the latest release of Google Chrome for Testing -CHROME_FOR_TESTING_VERSION=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].version') -echo "Installing Google Chrome for Testing version $CHROME_FOR_TESTING_VERSION" +chrome_for_testing_version=$(echo "${chrome_versions_json}" | jq -r '.builds["'"$chrome_version"'"].version') +echo "Installing Google Chrome for Testing version $chrome_for_testing_version" -CHROME_FOR_TESTING_URL=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].downloads.chrome[] | select(.platform=="'"${CHROME_PLATFORM}"'").url') -CHROME_FOR_TESTING_APP="Google Chrome for Testing.app" +chrome_for_testing_url=$(echo "${chrome_versions_json}" | jq -r '.builds["'"$chrome_version"'"].downloads.chrome[] | select(.platform=="'"${chrome_platform}"'").url') +chrome_for_testing_app="Google Chrome for Testing.app" -CHROME_FOR_TESTING_ARCHIVE_PATH=$(download_with_retry "$CHROME_FOR_TESTING_URL") -unzip -qq "$CHROME_FOR_TESTING_ARCHIVE_PATH" -d /tmp/ -mv "/tmp/chrome-${CHROME_PLATFORM}/${CHROME_FOR_TESTING_APP}" "/Applications/${CHROME_FOR_TESTING_APP}" +chrome_for_testing_archive_path=$(download_with_retry "$chrome_for_testing_url") +unzip -qq "$chrome_for_testing_archive_path" -d /tmp/ +mv "/tmp/chrome-${chrome_platform}/${chrome_for_testing_app}" "/Applications/${chrome_for_testing_app}" echo "Installing Selenium" brew_smart_install "selenium-server" diff --git a/images/macos/scripts/build/install-common-utils.sh b/images/macos/scripts/build/install-common-utils.sh index 253a2b60d..a414637a7 100644 --- a/images/macos/scripts/build/install-common-utils.sh +++ b/images/macos/scripts/build/install-common-utils.sh @@ -51,7 +51,7 @@ if is_Monterey; then osascript $HOME/utils/confirm-identified-developers.scpt $USER_PASSWORD } && break - if [ "$retry" -eq 0 ]; then + if [[ "$retry" -eq 0 ]]; then echo "Executing AppleScript failed. No retries left" exit 1 fi @@ -75,14 +75,14 @@ if is_Monterey; then dbQuery="SELECT * FROM kext_policy WHERE bundle_id LIKE 'com.parallels.kext.%';" kext=$(sudo sqlite3 $dbName "$dbQuery") - if [ -z "$kext" ]; then + if [[ -z "$kext" ]]; then echo "Parallels International GmbH not found" exit 1 fi # Create env variable url=$(brew info --json=v2 --installed | jq -r '.casks[] | select(.name[] == "Parallels Desktop").url') - if [ -z "$url" ]; then + if [[ -z "$url" ]]; then echo "Unable to parse url for Parallels Desktop cask" exit 1 fi diff --git a/images/macos/scripts/build/install-dotnet.sh b/images/macos/scripts/build/install-dotnet.sh index f7fc1039d..0bc0feb08 100644 --- a/images/macos/scripts/build/install-dotnet.sh +++ b/images/macos/scripts/build/install-dotnet.sh @@ -15,21 +15,21 @@ DOTNET_INSTALL_SCRIPT="https://dot.net/v1/dotnet-install.sh" install_script_path=$(download_with_retry $DOTNET_INSTALL_SCRIPT) chmod +x "$install_script_path" -ARGS_LIST=() +args_list=() echo "Parsing dotnet SDK (except rc and preview versions) from .json..." -DOTNET_VERSIONS=($(get_toolset_value ".dotnet.arch[\"$arch\"].versions | .[]")) +dotnet_versions=($(get_toolset_value ".dotnet.arch[\"$arch\"].versions | .[]")) -for DOTNET_VERSION in "${DOTNET_VERSIONS[@]}"; do - RELEASE_URL="https://raw.githubusercontent.com/dotnet/core/main/release-notes/${DOTNET_VERSION}/releases.json" - releases_json_file=$(download_with_retry "$RELEASE_URL") +for dotnet_version in "${dotnet_versions[@]}"; do + release_url="https://raw.githubusercontent.com/dotnet/core/main/release-notes/${dotnet_version}/releases.json" + releases_json_file=$(download_with_retry "$release_url") - if [[ $DOTNET_VERSION == "6.0" ]]; then - ARGS_LIST+=( + if [[ $dotnet_version == "6.0" ]]; then + args_list+=( $(cat "$releases_json_file" | jq -r 'first(.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not))') ) else - ARGS_LIST+=( + args_list+=( $(cat "$releases_json_file" | \ jq -r '.releases[].sdk."version"' | grep -v -E '\-(preview|rc)\d*' | \ sort -r | rev | uniq -s 2 | rev) @@ -37,7 +37,7 @@ for DOTNET_VERSION in "${DOTNET_VERSIONS[@]}"; do fi done -for ARGS in "${ARGS_LIST[@]}"; do +for ARGS in "${args_list[@]}"; do "$install_script_path" --version $ARGS -NoPath --arch $arch done diff --git a/images/macos/scripts/build/install-edge.sh b/images/macos/scripts/build/install-edge.sh index 94f0b7777..5146e202b 100644 --- a/images/macos/scripts/build/install-edge.sh +++ b/images/macos/scripts/build/install-edge.sh @@ -10,27 +10,27 @@ echo "Installing Microsoft Edge..." brew install --cask microsoft-edge EDGE_INSTALLATION_PATH="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" -EDGE_VERSION=$("$EDGE_INSTALLATION_PATH" --version | cut -d' ' -f 3) -EDGE_VERSION_MAJOR=$(echo $EDGE_VERSION | cut -d'.' -f 1) +edge_version=$("$EDGE_INSTALLATION_PATH" --version | cut -d' ' -f 3) +edge_version_major=$(echo $edge_version | cut -d'.' -f 1) -echo "Version of Microsoft Edge: ${EDGE_VERSION}" +echo "Version of Microsoft Edge: ${edge_version}" echo "Installing Microsoft Edge WebDriver..." -EDGE_DRIVER_VERSION_FILE_PATH=$(download_with_retry "https://msedgedriver.azureedge.net/LATEST_RELEASE_${EDGE_VERSION_MAJOR}_MACOS") -EDGE_DRIVER_LATEST_VERSION=$(iconv -f utf-16 -t utf-8 "$EDGE_DRIVER_VERSION_FILE_PATH" | tr -d '\r') -EDGE_DRIVER_URL="https://msedgedriver.azureedge.net/${EDGE_DRIVER_LATEST_VERSION}/edgedriver_mac64.zip" +edge_driver_version_file_path=$(download_with_retry "https://msedgedriver.azureedge.net/LATEST_RELEASE_${edge_version_major}_MACOS") +edge_driver_latest_version=$(iconv -f utf-16 -t utf-8 "$edge_driver_version_file_path" | tr -d '\r') +edge_driver_url="https://msedgedriver.azureedge.net/${edge_driver_latest_version}/edgedriver_mac64.zip" -echo "Compatible version of WebDriver: ${EDGE_DRIVER_LATEST_VERSION}" +echo "Compatible version of WebDriver: ${edge_driver_latest_version}" -EDGE_DRIVER_ARCHIVE_PATH=$(download_with_retry "$EDGE_DRIVER_URL") +edge_driver_archive_path=$(download_with_retry "$edge_driver_url") # Move webdriver to the separate directory to be consistent with the docs # https://docs.microsoft.com/en-us/azure/devops/pipelines/test/continuous-test-selenium?view=azure-devops#decide-how-you-will-deploy-and-test-your-app EDGE_DRIVER_DIR="/usr/local/share/edge_driver" mkdir -p $EDGE_DRIVER_DIR -unzip -qq "$EDGE_DRIVER_ARCHIVE_PATH" -d "$EDGE_DRIVER_DIR" +unzip -qq "$edge_driver_archive_path" -d "$EDGE_DRIVER_DIR" ln -s "$EDGE_DRIVER_DIR/msedgedriver" "/usr/local/bin/msedgedriver" echo "export EDGEWEBDRIVER=${EDGE_DRIVER_DIR}" >> "${HOME}/.bashrc" diff --git a/images/macos/scripts/build/install-golang.sh b/images/macos/scripts/build/install-golang.sh index 21d00d62d..7a28868ed 100644 --- a/images/macos/scripts/build/install-golang.sh +++ b/images/macos/scripts/build/install-golang.sh @@ -6,11 +6,11 @@ source ~/utils/utils.sh -DEFAULT_GO_VERSION=$(get_toolset_value '.go.default') +default_go_version=$(get_toolset_value '.go.default') echo "Installing Go..." -brew_smart_install "go@${DEFAULT_GO_VERSION}" +brew_smart_install "go@${default_go_version}" # Create symlinks to preserve backward compatibility. Symlinks are not created when non-latest go is being installed -ln -sf $(brew --prefix go@${DEFAULT_GO_VERSION})/bin/* /usr/local/bin/ +ln -sf $(brew --prefix go@${default_go_version})/bin/* /usr/local/bin/ invoke_tests "Common" "Go" diff --git a/images/macos/scripts/build/install-mono.sh b/images/macos/scripts/build/install-mono.sh index 1fa6e29f4..b5569a419 100644 --- a/images/macos/scripts/build/install-mono.sh +++ b/images/macos/scripts/build/install-mono.sh @@ -4,50 +4,48 @@ ## Desc: Install Mono Framework ################################################################################ -# Source utility functions source ~/utils/utils.sh # Install Mono Framework -MONO_VERSION_FULL=$(get_toolset_value '.mono.framework.version') -MONO_PKG_SHA256=$(get_toolset_value '.mono.framework.sha256') -MONO_VERSION=$(echo "$MONO_VERSION_FULL" | cut -d. -f 1,2,3) -MONO_VERSION_SHORT=$(echo $MONO_VERSION_FULL | cut -d. -f 1,2) -MONO_PKG_URL="https://download.mono-project.com/archive/${MONO_VERSION}/macos-10-universal/MonoFramework-MDK-${MONO_VERSION_FULL}.macos10.xamarin.universal.pkg" +mono_version_full=$(get_toolset_value '.mono.framework.version') +mono_pkg_sha256=$(get_toolset_value '.mono.framework.sha256') +mono_version=$(echo "$mono_version_full" | cut -d. -f 1,2,3) +mono_version_short=$(echo $mono_version_full | cut -d. -f 1,2) +mono_pkg_url="https://download.mono-project.com/archive/${mono_version}/macos-10-universal/MonoFramework-MDK-${mono_version_full}.macos10.xamarin.universal.pkg" MONO_VERSIONS_PATH='/Library/Frameworks/Mono.framework/Versions' -MONO_PKG_PATH=$(download_with_retry "$MONO_PKG_URL") -use_checksum_comparison "$MONO_PKG_PATH" "$MONO_PKG_SHA256" - -echo "Installing Mono Framework ${MONO_VERSION_FULL}..." -sudo installer -pkg "$MONO_PKG_PATH" -target / +mono_pkg_path=$(download_with_retry "$mono_pkg_url") +use_checksum_comparison "$mono_pkg_path" "$mono_pkg_sha256" +echo "Installing Mono Framework ${mono_version_full}..." +sudo installer -pkg "$mono_pkg_path" -target / # Download and install NUnit console -NUNIT_VERSION=$(get_toolset_value '.mono.nunit.version') -NUNIT_ARCHIVE_URL="https://github.com/nunit/nunit-console/releases/download/${NUNIT_VERSION}/NUnit.Console-${NUNIT_VERSION}.zip" -NUNIT_ARCHIVE_SHA256=$(get_toolset_value '.mono.nunit.sha256') +nunit_version=$(get_toolset_value '.mono.nunit.version') +nunit_archive_url="https://github.com/nunit/nunit-console/releases/download/${nunit_version}/NUnit.Console-${nunit_version}.zip" +nunit_archive_sha256=$(get_toolset_value '.mono.nunit.sha256') NUNIT_PATH="/Library/Developer/nunit" -NUNIT_VERSION_PATH="$NUNIT_PATH/$NUNIT_VERSION" +nunit_version_path="$NUNIT_PATH/$nunit_version" -NUNIT_ARCHIVE_PATH=$(download_with_retry "$NUNIT_ARCHIVE_URL") -use_checksum_comparison "$NUNIT_ARCHIVE_PATH" "$NUNIT_ARCHIVE_SHA256" -echo "Installing NUnit ${NUNIT_VERSION}..." -sudo mkdir -p "$NUNIT_VERSION_PATH" -sudo unzip -q "$NUNIT_ARCHIVE_PATH" -d "$NUNIT_VERSION_PATH" +nunit_archive_path=$(download_with_retry "$nunit_archive_url") +use_checksum_comparison "$nunit_archive_path" "$nunit_archive_sha256" +echo "Installing NUnit ${nunit_version}..." +sudo mkdir -p "$nunit_version_path" +sudo unzip -q "$nunit_archive_path" -d "$nunit_version_path" # Create a wrapper script for nunit3-console echo "Creating nunit3-console wrapper..." -NUNIT3_CONSOLE_WRAPPER=$(mktemp) -cat < "$NUNIT3_CONSOLE_WRAPPER" +nunit3_console_wrapper=$(mktemp) +cat < "$nunit3_console_wrapper" #!/bin/bash -e -o pipefail -exec ${MONO_VERSIONS_PATH}/${MONO_VERSION}/bin/mono --debug \$MONO_OPTIONS $NUNIT_VERSION_PATH/nunit3-console.exe "\$@" +exec ${MONO_VERSIONS_PATH}/${mono_version}/bin/mono --debug \$MONO_OPTIONS $nunit_version_path/nunit3-console.exe "\$@" EOF -cat "$NUNIT3_CONSOLE_WRAPPER" -sudo chmod +x "$NUNIT3_CONSOLE_WRAPPER" -sudo mv "$NUNIT3_CONSOLE_WRAPPER" "${MONO_VERSIONS_PATH}/${MONO_VERSION}/Commands/nunit3-console" +cat "$nunit3_console_wrapper" +sudo chmod +x "$nunit3_console_wrapper" +sudo mv "$nunit3_console_wrapper" "${MONO_VERSIONS_PATH}/${mono_version}/Commands/nunit3-console" # Create a symlink for the short version of Mono (e.g., 6.12) -echo "Creating short symlink '${MONO_VERSION_SHORT}'..." -sudo ln -s "${MONO_VERSIONS_PATH}/${MONO_VERSION}" "${MONO_VERSIONS_PATH}/${MONO_VERSION_SHORT}" +echo "Creating short symlink '${mono_version_short}'..." +sudo ln -s "${MONO_VERSIONS_PATH}/${mono_version}" "${MONO_VERSIONS_PATH}/${mono_version_short}" # Invoke tests for Xamarin and Mono invoke_tests "Xamarin" "Mono" diff --git a/images/macos/scripts/build/install-nvm.sh b/images/macos/scripts/build/install-nvm.sh index 4c2c121d5..49948459d 100644 --- a/images/macos/scripts/build/install-nvm.sh +++ b/images/macos/scripts/build/install-nvm.sh @@ -19,7 +19,6 @@ if bash "$nvm_installer_path"; then # set system node as default nvm alias default system - echo "Node version manager has been installed successfully" else echo "Node version manager installation failed" diff --git a/images/macos/scripts/build/install-pipx-packages.sh b/images/macos/scripts/build/install-pipx-packages.sh index 19efeee7b..0b4a8f90f 100644 --- a/images/macos/scripts/build/install-pipx-packages.sh +++ b/images/macos/scripts/build/install-pipx-packages.sh @@ -8,19 +8,11 @@ source ~/utils/utils.sh export PATH="$PATH:/opt/pipx_bin" -toolset=$(get_toolset_path) -pipx_packages=$(jq -r ".pipx[] .package" $toolset) +pipx_packages=$(get_toolset_value '.pipx[].package') for package in $pipx_packages; do - python_version=$(jq -r ".pipx[] | select(.package == \"$package\") .python" $toolset) - if [ "$python_version" != "null" ]; then - python_path="$HOME/hostedtoolcache/Python/$python_version*/x64/bin/python$python_version" - echo "Install $package into python $python_path" - pipx install $package --python $python_path - else - echo "Install $package into default python" - pipx install $package - fi + echo "Install $package into default python" + pipx install $package done invoke_tests "PipxPackages" diff --git a/images/macos/scripts/build/install-powershell.sh b/images/macos/scripts/build/install-powershell.sh index 3a0a1bbd9..b38ff10e7 100644 --- a/images/macos/scripts/build/install-powershell.sh +++ b/images/macos/scripts/build/install-powershell.sh @@ -11,7 +11,7 @@ arch=$(get_arch) metadata_json_path=$(download_with_retry "https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json") version=$(jq -r '.LTSReleaseTag[0]' "$metadata_json_path") -download_url=$(get_github_package_download_url "PowerShell/PowerShell" "contains(\"osx-$arch.pkg\")" "$version" "$API_PAT") +download_url=$(resolve_github_release_asset_url "PowerShell/PowerShell" "contains(\"osx-$arch.pkg\")" "$version" "$API_PAT") pkg_path=$(download_with_retry "$download_url") # Work around the issue on macOS Big Sur 11.5 or higher for possible error message ("can't be opened because Apple cannot check it for malicious software") when installing the package diff --git a/images/macos/scripts/build/install-visualstudio.sh b/images/macos/scripts/build/install-visualstudio.sh index 805a0c542..402665b73 100644 --- a/images/macos/scripts/build/install-visualstudio.sh +++ b/images/macos/scripts/build/install-visualstudio.sh @@ -8,33 +8,33 @@ source ~/utils/utils.sh source ~/utils/xamarin-utils.sh install_vsmac() { - local VSMAC_VERSION=$1 - local VSMAC_DEFAULT=$2 - if [ $VSMAC_VERSION == "2019" ]; then - VSMAC_DOWNLOAD_URL=$(curl -fsSL "https://aka.ms/manifest/stable" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') - elif [ $VSMAC_VERSION == "2022" ]; then - VSMAC_DOWNLOAD_URL=$(curl -fsSL "https://aka.ms/manifest/stable-2022" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') - elif [ $VSMAC_VERSION == "preview" ]; then - VSMAC_DOWNLOAD_URL=$(curl -fsSL "https://aka.ms/manifest/preview" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') + local vsmac_version=$1 + local vsmac_default=$2 + if [[ $vsmac_version == "2019" ]]; then + vsmac_download_url=$(curl -fsSL "https://aka.ms/manifest/stable" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') + elif [[ $vsmac_version == "2022" ]]; then + vsmac_download_url=$(curl -fsSL "https://aka.ms/manifest/stable-2022" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') + elif [[ $vsmac_version == "preview" ]]; then + vsmac_download_url=$(curl -fsSL "https://aka.ms/manifest/preview" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') else - VSMAC_DOWNLOAD_URL=$(buildVSMacDownloadUrl $VSMAC_VERSION) + vsmac_download_url=$(buildVSMacDownloadUrl $vsmac_version) fi - echo "Installing Visual Studio ${VSMAC_VERSION} for Mac" + echo "Installing Visual Studio ${vsmac_version} for Mac" TMPMOUNT=$(/usr/bin/mktemp -d /tmp/visualstudio.XXXX) mkdir -p "$TMPMOUNT/downloads" - VSMAC_INSTALLER=$(download_with_retry "$VSMAC_DOWNLOAD_URL" "$TMPMOUNT/downloads/${VSMAC_DOWNLOAD_URL##*/}") + vsmac_installer=$(download_with_retry "$vsmac_download_url" "$TMPMOUNT/downloads/${vsmac_download_url##*/}") echo "Mounting Visual Studio..." - hdiutil attach "$VSMAC_INSTALLER" -mountpoint "$TMPMOUNT" + hdiutil attach "$vsmac_installer" -mountpoint "$TMPMOUNT" echo "Moving Visual Studio to /Applications/..." pushd "$TMPMOUNT" tar cf - "./Visual Studio.app" | tar xf - -C /Applications/ - if [ $VSMAC_VERSION != $VSMAC_DEFAULT ]; then - mv "/Applications/Visual Studio.app" "/Applications/Visual Studio ${VSMAC_VERSION}.app" + if [[ $vsmac_version != $vsmac_default ]]; then + mv "/Applications/Visual Studio.app" "/Applications/Visual Studio ${vsmac_version}.app" fi popd @@ -42,11 +42,11 @@ install_vsmac() { sudo rm -rf "$TMPMOUNT" } -VSMAC_VERSIONS=($(get_toolset_value '.xamarin.vsmac.versions[]')) -DEFAULT_VSMAC_VERSION=$(get_toolset_value '.xamarin.vsmac.default') +vsmac_versions=($(get_toolset_value '.xamarin.vsmac.versions[]')) +default_vsmac_version=$(get_toolset_value '.xamarin.vsmac.default') -for VERSION in "${VSMAC_VERSIONS[@]}"; do - install_vsmac $VERSION $DEFAULT_VSMAC_VERSION +for version in "${vsmac_versions[@]}"; do + install_vsmac $version $default_vsmac_version done invoke_tests "Common" "VSMac" diff --git a/images/macos/scripts/build/install-xamarin.sh b/images/macos/scripts/build/install-xamarin.sh index 5eda10416..33ba01281 100644 --- a/images/macos/scripts/build/install-xamarin.sh +++ b/images/macos/scripts/build/install-xamarin.sh @@ -7,16 +7,16 @@ source ~/utils/utils.sh source ~/utils/xamarin-utils.sh -MONO_VERSIONS=($(get_toolset_value '.xamarin."mono_versions" | reverse | .[]')) -XAMARIN_IOS_VERSIONS=($(get_toolset_value '.xamarin."ios_versions" | reverse | .[]')) -XAMARIN_MAC_VERSIONS=($(get_toolset_value '.xamarin."mac_versions" | reverse | .[]')) -XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android_versions" | reverse | .[]')) -LATEST_SDK_SYMLINK=$(get_toolset_value '.xamarin.bundles[0].symlink') -CURRENT_SDK_SYMLINK=$(get_toolset_value '.xamarin."bundle_default"') -DEFAULT_XCODE_VERSION=$(get_toolset_value '.xcode.default') +mono_versions=($(get_toolset_value '.xamarin."mono_versions" | reverse | .[]')) +xamarin_ios_versions=($(get_toolset_value '.xamarin."ios_versions" | reverse | .[]')) +xamarin_mac_versions=($(get_toolset_value '.xamarin."mac_versions" | reverse | .[]')) +xamarin_android_versions=($(get_toolset_value '.xamarin."android_versions" | reverse | .[]')) +latest_sdk_symlink=$(get_toolset_value '.xamarin.bundles[0].symlink') +current_sdk_symlink=$(get_toolset_value '.xamarin."bundle_default"') +default_xcode_version=$(get_toolset_value '.xcode.default') -if [ "$CURRENT_SDK_SYMLINK" == "latest" ]; then - CURRENT_SDK_SYMLINK=$LATEST_SDK_SYMLINK +if [ "$current_sdk_symlink" == "latest" ]; then + current_sdk_symlink=$latest_sdk_symlink fi MONO_VERSIONS_PATH='/Library/Frameworks/Mono.framework/Versions' @@ -34,36 +34,36 @@ pushd $TMPMOUNT downloadNUnitConsole # Install Mono sdks -for VERSION in "${MONO_VERSIONS[@]}"; do installMono $VERSION; done +for version in "${mono_versions[@]}"; do installMono $version; done sudo mv -v $TMPMOUNT_FRAMEWORKS/mono/* $MONO_VERSIONS_PATH/ # Install Xamarin.iOS sdks -for VERSION in "${XAMARIN_IOS_VERSIONS[@]}"; do installXamarinIOS $VERSION; done +for version in "${xamarin_ios_versions[@]}"; do installXamarinIOS $version; done sudo mv -v $TMPMOUNT_FRAMEWORKS/ios/* $IOS_VERSIONS_PATH/ # Install Xamarin.Mac sdks -for VERSION in "${XAMARIN_MAC_VERSIONS[@]}"; do installXamarinMac $VERSION; done +for version in "${xamarin_mac_versions[@]}"; do installXamarinMac $version; done sudo mv -v $TMPMOUNT_FRAMEWORKS/mac/* $MAC_VERSIONS_PATH/ # Install Xamarin.Android sdks -for VERSION in "${XAMARIN_ANDROID_VERSIONS[@]}"; do installXamarinAndroid $VERSION; done +for version in "${xamarin_android_versions[@]}"; do installXamarinAndroid $version; done sudo mv -v $TMPMOUNT_FRAMEWORKS/android/* $ANDROID_VERSIONS_PATH/ # Create bundles -BUNDLES_COUNT=$(get_toolset_value '.xamarin.bundles | length') -for ((BUNDLE_INDEX=0; BUNDLE_INDEX/tmp/get_github_package_download_url.json && failed=false || sleep 60 - [ "$failed" = false ] && break - done + [ -n "$api_pat" ] && authString=(-H "Authorization: token ${api_pat}") - if [ "$failed" = true ]; then - echo "Failed: get_github_package_download_url" - exit 1; - fi + json=$(curl "${authString[@]}" -fsSL "https://api.github.com/repos/${repo}/releases?per_page=${page_size}") - json=$(cat /tmp/get_github_package_download_url.json) - - if [[ "$VERSION" == "latest" ]]; then - tagName=$(echo $json | jq -r '.[] | select((.prerelease==false) and (.assets | length > 0)).tag_name' | sort --unique --version-sort | egrep -v ".*-[a-z]" | tail -1) + if [[ $version == "latest" ]]; then + tag_name=$(echo $json | jq -r '.[].tag_name' | sort --unique --version-sort | egrep -v ".*-[a-z]|beta" | tail -n 1) + elif [[ $version == *"*"* ]]; then + tag_name=$(echo $json | jq -r '.[].tag_name' | sort --unique --version-sort | egrep -v ".*-[a-z]|beta" | egrep "${version}" | tail -n 1) else - tagName=$(echo $json | jq -r '.[] | select(.prerelease==false).tag_name' | sort --unique --version-sort | egrep -v ".*-[a-z]" | egrep "\w*${VERSION}" | tail -1) + tag_name=$(echo $json | jq -r '.[].tag_name' | sort --unique --version-sort | egrep -v ".*-[a-z]|beta" | egrep "${version}") fi - downloadUrl=$(echo $json | jq -r ".[] | select(.tag_name==\"${tagName}\").assets[].browser_download_url | select(${FILTER})" | head -n 1) - if [ -z "$downloadUrl" ]; then - echo "Failed to parse a download url for the '${tagName}' tag using '${FILTER}' filter" + download_url=$(echo $json | jq -r ".[] | select(.tag_name==\"${tag_name}\").assets[].browser_download_url | select(${filter})" | head -n 1) + if [ -z "$download_url" ]; then + echo "Failed to parse a download url for the '${tag_name}' tag using '${filter}' filter" exit 1 fi - echo $downloadUrl + + echo $download_url } # Close all finder windows because they can interfere with UI tests diff --git a/images/macos/scripts/tests/Rosetta.Tests.ps1 b/images/macos/scripts/tests/Rosetta.Tests.ps1 new file mode 100644 index 000000000..e65f22e32 --- /dev/null +++ b/images/macos/scripts/tests/Rosetta.Tests.ps1 @@ -0,0 +1,11 @@ +Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" + +$os = Get-OSVersion + +Describe "Rosetta" -Skip:(-not $os.IsArm64) { + It "Rosetta is available" { + $commandResult = Get-CommandResult "/usr/bin/pgrep oahd" + $commandResult.Output | Should -Match "\d+" + $commandResult.ExitCode | Should -Be 0 + } +} diff --git a/images/macos/templates/macOS-13.arm64.anka.pkr.hcl b/images/macos/templates/macOS-13.arm64.anka.pkr.hcl index 1ab3ffc0c..98a2118eb 100644 --- a/images/macos/templates/macOS-13.arm64.anka.pkr.hcl +++ b/images/macos/templates/macOS-13.arm64.anka.pkr.hcl @@ -131,8 +131,7 @@ build { provisioner "shell" { scripts = [ "./scripts/build/install-xcode-clt.sh", - "./scripts/build/install-homebrew.sh", - "./scripts/build/install-rosetta.sh" + "./scripts/build/install-homebrew.sh" ] execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" } @@ -170,6 +169,7 @@ build { provisioner "shell" { pause_before = "30s" scripts = [ + "./scripts/build/install-rosetta.sh", "./scripts/build/configure-windows.sh", "./scripts/build/install-powershell.sh", "./scripts/build/install-mono.sh",