diff --git a/images/macos/assets/bootstrap-provisioner/setAutoLogin.sh b/images/macos/assets/bootstrap-provisioner/setAutoLogin.sh index e2880e157..17a9d4de2 100644 --- a/images/macos/assets/bootstrap-provisioner/setAutoLogin.sh +++ b/images/macos/assets/bootstrap-provisioner/setAutoLogin.sh @@ -11,7 +11,7 @@ LICENSE_BLOCK USERNAME="${1}" PW="${2}" -function kcpasswordEncode { +kcpasswordEncode() { #ascii string local thisString="${1}" local i diff --git a/images/macos/assets/xamarin-selector/select-xamarin-sdk-v2.sh b/images/macos/assets/xamarin-selector/select-xamarin-sdk-v2.sh index 0e6b08187..153b52e88 100644 --- a/images/macos/assets/xamarin-selector/select-xamarin-sdk-v2.sh +++ b/images/macos/assets/xamarin-selector/select-xamarin-sdk-v2.sh @@ -23,7 +23,7 @@ change_framework_version() { echo "Select $framework $version" local countDigit=$(echo "${version}" | grep -o "\." | grep -c "\.") - + if [[ countDigit -gt 1 ]]; then echo "[WARNING] It is not recommended to specify the exact framework version because your build can be broken with the next patch update. Consider using "major.minor" only format." fi @@ -31,7 +31,7 @@ change_framework_version() { local framework_path=$(get_framework_path "$framework") if [ -d "${framework_path}/${version}" ]; then - sudo rm -f "${framework_path}/Current" + sudo rm -f ${framework_path}/Current sudo ln -s "${framework_path}/${version}" "${framework_path}/Current" else echo "Invalid framework version ${framework_path}/${version}" @@ -46,7 +46,7 @@ for arg in "$@"; do case $key in --mono | --ios | --android | --mac) change_framework_version $key $value ;; *) - echo "Invalid parameter <${key}>" + echo "Invalid parameter <${key}>" exit 1 ;; esac diff --git a/images/macos/scripts/build/configure-hostname.sh b/images/macos/scripts/build/configure-hostname.sh index 40c9f51e4..7b44557ec 100644 --- a/images/macos/scripts/build/configure-hostname.sh +++ b/images/macos/scripts/build/configure-hostname.sh @@ -14,7 +14,7 @@ scutil --set LocalHostName $name scutil --set ComputerName "${name}.local" EOF -chmod +x "/usr/local/bin/change_hostname.sh" +chmod +x /usr/local/bin/change_hostname.sh sudo tee -a /Library/LaunchDaemons/change_hostname.plist > /dev/null <<\EOF diff --git a/images/macos/scripts/build/configure-machine.sh b/images/macos/scripts/build/configure-machine.sh index 11488e76a..294935000 100644 --- a/images/macos/scripts/build/configure-machine.sh +++ b/images/macos/scripts/build/configure-machine.sh @@ -22,7 +22,7 @@ if is_Veertu; then fi # Change screen resolution to the maximum supported for 4Mb video memory -if [ -d "/Library/Application Support/VMware Tools" ]; then +if [[ -d "/Library/Application Support/VMware Tools" ]]; then sudo "/Library/Application Support/VMware Tools/vmware-resolutionSet" 1176 885 fi @@ -60,7 +60,7 @@ rm -f ./add-certificate # enable-automationmode-without-authentication if ! is_BigSur; then retry=10 -while [ $retry -gt 0 ]; do +while [[ $retry -gt 0 ]]; do { osascript < "${Launch_Daemons}/limit.maxfiles.plist" << EOF +cat > ${Launch_Daemons}/limit.maxfiles.plist << EOF @@ -28,17 +28,17 @@ EOF # Creating script for applying workaround https://developer.apple.com/forums/thread/735798 -cat > "/Users/runner/limit-maxfiles.sh" << EOF +cat > /Users/runner/limit-maxfiles.sh << EOF #!/bin/bash sudo launchctl limit maxfiles 256 unlimited sudo launchctl limit maxfiles 65536 524288 EOF echo "limit.maxfiles.sh permissions changing" -chmod +x "/Users/runner/limit-maxfiles.sh" +chmod +x /Users/runner/limit-maxfiles.sh echo "limit.maxfiles.plist permissions changing" chown root:wheel "${Launch_Daemons}/limit.maxfiles.plist" -chmod 0644 "${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 87808eba5..1a09bc2c6 100644 --- a/images/macos/scripts/build/configure-network-interface-detection.sh +++ b/images/macos/scripts/build/configure-network-interface-detection.sh @@ -7,7 +7,7 @@ ################################################################################ PLIST=/Library/LaunchDaemons/sonoma.detectnewhardware.plist -cat < "${PLIST}" +cat < ${PLIST} @@ -27,8 +27,8 @@ EOF # These should be already set as follows, but since they're required # in order to load properly, we set them explicitly. -/bin/chmod 644 "${PLIST}" -/usr/sbin/chown root:wheel "${PLIST}" +/bin/chmod 644 ${PLIST} +/usr/sbin/chown root:wheel ${PLIST} : ' The MIT License (MIT) diff --git a/images/macos/scripts/build/configure-ntpconf.sh b/images/macos/scripts/build/configure-ntpconf.sh index cdb6f3d14..e629c6172 100644 --- a/images/macos/scripts/build/configure-ntpconf.sh +++ b/images/macos/scripts/build/configure-ntpconf.sh @@ -15,5 +15,5 @@ server time.windows.com EOF # Set the timezone to UTC. -echo The Timezone setting to UTC... +echo "The Timezone setting to UTC..." ln -sf /usr/share/zoneinfo/UTC /etc/localtime diff --git a/images/macos/scripts/build/configure-screensaver.sh b/images/macos/scripts/build/configure-screensaver.sh index 6b4900cc9..687302880 100644 --- a/images/macos/scripts/build/configure-screensaver.sh +++ b/images/macos/scripts/build/configure-screensaver.sh @@ -5,7 +5,7 @@ ################################################################################ # set screensaver idleTime to 0, to prevent turning screensaver on -macUUID=`ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-62` +macUUID=$(ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-62) rm -rf /Users/$USERNAME/Library/Preferences/com.apple.screensaver.$macUUID.plist rm -rf /Users/$USERNAME/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist diff --git a/images/macos/scripts/build/configure-windows.sh b/images/macos/scripts/build/configure-windows.sh index 92cb9aa98..72cb4c8ac 100644 --- a/images/macos/scripts/build/configure-windows.sh +++ b/images/macos/scripts/build/configure-windows.sh @@ -22,13 +22,13 @@ while [[ $retry -gt 0 ]]; do fi sleep 30 done -IFS=',' read -r -a windowslist <<< "$openwindows" +IFS=',' read -r -a windowslist <<< $openwindows -if [ -n "${openwindows}" ]; then +if [[ -n ${openwindows} ]]; then echo "Found opened window:" fi -for window in "${windowslist[@]}"; do +for window in ${windowslist[@]}; do if [[ $window =~ "NotificationCenter" ]]; then echo "[Warning] $window" else @@ -37,6 +37,6 @@ for window in "${windowslist[@]}"; do fi done -if [ "${scripterror}" = true ]; then +if [[ ${scripterror} = true ]]; then exit 1 fi diff --git a/images/macos/scripts/build/configure-xcode-symlinks.sh b/images/macos/scripts/build/configure-xcode-symlinks.sh deleted file mode 100644 index 1fbfe7ed8..000000000 --- a/images/macos/scripts/build/configure-xcode-symlinks.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -e -o pipefail -################################################################################ -## File: configure-xcode-symlinks.sh -## Desc: Link the existing Xcodes into the correct location for provisionator. -## This is maintained for backwards compatibility only. Do not add new xcodes here. -################################################################################ - -source ~/utils/utils.sh - -ln -sf /Applications/Xcode_8.app /Applications/Xcode8.app -ln -sf /Applications/Xcode_8.1.app /Applications/Xcode81.app -ln -sf /Applications/Xcode_9.app /Applications/Xcode9.app -ln -sf /Applications/Xcode_9.1.app /Applications/Xcode91.app -ln -sf /Applications/Xcode_9.2.app /Applications/Xcode92.app -ln -sf /Applications/Xcode_9.3.app /Applications/Xcode93.app -ln -sf /Applications/Xcode_9.3.app /Applications/Xcode_9.3_beta.app -ln -sf /Applications/Xcode_9.4.app /Applications/Xcode_9.4-beta.app -ln -sf /Applications/Xcode_9.4.app /Applications/Xcode_9.4_beta.app -ln -sf /Applications/Xcode_9.4.app /Applications/Xcode_9.4_beta_2.app diff --git a/images/macos/scripts/build/configure-xcode.sh b/images/macos/scripts/build/configure-xcode.sh index bde270381..f707679e7 100644 --- a/images/macos/scripts/build/configure-xcode.sh +++ b/images/macos/scripts/build/configure-xcode.sh @@ -13,15 +13,14 @@ DEFAULT_XCODE_VERSION=$(get_toolset_value '.xcode.default') # Assets.xcassets : error : CoreData: error: (6922) I/O error for database # at $HOME/Library/Developer/Xcode/UserData/IB Support/Simulator Devices/{GUID} echo "Erase a device's contents and settings:" -for XCODE_VERSION in "${XCODE_LIST[@]}" -do +for XCODE_VERSION in ${XCODE_LIST[@]}; do echo " Xcode Version: ${XCODE_VERSION}" launchctl remove com.apple.CoreSimulator.CoreSimulatorService || true #add sleep to let CoreSimulatorService to exit sleep 3 # Select xcode version by default - sudo xcode-select -s "/Applications/Xcode_${XCODE_VERSION}.app/Contents/Developer" + sudo xcode-select -s /Applications/Xcode_${XCODE_VERSION}.app/Contents/Developer # Erase a device's contents and settings xcrun simctl erase all @@ -32,4 +31,4 @@ done # Select xcode version by default echo "Setting Xcode ${DEFAULT_XCODE_VERSION} as default" -sudo xcode-select -s "/Applications/Xcode_${DEFAULT_XCODE_VERSION}.app/Contents/Developer" +sudo xcode-select -s /Applications/Xcode_${DEFAULT_XCODE_VERSION}.app/Contents/Developer diff --git a/images/macos/scripts/build/install-actions-cache.sh b/images/macos/scripts/build/install-actions-cache.sh index 4871bf86a..4fbebe3d8 100644 --- a/images/macos/scripts/build/install-actions-cache.sh +++ b/images/macos/scripts/build/install-actions-cache.sh @@ -8,13 +8,13 @@ source ~/utils/utils.sh echo "Check if ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE folder exist..." -if [ ! -d $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE ]; then +if [[ ! -d $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE ]]; then mkdir -p $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE fi 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" +archive_path=$(download_with_retry $download_url) +tar -xzf $archive_path -C $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE invoke_tests "ActionArchiveCache" diff --git a/images/macos/scripts/build/install-android-sdk.sh b/images/macos/scripts/build/install-android-sdk.sh index 86eee8a7e..204a2db82 100644 --- a/images/macos/scripts/build/install-android-sdk.sh +++ b/images/macos/scripts/build/install-android-sdk.sh @@ -6,39 +6,37 @@ source ~/utils/utils.sh -function filter_components_by_version { - minimumVersion=$1 +add_filtered_instalaltion_components() { + local minimum_version=$1 shift - toolsArr=("$@") + local tools_array=("$@") - for item in ${toolsArr[@]} - do + for item in ${tools_array[@]}; do # take the last argument after spliting string by ';'' and '-'' version=$(echo "${item##*[-;]}") - if verlte $minimumVersion $version - then + if [[ "$(printf "${minimum_version}\n${version}\n" | sort -V | head -n1)" == "$minimum_version" ]]; then components+=($item) fi done } -function get_full_ndk_version { - majorVersion=$1 - ndkVersion=$(${SDKMANAGER} --list | grep "ndk;${majorVersion}.*" | awk '{gsub("ndk;", ""); print $1}' | sort -V | tail -n1) +get_full_ndk_version() { + local majorVersion=$1 + ndkVersion=$(${SDKMANAGER} --list | grep "ndk;${majorVersion}.*" | awk '{gsub("ndk;", ""); print $1}' | sort -V | tail -n1) echo "$ndkVersion" } components=() -ANDROID_PLATFORM=$(get_toolset_value '.android.platform_min_version') -ANDROID_BUILD_TOOL=$(get_toolset_value '.android.build_tools_min_version') -ANDROID_EXTRA_LIST=($(get_toolset_value '.android."extras"[]')) -ANDROID_ADDON_LIST=($(get_toolset_value '.android."addons"[]')) -ANDROID_ADDITIONAL_TOOLS=($(get_toolset_value '.android."additional_tools"[]')) -ANDROID_NDK_MAJOR_VERSIONS=($(get_toolset_value '.android.ndk."versions"[]')) -ANDROID_NDK_MAJOR_DEFAULT=$(get_toolset_value '.android.ndk.default') -ANDROID_NDK_MAJOR_LATEST=$(get_toolset_value '.android.ndk."versions"[-1]') +android_platform=$(get_toolset_value '.android.platform_min_version') +android_build_tool=$(get_toolset_value '.android.build_tools_min_version') +android_extra_list=($(get_toolset_value '.android."extras"[]')) +android_addon_list=($(get_toolset_value '.android."addons"[]')) +android_additional_tools=($(get_toolset_value '.android."additional_tools"[]')) +android_ndk_major_versions=($(get_toolset_value '.android.ndk."versions"[]')) +android_ndk_major_default=$(get_toolset_value '.android.ndk.default') +android_ndk_major_latest=$(get_toolset_value '.android.ndk."versions"[-1]') # Get the latest command line tools from https://developer.android.com/studio#cmdline-tools # Newer version(s) require Java 11 by default # See https://github.com/actions/runner-images/issues/6960 @@ -81,15 +79,15 @@ echo "Installing latest tools & platform tools..." echo y | $SDKMANAGER "tools" "platform-tools" echo "Installing latest ndk..." -for ndk_version in "${ANDROID_NDK_MAJOR_VERSIONS[@]}" +for ndk_version in "${android_ndk_major_versions[@]}" do ndk_full_version=$(get_full_ndk_version $ndk_version) echo y | $SDKMANAGER "ndk;$ndk_full_version" done -ndkDefault=$(get_full_ndk_version $ANDROID_NDK_MAJOR_DEFAULT) +ndkDefault=$(get_full_ndk_version $android_ndk_major_default) ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$ndkDefault -ndkLatest=$(get_full_ndk_version $ANDROID_NDK_MAJOR_LATEST) +ndkLatest=$(get_full_ndk_version $android_ndk_major_latest) ANDROID_NDK_LATEST_HOME=$ANDROID_HOME/ndk/$ndkLatest # ANDROID_NDK, ANDROID_NDK_HOME, and ANDROID_NDK_ROOT variables should be set as many customer builds depend on them https://github.com/actions/runner-images/issues/5879 echo "export ANDROID_NDK=$ANDROID_NDK_HOME" >> "${HOME}/.bashrc" @@ -98,27 +96,27 @@ echo "export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME" >> "${HOME}/.bashrc" echo "export ANDROID_NDK_LATEST_HOME=$ANDROID_NDK_LATEST_HOME" >> "${HOME}/.bashrc" availablePlatforms=($($SDKMANAGER --list | grep "platforms;android-[0-9]" | cut -d"|" -f 1 | sort -u)) -filter_components_by_version $ANDROID_PLATFORM "${availablePlatforms[@]}" +add_filtered_instalaltion_components $android_platform "${availablePlatforms[@]}" allBuildTools=($($SDKMANAGER --list --include_obsolete | grep "build-tools;" | cut -d"|" -f 1 | sort -u)) availableBuildTools=$(echo ${allBuildTools[@]//*rc[0-9]/}) -filter_components_by_version $ANDROID_BUILD_TOOL "${availableBuildTools[@]}" +add_filtered_instalaltion_components $android_build_tool "${availableBuildTools[@]}" echo "y" | $SDKMANAGER ${components[@]} -for extra_name in "${ANDROID_EXTRA_LIST[@]}" +for extra_name in "${android_extra_list[@]}" do echo "Installing extra $extra_name ..." echo y | $SDKMANAGER "extras;$extra_name" done -for addon_name in "${ANDROID_ADDON_LIST[@]}" +for addon_name in "${android_addon_list[@]}" do echo "Installing add-on $addon_name ..." echo y | $SDKMANAGER "add-ons;$addon_name" done -for tool_name in "${ANDROID_ADDITIONAL_TOOLS[@]}" +for tool_name in "${android_additional_tools[@]}" do echo "Installing additional tool $tool_name ..." echo y | $SDKMANAGER "$tool_name" diff --git a/images/macos/scripts/build/install-aws-tools.sh b/images/macos/scripts/build/install-aws-tools.sh index 113881bab..db4565b73 100644 --- a/images/macos/scripts/build/install-aws-tools.sh +++ b/images/macos/scripts/build/install-aws-tools.sh @@ -6,11 +6,11 @@ source ~/utils/utils.sh -echo Installing aws... +echo "Installing aws..." awscliv2_pkg_path=$(download_with_retry "https://awscli.amazonaws.com/AWSCLIV2.pkg") sudo installer -pkg "$awscliv2_pkg_path" -target / -echo Installing aws sam cli... +echo "Installing aws sam cli..." brew tap aws/tap brew_smart_install aws-sam-cli diff --git a/images/macos/scripts/build/install-azcopy.sh b/images/macos/scripts/build/install-azcopy.sh index e0e95d9d9..39df17a7d 100644 --- a/images/macos/scripts/build/install-azcopy.sh +++ b/images/macos/scripts/build/install-azcopy.sh @@ -15,11 +15,11 @@ else fi # Install AzCopy -archive_path=$(download_with_retry "${url}") -unzip -qq "$archive_path" -d /tmp/azcopy +archive_path=$(download_with_retry ${url}) +unzip -qq $archive_path -d /tmp/azcopy extract_path=$(echo /tmp/azcopy/azcopy*) -cp "$extract_path/azcopy" "/usr/local/bin/azcopy" -chmod +x "/usr/local/bin/azcopy" +cp $extract_path/azcopy /usr/local/bin/azcopy +chmod +x /usr/local/bin/azcopy invoke_tests "Common" "AzCopy" diff --git a/images/macos/scripts/build/install-bicep.sh b/images/macos/scripts/build/install-bicep.sh index fbae13e59..6a5a3ddb2 100644 --- a/images/macos/scripts/build/install-bicep.sh +++ b/images/macos/scripts/build/install-bicep.sh @@ -6,7 +6,7 @@ source ~/utils/utils.sh -echo Installing bicep cli... +echo "Installing bicep cli..." brew tap azure/bicep brew_smart_install bicep diff --git a/images/macos/scripts/build/install-chrome.sh b/images/macos/scripts/build/install-chrome.sh index ace3ee728..709e1eaf3 100644 --- a/images/macos/scripts/build/install-chrome.sh +++ b/images/macos/scripts/build/install-chrome.sh @@ -19,32 +19,32 @@ echo "Google Chrome version is $full_chrome_version" # Get Google Chrome versions information 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') +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_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') +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_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-codeql-bundle.sh b/images/macos/scripts/build/install-codeql-bundle.sh index 68fed2634..ca05d231d 100644 --- a/images/macos/scripts/build/install-codeql-bundle.sh +++ b/images/macos/scripts/build/install-codeql-bundle.sh @@ -8,7 +8,7 @@ source ~/utils/utils.sh # Retrieve the CLI version of the latest CodeQL bundle. defaults_json_path=$(download_with_retry https://raw.githubusercontent.com/github/codeql-action/v2/src/defaults.json) -bundle_version="$(jq -r '.cliVersion' "$defaults_json_path")" +bundle_version=$(jq -r '.cliVersion' $defaults_json_path) bundle_tag_name="codeql-bundle-v$bundle_version" echo "Downloading CodeQL bundle $bundle_version..." @@ -16,17 +16,17 @@ echo "Downloading CodeQL bundle $bundle_version..." # different operating systems within containers. archive_path=$(download_with_retry "https://github.com/github/codeql-action/releases/download/$bundle_tag_name/codeql-bundle.tar.gz") -codeql_toolcache_path="$AGENT_TOOLSDIRECTORY/CodeQL/$bundle_version/x64" -mkdir -p "$codeql_toolcache_path" +codeql_toolcache_path=$AGENT_TOOLSDIRECTORY/CodeQL/$bundle_version/x64 +mkdir -p $codeql_toolcache_path echo "Unpacking the downloaded CodeQL bundle archive..." -tar -xzf "$archive_path" -C "$codeql_toolcache_path" +tar -xzf $archive_path -C $codeql_toolcache_path # Touch a file to indicate to the CodeQL Action that this bundle shipped with the toolcache. This is # to support overriding the CodeQL version specified in defaults.json on GitHub Enterprise. -touch "$codeql_toolcache_path/pinned-version" +touch $codeql_toolcache_path/pinned-version # Touch a file to indicate to the toolcache that setting up CodeQL is complete. -touch "$codeql_toolcache_path.complete" +touch $codeql_toolcache_path.complete invoke_tests "Common" "CodeQL Bundle" diff --git a/images/macos/scripts/build/install-common-utils.sh b/images/macos/scripts/build/install-common-utils.sh index a414637a7..f031bd67b 100644 --- a/images/macos/scripts/build/install-common-utils.sh +++ b/images/macos/scripts/build/install-common-utils.sh @@ -28,9 +28,9 @@ for package in $cask_packages; do # Do not update VirtualBox on macOS 12 due to the issue with VMs in gurumediation state which blocks Vagrant on macOS: https://github.com/actions/runner-images/issues/8730 # macOS host: Dropped all kernel extensions. VirtualBox relies fully on the hypervisor and vmnet frameworks provided by Apple now. virtualbox_cask_path=$(download_with_retry "https://raw.githubusercontent.com/Homebrew/homebrew-cask/aa3c55951fc9d687acce43e5c0338f42c1ddff7b/Casks/virtualbox.rb") - brew install "$virtualbox_cask_path" + brew install $virtualbox_cask_path else - brew install --cask "$package" + brew install --cask $package fi done @@ -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,23 +75,20 @@ 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 - echo "export PARALLELS_DMG_URL=$url" >> "${HOME}/.bashrc" + echo "export PARALLELS_DMG_URL=$url" >> ${HOME}/.bashrc fi -# Invoke bazel to download bazel version via bazelisk -bazel - # Install Azure DevOps extension for Azure Command Line Interface az extension add -n azure-devops diff --git a/images/macos/scripts/build/install-dotnet.sh b/images/macos/scripts/build/install-dotnet.sh index 0bc0feb08..212c40419 100644 --- a/images/macos/scripts/build/install-dotnet.sh +++ b/images/macos/scripts/build/install-dotnet.sh @@ -13,32 +13,32 @@ arch=$(get_arch) # Download installer from dot.net and keep it locally DOTNET_INSTALL_SCRIPT="https://dot.net/v1/dotnet-install.sh" install_script_path=$(download_with_retry $DOTNET_INSTALL_SCRIPT) -chmod +x "$install_script_path" +chmod +x $install_script_path args_list=() echo "Parsing dotnet SDK (except rc and preview versions) from .json..." dotnet_versions=($(get_toolset_value ".dotnet.arch[\"$arch\"].versions | .[]")) -for dotnet_version in "${dotnet_versions[@]}"; do +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+=( - $(cat "$releases_json_file" | jq -r 'first(.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not))') + $(cat $releases_json_file | jq -r 'first(.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not))') ) else args_list+=( - $(cat "$releases_json_file" | \ + $(cat $releases_json_file | \ jq -r '.releases[].sdk."version"' | grep -v -E '\-(preview|rc)\d*' | \ sort -r | rev | uniq -s 2 | rev) ) fi done -for ARGS in "${args_list[@]}"; do - "$install_script_path" --version $ARGS -NoPath --arch $arch +for ARGS in ${args_list[@]}; do + $install_script_path --version $ARGS -NoPath --arch $arch done # dotnet installer doesn't create symlink to executable in /user/local/bin @@ -46,12 +46,12 @@ done ln -s ~/.dotnet/dotnet /usr/local/bin/dotnet # Validate installation -if [ $(dotnet --list-sdks | wc -l) -lt "1" ]; then +if [[ $(dotnet --list-sdks | wc -l) -lt "1" ]]; then echo "The .NET Core SDK is not installed" exit 1 fi -echo 'export PATH="$PATH:$HOME/.dotnet/tools"' >> "$HOME/.bashrc" +echo 'export PATH="$PATH:$HOME/.dotnet/tools"' >> $HOME/.bashrc echo "Dotnet operations have been completed successfully..." invoke_tests "Common" ".NET" diff --git a/images/macos/scripts/build/install-edge.sh b/images/macos/scripts/build/install-edge.sh index 5146e202b..c42378734 100644 --- a/images/macos/scripts/build/install-edge.sh +++ b/images/macos/scripts/build/install-edge.sh @@ -30,10 +30,10 @@ edge_driver_archive_path=$(download_with_retry "$edge_driver_url") EDGE_DRIVER_DIR="/usr/local/share/edge_driver" mkdir -p $EDGE_DRIVER_DIR -unzip -qq "$edge_driver_archive_path" -d "$EDGE_DRIVER_DIR" -ln -s "$EDGE_DRIVER_DIR/msedgedriver" "/usr/local/bin/msedgedriver" +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" +echo "export EDGEWEBDRIVER=${EDGE_DRIVER_DIR}" >> ${HOME}/.bashrc # Configure Edge Updater to prevent auto update # https://learn.microsoft.com/en-us/deployedge/edge-learnmore-edgeupdater-for-macos diff --git a/images/macos/scripts/build/install-firefox.sh b/images/macos/scripts/build/install-firefox.sh index 75c4f6ccb..c20e25359 100644 --- a/images/macos/scripts/build/install-firefox.sh +++ b/images/macos/scripts/build/install-firefox.sh @@ -14,6 +14,6 @@ brew_smart_install "geckodriver" geckoPath="$(brew --prefix geckodriver)/bin" echo "Add GECKOWEBDRIVER to bashrc..." -echo "export GECKOWEBDRIVER=${geckoPath}" >> "${HOME}/.bashrc" +echo "export GECKOWEBDRIVER=${geckoPath}" >> ${HOME}/.bashrc invoke_tests "Browsers" "Firefox" diff --git a/images/macos/scripts/build/install-gcc.sh b/images/macos/scripts/build/install-gcc.sh index 07155b607..9647d56d4 100644 --- a/images/macos/scripts/build/install-gcc.sh +++ b/images/macos/scripts/build/install-gcc.sh @@ -14,7 +14,7 @@ done # Delete default gfortran link if it exists https://github.com/actions/runner-images/issues/1280 gfortranPath=$(which gfortran) || true -if [ $gfortranPath ]; then +if [[ $gfortranPath ]]; then rm $gfortranPath fi diff --git a/images/macos/scripts/build/install-git.sh b/images/macos/scripts/build/install-git.sh index fedc7d680..adc3ecccf 100644 --- a/images/macos/scripts/build/install-git.sh +++ b/images/macos/scripts/build/install-git.sh @@ -6,12 +6,12 @@ source ~/utils/utils.sh -echo Installing Git... +echo "Installing Git..." brew_smart_install "git" git config --global --add safe.directory "*" -echo Installing Git LFS +echo "Installing Git LFS" brew_smart_install "git-lfs" # Update global git config @@ -19,7 +19,7 @@ git lfs install # Update system git config sudo git lfs install --system -echo Disable all the Git help messages... +echo "Disable all the Git help messages..." git config --global advice.pushUpdateRejected false git config --global advice.pushNonFFCurrent false git config --global advice.pushNonFFMatching false diff --git a/images/macos/scripts/build/install-haskell.sh b/images/macos/scripts/build/install-haskell.sh index 982db5877..d88bf616e 100644 --- a/images/macos/scripts/build/install-haskell.sh +++ b/images/macos/scripts/build/install-haskell.sh @@ -6,9 +6,9 @@ source ~/utils/utils.sh -curl --proto '=https' --tlsv1.2 -fsSL https://get-ghcup.haskell.org | sh +curl --proto '=https' --tlsv1.2 -fsSL https://get-ghcup.haskell.org | bash export PATH="$HOME/.ghcup/bin:$PATH" -echo 'export PATH="$PATH:$HOME/.ghcup/bin"' >> "$HOME/.bashrc" +echo 'export PATH="$PATH:$HOME/.ghcup/bin"' >> $HOME/.bashrc # ghcup output looks like this "ghc 8.6.4 base-4.12.0.0 hls-powered", need to take all the first versions only(8.6.4 in that case) and avoid pre-release ones availableVersions=$(ghcup list -t ghc -r | grep -v "prerelease" | awk '{print $2}') diff --git a/images/macos/scripts/build/install-homebrew.sh b/images/macos/scripts/build/install-homebrew.sh index cb32793d9..4a72cf2e6 100644 --- a/images/macos/scripts/build/install-homebrew.sh +++ b/images/macos/scripts/build/install-homebrew.sh @@ -10,7 +10,7 @@ arch=$(get_arch) echo "Installing Homebrew..." homebrew_installer_path=$(download_with_retry "https://raw.githubusercontent.com/Homebrew/install/master/install.sh") -/bin/bash "$homebrew_installer_path" +/bin/bash $homebrew_installer_path if [[ $arch == "arm64" ]]; then /opt/homebrew/bin/brew update diff --git a/images/macos/scripts/build/install-miniconda.sh b/images/macos/scripts/build/install-miniconda.sh index 2ee589580..7d9ea2fe1 100644 --- a/images/macos/scripts/build/install-miniconda.sh +++ b/images/macos/scripts/build/install-miniconda.sh @@ -7,16 +7,16 @@ source ~/utils/utils.sh miniconda_installer_path=$(download_with_retry "https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh") -chmod +x "$miniconda_installer_path" -sudo "$miniconda_installer_path" -b -p /usr/local/miniconda +chmod +x $miniconda_installer_path +sudo $miniconda_installer_path -b -p /usr/local/miniconda # Chmod with full permissions recursively to avoid permissions restrictions sudo chmod -R 777 /usr/local/miniconda sudo ln -s /usr/local/miniconda/bin/conda /usr/local/bin/conda -if [ -d "$HOME/.conda" ]; then - sudo chown -R $USER "$HOME/.conda" +if [[ -d $HOME/.conda ]]; then + sudo chown -R $USER $HOME/.conda fi echo "export CONDA=/usr/local/miniconda" >> $HOME/.bashrc diff --git a/images/macos/scripts/build/install-mongodb.sh b/images/macos/scripts/build/install-mongodb.sh index 092d71535..c603d3892 100644 --- a/images/macos/scripts/build/install-mongodb.sh +++ b/images/macos/scripts/build/install-mongodb.sh @@ -14,10 +14,10 @@ toolsetVersion=$(get_toolset_value '.mongodb.version') brew tap mongodb/brew versionToInstall=$(brew search --formulae /mongodb-community@$toolsetVersion/ | awk -F'/' '{print $3}' | tail -1) echo "Installing mongodb $versionToInstall" -brew_smart_install "$versionToInstall" +brew_smart_install $versionToInstall if ! which mongo ; then - brew link "$versionToInstall" + brew link $versionToInstall fi invoke_tests "Databases" "MongoDB" diff --git a/images/macos/scripts/build/install-mono.sh b/images/macos/scripts/build/install-mono.sh index b5569a419..3ac147f0a 100644 --- a/images/macos/scripts/build/install-mono.sh +++ b/images/macos/scripts/build/install-mono.sh @@ -9,28 +9,28 @@ 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=$(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" +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 / +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_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" +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" +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..." @@ -39,13 +39,13 @@ 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 "\$@" 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}" +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-node.sh b/images/macos/scripts/build/install-node.sh index 60a25d5de..a4c4aaeba 100644 --- a/images/macos/scripts/build/install-node.sh +++ b/images/macos/scripts/build/install-node.sh @@ -14,7 +14,7 @@ brew link node@$defaultVersion --force --overwrite echo Installing yarn... yarn_installer_path=$(download_with_retry "https://yarnpkg.com/install.sh") -bash "$yarn_installer_path" +bash $yarn_installer_path if is_BigSur || is_Monterey; then npm_global_packages=$(get_toolset_value '.npm.global_packages[].name') diff --git a/images/macos/scripts/build/install-nvm.sh b/images/macos/scripts/build/install-nvm.sh index 49948459d..4d475cd1b 100644 --- a/images/macos/scripts/build/install-nvm.sh +++ b/images/macos/scripts/build/install-nvm.sh @@ -6,12 +6,12 @@ source ~/utils/utils.sh -[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}") +[[ -n $API_PAT ]] && authString=(-H "Authorization: token ${API_PAT}") nvm_version=$(curl "${authString[@]}" -fsSL https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r '.tag_name') nvm_installer_path=$(download_with_retry "https://raw.githubusercontent.com/nvm-sh/nvm/$nvm_version/install.sh") -if bash "$nvm_installer_path"; then - . ~/.bashrc +if bash $nvm_installer_path; then + source ~/.bashrc nvm --version for version in $(get_toolset_value '.node.nvm_versions[]'); do nvm install "v${version}" diff --git a/images/macos/scripts/build/install-openjdk.sh b/images/macos/scripts/build/install-openjdk.sh index 6000439f6..6c7ec3633 100644 --- a/images/macos/scripts/build/install-openjdk.sh +++ b/images/macos/scripts/build/install-openjdk.sh @@ -18,15 +18,15 @@ createEnvironmentVariable() { if [[ ${DEFAULT} == "True" ]]; then echo "Setting up JAVA_HOME variable to ${INSTALL_PATH_PATTERN}" - echo "export JAVA_HOME=${INSTALL_PATH_PATTERN}" >> "${HOME}/.bashrc" + echo "export JAVA_HOME=${INSTALL_PATH_PATTERN}" >> ${HOME}/.bashrc fi if [[ $arch == "arm64" ]]; then echo "Setting up JAVA_HOME_${JAVA_VERSION}_arm64 variable to ${INSTALL_PATH_PATTERN}" - echo "export JAVA_HOME_${JAVA_VERSION}_arm64=${INSTALL_PATH_PATTERN}" >> "${HOME}/.bashrc" + echo "export JAVA_HOME_${JAVA_VERSION}_arm64=${INSTALL_PATH_PATTERN}" >> ${HOME}/.bashrc else echo "Setting up JAVA_HOME_${JAVA_VERSION}_X64 variable to ${INSTALL_PATH_PATTERN}" - echo "export JAVA_HOME_${JAVA_VERSION}_X64=${INSTALL_PATH_PATTERN}" >> "${HOME}/.bashrc" + echo "export JAVA_HOME_${JAVA_VERSION}_X64=${INSTALL_PATH_PATTERN}" >> ${HOME}/.bashrc fi } @@ -58,12 +58,12 @@ installOpenJDK() { fi # Download and extract Java binaries - archive_path=$(download_with_retry "$archive_url") + archive_path=$(download_with_retry $archive_url) echo "Creating ${javaToolcacheVersionArchPath} directory" mkdir -p ${javaToolcacheVersionArchPath} - tar -xf "$archive_path" -C ${javaToolcacheVersionArchPath} --strip-components=1 + tar -xf $archive_path -C ${javaToolcacheVersionArchPath} --strip-components=1 # Create complete file if [[ $arch == "arm64" ]]; then diff --git a/images/macos/scripts/build/install-postgresql.sh b/images/macos/scripts/build/install-postgresql.sh index 5f62cc45b..0f28b759e 100644 --- a/images/macos/scripts/build/install-postgresql.sh +++ b/images/macos/scripts/build/install-postgresql.sh @@ -20,11 +20,11 @@ brew services start $postgreService echo "Check PostgreSQL service is running" i=10 COMMAND='pg_isready' -while [ $i -gt 0 ]; do +while [[ $i -gt 0 ]]; do echo "Check PostgreSQL service status" eval $COMMAND && break ((i--)) - if [ $i == 0 ]; then + if [[ $i == 0 ]]; then echo "PostgreSQL service not ready, all attempts exhausted" exit 1 fi diff --git a/images/macos/scripts/build/install-powershell.sh b/images/macos/scripts/build/install-powershell.sh index 557d0f767..d6c2a9fc8 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") pwshVersionToolset=$(get_toolset_value '.pwsh.version') -pwshVersions=$(jq -r '.LTSReleaseTag[]' "$metadata_json_path") +pwshVersions=$(jq -r '.LTSReleaseTag[]' $metadata_json_path) for version in ${pwshVersions[@]}; do if [[ "$version" =~ "$pwshVersionToolset" ]]; then @@ -20,19 +20,19 @@ for version in ${pwshVersions[@]}; do fi done -pkg_path=$(download_with_retry "$download_url") +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 -sudo xattr -rd com.apple.quarantine "$pkg_path" +sudo xattr -rd com.apple.quarantine $pkg_path -sudo installer -pkg "$pkg_path" -target / +sudo installer -pkg $pkg_path -target / # Install PowerShell modules psModules=$(get_toolset_value '.powershellModules[].name') for module in ${psModules[@]}; do echo "Installing $module module" moduleVersions="$(get_toolset_value ".powershellModules[] | select(.name==\"$module\") | .versions[]?")" - if [[ -z "$moduleVersions" ]];then + if [[ -z $moduleVersions ]];then # Check MacOS architecture and sudo on Arm64 if [[ $arch == "arm64" ]]; then sudo pwsh -command "& {Install-Module $module -Force -Scope AllUsers}" diff --git a/images/macos/scripts/build/install-pypy.sh b/images/macos/scripts/build/install-pypy.sh index 5e1900b57..08f4ca70d 100644 --- a/images/macos/scripts/build/install-pypy.sh +++ b/images/macos/scripts/build/install-pypy.sh @@ -6,23 +6,22 @@ source ~/utils/utils.sh -function InstallPyPy -{ - PACKAGE_URL=$1 +InstallPyPy() { + local package_url=$1 - PACKAGE_TAR_NAME=$(basename "$PACKAGE_URL") + PACKAGE_TAR_NAME=$(basename $package_url) echo "Downloading tar archive '$PACKAGE_TAR_NAME'" - archive_path=$(download_with_retry "$PACKAGE_URL") + archive_path=$(download_with_retry $package_url) echo "Expand '$PACKAGE_TAR_NAME' to the /tmp folder" - tar xf "$archive_path" -C /tmp + tar xf $archive_path -C /tmp # Get Python version PACKAGE_NAME=${PACKAGE_TAR_NAME/.tar.bz2/} MAJOR_VERSION=$(echo ${PACKAGE_NAME/pypy/} | cut -d. -f1) PYTHON_MAJOR="python$MAJOR_VERSION" - if [ $MAJOR_VERSION != 2 ]; then + if [[ $MAJOR_VERSION != 2 ]]; then PYPY_MAJOR="pypy$MAJOR_VERSION" else PYPY_MAJOR="pypy" @@ -40,14 +39,14 @@ function InstallPyPy PYPY_TOOLCACHE_VERSION_ARCH_PATH=$PYPY_TOOLCACHE_VERSION_PATH/x64 echo "Check if PyPy hostedtoolcache folder exist..." - if [ ! -d $PYPY_TOOLCACHE_PATH ]; then + if [[ ! -d $PYPY_TOOLCACHE_PATH ]]; then mkdir -p $PYPY_TOOLCACHE_PATH fi echo "Create PyPy '$PYPY_TOOLCACHE_VERSION_PATH' folder" mkdir $PYPY_TOOLCACHE_VERSION_PATH - echo "Move PyPy '$PACKAGE_TEMP_FOLDER' binaries to '$PYPY_TOOLCACHE_VERSION_ARCH_PATH' folder" + echo "Move PyPy $PACKAGE_TEMP_FOLDER binaries to $PYPY_TOOLCACHE_VERSION_ARCH_PATH folder" mv $PACKAGE_TEMP_FOLDER $PYPY_TOOLCACHE_VERSION_ARCH_PATH echo "Create additional symlinks (Required for UsePythonVersion Azure DevOps task)" @@ -58,8 +57,8 @@ function InstallPyPy echo $PYPY_FULL_VERSION > "PYPY_VERSION" # Starting from PyPy 7.3.4 these links are already included in the package - [ -f ./$PYTHON_MAJOR ] || ln -s $PYPY_MAJOR $PYTHON_MAJOR - [ -f ./python ] || ln -s $PYTHON_MAJOR python + [[ -f ./$PYTHON_MAJOR ]] || ln -s $PYPY_MAJOR $PYTHON_MAJOR + [[ -f ./python ]] || ln -s $PYTHON_MAJOR python chmod +x ./python ./$PYTHON_MAJOR @@ -76,12 +75,12 @@ versions_json_path=$(download_with_retry "https://downloads.python.org/pypy/vers toolsetVersions=$(get_toolset_value '.toolcache[] | select(.name | contains("PyPy")) | .arch.'$arch'.versions[]') for toolsetVersion in $toolsetVersions; do - latestMajorPyPyVersion=$(cat "$versions_json_path" | + latestMajorPyPyVersion=$(cat $versions_json_path | jq -r --arg toolsetVersion $toolsetVersion '.[] | select((.python_version | startswith($toolsetVersion)) and .stable == true).files[] | select(.platform == "darwin").download_url' | head -1) - if [[ -z "$latestMajorPyPyVersion" ]]; then - echo "Failed to get PyPy version '$toolsetVersion'" + if [[ -z $latestMajorPyPyVersion ]]; then + echo "Failed to get PyPy version $toolsetVersion" exit 1 fi InstallPyPy $latestMajorPyPyVersion diff --git a/images/macos/scripts/build/install-python.sh b/images/macos/scripts/build/install-python.sh index 91269d19f..3fa93b27a 100644 --- a/images/macos/scripts/build/install-python.sh +++ b/images/macos/scripts/build/install-python.sh @@ -12,19 +12,19 @@ if is_Monterey || is_BigSur; then echo "Install latest Python 2" python2_pkg=$(download_with_retry "https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg") python2_pkg_sha256="c570f38b05dd8b112ad21b418cdf51a9816d62f9f44746452739d421be24d50c" - use_checksum_comparison "$python2_pkg" "$python2_pkg_sha256" + use_checksum_comparison $python2_pkg $python2_pkg_sha256 choice_changes_xml=$(mktemp /tmp/python2_choice_changes.xml.XXXXXX) - sudo installer -showChoiceChangesXML -pkg "$python2_pkg" -target / | tee "$choice_changes_xml" > /dev/null + sudo installer -showChoiceChangesXML -pkg $python2_pkg -target / | tee $choice_changes_xml > /dev/null # To avoid symlink conflicts, remove tools installation in /usr/local/bin using installer choices - xmllint --shell "$choice_changes_xml" <> "${HOME}/.bashrc" -echo "export PIPX_HOME=${PIPX_HOME}" >> "${HOME}/.bashrc" -echo 'export PATH="$PIPX_BIN_DIR:$PATH"' >> "${HOME}/.bashrc" +echo "export PIPX_BIN_DIR=${PIPX_BIN_DIR}" >> ${HOME}/.bashrc +echo "export PIPX_HOME=${PIPX_HOME}" >> ${HOME}/.bashrc +echo 'export PATH="$PIPX_BIN_DIR:$PATH"' >> ${HOME}/.bashrc invoke_tests "Python" diff --git a/images/macos/scripts/build/install-rosetta.sh b/images/macos/scripts/build/install-rosetta.sh index af3a438c5..3eeec7f52 100644 --- a/images/macos/scripts/build/install-rosetta.sh +++ b/images/macos/scripts/build/install-rosetta.sh @@ -4,5 +4,5 @@ ## Desc: Install Rosetta ################################################################################ -echo 'Installing Rosetta' +echo "Installing Rosetta" /usr/sbin/softwareupdate --install-rosetta --agree-to-license diff --git a/images/macos/scripts/build/install-ruby.sh b/images/macos/scripts/build/install-ruby.sh index 13989a62e..e93ca6ab2 100644 --- a/images/macos/scripts/build/install-ruby.sh +++ b/images/macos/scripts/build/install-ruby.sh @@ -8,7 +8,7 @@ source ~/utils/utils.sh arch=$(get_arch) DEFAULT_RUBY_VERSION=$(get_toolset_value '.ruby.default') -echo Installing Ruby... +echo "Installing Ruby..." brew_smart_install "ruby@${DEFAULT_RUBY_VERSION}" if [[ $arch == "arm64" ]]; then export PATH=/opt/homebrew/opt/ruby@${DEFAULT_RUBY_VERSION}/bin:$PATH @@ -16,12 +16,12 @@ else export PATH=/usr/local/opt/ruby@${DEFAULT_RUBY_VERSION}/bin:$PATH fi -GEM_PATH=`gem env|awk '/EXECUTABLE DIRECTORY/ {print $4}'` -echo "GEM_PATH=$GEM_PATH" >> "$HOME/.bashrc" +GEM_PATH=$(gem env|awk '/EXECUTABLE DIRECTORY/ {print $4}') +echo "GEM_PATH=$GEM_PATH" >> $HOME/.bashrc if [[ $arch == "arm64" ]]; then - echo 'export PATH="$GEM_PATH:/opt/homebrew/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> "$HOME/.bashrc" + echo 'export PATH="$GEM_PATH:/opt/homebrew/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> $HOME/.bashrc else - echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> "$HOME/.bashrc" + echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> $HOME/.bashrc fi if ! is_Arm64; then @@ -29,13 +29,13 @@ if ! is_Arm64; then [ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}") PACKAGE_TAR_NAMES=$(curl "${authString[@]}" -fsSL "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name') TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .arch.'$arch'.versions[]') - RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby" + RUBY_PATH=$AGENT_TOOLSDIRECTORY/Ruby echo "Check if Ruby hostedtoolcache folder exists..." - if [ ! -d $RUBY_PATH ]; then + if [[ ! -d $RUBY_PATH ]]; then mkdir -p $RUBY_PATH fi - + echo "ruby path - $RUBY_PATH " for TOOLSET_VERSION in ${TOOLSET_VERSIONS[@]}; do PACKAGE_TAR_NAME=$(echo "$PACKAGE_TAR_NAMES" | grep "^ruby-${TOOLSET_VERSION}-macos-latest.tar.gz$" | egrep -v "rc|preview" | sort -V | tail -1) RUBY_VERSION=$(echo "$PACKAGE_TAR_NAME" | cut -d'-' -f 2) @@ -47,10 +47,10 @@ if ! is_Arm64; then echo "Downloading tar archive $PACKAGE_TAR_NAME" ARCHIVE_PATH=$(download_with_retry "https://github.com/ruby/ruby-builder/releases/download/toolcache/${PACKAGE_TAR_NAME}") - echo "Expand '$PACKAGE_TAR_NAME' to the '$RUBY_VERSION_PATH' folder" - tar xf "$ARCHIVE_PATH" -C $RUBY_VERSION_PATH - COMPLETE_FILE_PATH="$RUBY_VERSION_PATH/x64.complete" - if [ ! -f $COMPLETE_FILE_PATH ]; then + echo "Expand $PACKAGE_TAR_NAME to the $RUBY_VERSION_PATH folder" + tar xf $ARCHIVE_PATH -C $RUBY_VERSION_PATH + COMPLETE_FILE_PATH=$RUBY_VERSION_PATH/x64.complete + if [[ ! -f $COMPLETE_FILE_PATH ]]; then echo "Create complete file" touch $COMPLETE_FILE_PATH fi diff --git a/images/macos/scripts/build/install-rubygems.sh b/images/macos/scripts/build/install-rubygems.sh index 15a20616b..02caefe0b 100644 --- a/images/macos/scripts/build/install-rubygems.sh +++ b/images/macos/scripts/build/install-rubygems.sh @@ -6,14 +6,14 @@ source ~/utils/utils.sh -echo Updating RubyGems... +echo "Updating RubyGems..." gem update --system # Temporarily install activesupport 7.0.8 due to compatibility issues with cocoapods https://github.com/CocoaPods/CocoaPods/issues/12081 gem install activesupport -v 7.0.8 gemsToInstall=$(get_toolset_value '.ruby.rubygems | .[]') -if [ -n "$gemsToInstall" ]; then +if [[ -n $gemsToInstall ]]; then for gem in $gemsToInstall; do echo "Installing gem $gem" gem install $gem diff --git a/images/macos/scripts/build/install-rust.sh b/images/macos/scripts/build/install-rust.sh index a1fa98403..9b6e9be25 100644 --- a/images/macos/scripts/build/install-rust.sh +++ b/images/macos/scripts/build/install-rust.sh @@ -6,23 +6,23 @@ source ~/utils/utils.sh -echo Installing Rustup... +echo "Installing Rustup..." brew_smart_install "rustup-init" -echo Installing Rust language... +echo "Installing Rust language..." rustup-init -y --no-modify-path --default-toolchain=stable --profile=minimal -echo Initialize environment variables... +echo "Initialize environment variables..." CARGO_HOME=$HOME/.cargo -echo Install common tools... +echo "Install common tools..." rustup component add rustfmt clippy if is_BigSur || is_Monterey; then cargo install --locked bindgen-cli cbindgen cargo-audit cargo-outdated fi -echo Cleanup Cargo registry cached data... +echo "Cleanup Cargo registry cached data..." rm -rf $CARGO_HOME/registry/* invoke_tests "Rust" diff --git a/images/macos/scripts/build/install-safari.sh b/images/macos/scripts/build/install-safari.sh index bd4f54e7c..a00ef482c 100644 --- a/images/macos/scripts/build/install-safari.sh +++ b/images/macos/scripts/build/install-safari.sh @@ -13,7 +13,7 @@ sudo safaridriver --enable echo "Enabling the 'Allow Remote Automation' option in Safari's Develop menu" mkdir -p $HOME/Library/WebDriver safari_plist="$HOME/Library/WebDriver/com.apple.Safari.plist" -# "|| true" is needed to suppress exit code 1 in case if property or file doesn't exist +# "|| true" is needed to suppress exit code 1 in case if property or file doesn't exist /usr/libexec/PlistBuddy -c 'delete AllowRemoteAutomation' $safari_plist || true /usr/libexec/PlistBuddy -c 'add AllowRemoteAutomation bool true' $safari_plist diff --git a/images/macos/scripts/build/install-swiftlint.sh b/images/macos/scripts/build/install-swiftlint.sh index 5a3222e97..c04382987 100644 --- a/images/macos/scripts/build/install-swiftlint.sh +++ b/images/macos/scripts/build/install-swiftlint.sh @@ -6,13 +6,13 @@ source ~/utils/utils.sh -echo Installing Swiftlint... +echo "Installing Swiftlint..." if is_BigSur; then # SwiftLint now requires Swift 5.6 or higher to build, and macOS 12 or higher to run https://github.com/realm/SwiftLint/releases/tag/0.49.0 COMMIT=d1d5743344227fe6e3c37cfba19f0cfe15a9448a FORMULA_URL="https://raw.githubusercontent.com/Homebrew/homebrew-core/$COMMIT/Formula/swiftlint.rb" - curl -fsSL "$FORMULA_URL" > $(find $(brew --repository) -name swiftlint.rb) + curl -fsSL $FORMULA_URL > $(find $(brew --repository) -name swiftlint.rb) HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_FROM_API=1 brew install swiftlint else brew_smart_install "swiftlint" diff --git a/images/macos/scripts/build/install-visualstudio.sh b/images/macos/scripts/build/install-visualstudio.sh index 402665b73..e4fa7a35a 100644 --- a/images/macos/scripts/build/install-visualstudio.sh +++ b/images/macos/scripts/build/install-visualstudio.sh @@ -24,13 +24,13 @@ install_vsmac() { 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" + pushd $TMPMOUNT tar cf - "./Visual Studio.app" | tar xf - -C /Applications/ if [[ $vsmac_version != $vsmac_default ]]; then @@ -38,14 +38,14 @@ install_vsmac() { fi popd - sudo hdiutil detach "$TMPMOUNT" - sudo rm -rf "$TMPMOUNT" + sudo hdiutil detach $TMPMOUNT + sudo rm -rf $TMPMOUNT } vsmac_versions=($(get_toolset_value '.xamarin.vsmac.versions[]')) default_vsmac_version=$(get_toolset_value '.xamarin.vsmac.default') -for version in "${vsmac_versions[@]}"; do +for version in ${vsmac_versions[@]}; do install_vsmac $version $default_vsmac_version done diff --git a/images/macos/scripts/build/install-xamarin.sh b/images/macos/scripts/build/install-xamarin.sh index 33ba01281..faa0b70df 100644 --- a/images/macos/scripts/build/install-xamarin.sh +++ b/images/macos/scripts/build/install-xamarin.sh @@ -15,17 +15,17 @@ 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 +if [[ $current_sdk_symlink == "latest" ]]; then current_sdk_symlink=$latest_sdk_symlink fi -MONO_VERSIONS_PATH='/Library/Frameworks/Mono.framework/Versions' -IOS_VERSIONS_PATH='/Library/Frameworks/Xamarin.iOS.framework/Versions' -ANDROID_VERSIONS_PATH='/Library/Frameworks/Xamarin.Android.framework/Versions' -MAC_VERSIONS_PATH='/Library/Frameworks/Xamarin.Mac.framework/Versions' +MONO_VERSIONS_PATH="/Library/Frameworks/Mono.framework/Versions" +IOS_VERSIONS_PATH="/Library/Frameworks/Xamarin.iOS.framework/Versions" +ANDROID_VERSIONS_PATH="/Library/Frameworks/Xamarin.Android.framework/Versions" +MAC_VERSIONS_PATH="/Library/Frameworks/Xamarin.Mac.framework/Versions" -TMPMOUNT=`/usr/bin/mktemp -d /tmp/visualstudio.XXXX` -TMPMOUNT_FRAMEWORKS="$TMPMOUNT/frameworks" +TMPMOUNT=$(/usr/bin/mktemp -d /tmp/visualstudio.XXXX) +TMPMOUNT_FRAMEWORKS=$TMPMOUNT/frameworks createBackupFolders pushd $TMPMOUNT @@ -34,19 +34,19 @@ 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/ @@ -75,7 +75,7 @@ createUWPShim popd echo "Clean up packages..." -sudo rm -rf "$TMPMOUNT" +sudo rm -rf $TMPMOUNT # Fix Xamarin issue with Xcode symlink: https://github.com/xamarin/xamarin-macios/issues/9960 PREFERENCES_XAMARIN_DIR="${HOME}/Library/Preferences/Xamarin" diff --git a/images/macos/scripts/build/install-xcode-clt.sh b/images/macos/scripts/build/install-xcode-clt.sh index 13c17a5e6..4e6f33457 100644 --- a/images/macos/scripts/build/install-xcode-clt.sh +++ b/images/macos/scripts/build/install-xcode-clt.sh @@ -7,8 +7,8 @@ source ~/utils/utils.sh is_clt_installed() { - clt_path=`xcode-select -p 2>&1` - [[ -d "$clt_path" ]] + clt_path=$(xcode-select -p 2>&1) + [[ -d $clt_path ]] } install_clt() { diff --git a/images/macos/scripts/build/install-xcode-simulators.sh b/images/macos/scripts/build/install-xcode-simulators.sh deleted file mode 100644 index f04ea329b..000000000 --- a/images/macos/scripts/build/install-xcode-simulators.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -e -o pipefail -################################################################################ -## File: install-xcode-simulators.sh -## Desc: Install Xcode simulators -################################################################################ - -source ~/utils/utils.sh - -# Downloading and installing simulators -SIMS_TO_INSTALL=( -"8.4" -"9.0" -"9.1" -"9.2" -"9.3" -"10.0" -"10.1" -"10.2" -"10.3" -) - -for sim_version in ${SIMS_TO_INSTALL[@]} -do - echo "Installing iOS $sim_version ..." - sudo xcversion simulators --install="iOS ${sim_version}" - echo "Successfuly installed iOS $sim_version ..." -done - -echo "Done installing simulator runtimes." diff --git a/images/macos/scripts/helpers/utils.sh b/images/macos/scripts/helpers/utils.sh index f9219113d..c4d71881f 100644 --- a/images/macos/scripts/helpers/utils.sh +++ b/images/macos/scripts/helpers/utils.sh @@ -87,12 +87,6 @@ get_toolset_value() { echo "$(jq -r "$query" $toolset_path)" } -verlte() { - sortedVersion=$(echo -e "$1\n$2" | sort -V | head -n1) - [ "$1" = "$sortedVersion" ] -} - - # brew provides package bottles for different macOS versions # The 'brew install' command will fail if a package bottle does not exist # Use the '--build-from-source' option to build from source in this case diff --git a/images/macos/scripts/helpers/xamarin-utils.sh b/images/macos/scripts/helpers/xamarin-utils.sh index 83ddfb1bc..20e3b9dc8 100644 --- a/images/macos/scripts/helpers/xamarin-utils.sh +++ b/images/macos/scripts/helpers/xamarin-utils.sh @@ -160,7 +160,7 @@ installNunitConsole() { #!/bin/bash -e -o pipefail exec /Library/Frameworks/Mono.framework/Versions/${MONO_VERSION}/bin/mono --debug \$MONO_OPTIONS $NUNIT3_PATH/nunit3-console.exe "\$@" EOF - sudo chmod +x "$TMP_WRAPPER_PATH" + sudo chmod +x $TMP_WRAPPER_PATH sudo mv "$TMP_WRAPPER_PATH" "${MONO_VERSIONS_PATH}/${MONO_VERSION}/Commands/nunit3-console" }