mirror of
https://github.com/actions/runner-images.git
synced 2025-12-24 10:28:00 +08:00
[macOS] Implement new directories hierarchy (#8741)
This commit is contained in:
committed by
GitHub
parent
5d40b1e213
commit
8d6a01b370
22
images/macos/scripts/build/action-archive-cache.sh
Normal file
22
images/macos/scripts/build/action-archive-cache.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
################################################################################
|
||||
## File: action-archive-cache.sh
|
||||
## Desc: Download latest release from https://github.com/actions/action-verions
|
||||
## and un-tar to $HOME/actionarchivecache
|
||||
## Maintainer: #actions-runtime and @TingluoHuang
|
||||
################################################################################
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "Check if ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE folder exist..."
|
||||
if [ ! -d $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE ]; then
|
||||
mkdir -p $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
|
||||
fi
|
||||
|
||||
downloadUrl=$(get_github_package_download_url "actions/action-versions" "contains(\"action-versions.tar.gz\")" "latest")
|
||||
echo "Downloading action-versions $downloadUrl"
|
||||
download_with_retries "$downloadUrl" "/tmp" action-versions.tar.gz
|
||||
tar -xzf /tmp/action-versions.tar.gz -C $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
|
||||
|
||||
invoke_tests "ActionArchiveCache"
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# This script was taken from https://github.com/timsutton/osx-vm-templates/blob/master/scripts/add-network-interface-detection.sh
|
||||
# Distributed by MIT license, license can be found at the bottom of this script
|
||||
|
||||
# This script adds a Mac OS Launch Daemon, which runs every time the
|
||||
# machine is booted. The daemon will re-detect the attached network
|
||||
# interfaces. If this is not done, network devices may not work.
|
||||
PLIST=/Library/LaunchDaemons/sonoma.detectnewhardware.plist
|
||||
cat <<EOF > "${PLIST}"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>sonoma.detectnewhardware</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/sbin/networksetup</string>
|
||||
<string>-detectnewhardware</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
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}"
|
||||
|
||||
|
||||
: '
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2013-2017 Timothy Sutton
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
'
|
||||
133
images/macos/scripts/build/android-toolsets.sh
Normal file
133
images/macos/scripts/build/android-toolsets.sh
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
function filter_components_by_version {
|
||||
minimumVersion=$1
|
||||
shift
|
||||
toolsArr=("$@")
|
||||
|
||||
for item in ${toolsArr[@]}
|
||||
do
|
||||
# take the last argument after spliting string by ';'' and '-''
|
||||
version=$(echo "${item##*[-;]}")
|
||||
if verlte $minimumVersion $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)
|
||||
|
||||
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."extra-list"[]'))
|
||||
ANDROID_ADDON_LIST=($(get_toolset_value '.android."addon-list"[]'))
|
||||
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
|
||||
ANDROID_HOME=$HOME/Library/Android/sdk
|
||||
ANDROID_OSX_SDK_FILE=tools-macosx.zip
|
||||
|
||||
# Download the latest command line tools so that we can accept all of the licenses.
|
||||
# See https://developer.android.com/studio/#command-tools
|
||||
cmdlineToolsVersion=$(get_toolset_value '.android."cmdline-tools"')
|
||||
|
||||
if [[ $cmdlineToolsVersion == "latest" ]]; then
|
||||
repositoryXmlUrl="https://dl.google.com/android/repository/repository2-1.xml"
|
||||
download_with_retries $repositoryXmlUrl "/tmp" "repository2-1.xml"
|
||||
cmdlineToolsVersion=$(
|
||||
yq -p=xml \
|
||||
'.sdk-repository.remotePackage[] | select(."+@path" == "cmdline-tools;latest" and .channelRef."+@ref" == "channel-0").archives.archive[].complete.url | select(contains("commandlinetools-mac"))' \
|
||||
/tmp/repository2-1.xml
|
||||
)
|
||||
|
||||
if [[ -z $cmdlineToolsVersion ]]; then
|
||||
echo "Failed to parse latest command-line tools version"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Downloading android command line tools..."
|
||||
download_with_retries "https://dl.google.com/android/repository/${cmdlineToolsVersion}" /tmp $ANDROID_OSX_SDK_FILE
|
||||
|
||||
echo "Uncompressing android command line tools..."
|
||||
mkdir -p $HOME/Library/Android/sdk
|
||||
unzip -q /tmp/$ANDROID_OSX_SDK_FILE -d $HOME/Library/Android/sdk/cmdline-tools
|
||||
# Command line tools need to be placed in $HOME/Library/Android/sdk/cmdline-tools/latest to function properly
|
||||
mv $HOME/Library/Android/sdk/cmdline-tools/cmdline-tools $HOME/Library/Android/sdk/cmdline-tools/latest
|
||||
rm -f /tmp/$ANDROID_OSX_SDK_FILE
|
||||
|
||||
echo ANDROID_HOME is $ANDROID_HOME
|
||||
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin
|
||||
|
||||
SDKMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager
|
||||
|
||||
echo "Installing latest tools & platform tools..."
|
||||
echo y | $SDKMANAGER "tools" "platform-tools"
|
||||
|
||||
echo "Installing latest ndk..."
|
||||
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)
|
||||
ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$ndkDefault
|
||||
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"
|
||||
echo "export ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> "${HOME}/.bashrc"
|
||||
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[@]}"
|
||||
|
||||
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[@]}"
|
||||
|
||||
echo "y" | $SDKMANAGER ${components[@]}
|
||||
|
||||
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[@]}"
|
||||
do
|
||||
echo "Installing add-on $addon_name ..."
|
||||
echo y | $SDKMANAGER "add-ons;$addon_name"
|
||||
done
|
||||
|
||||
for tool_name in "${ANDROID_ADDITIONAL_TOOLS[@]}"
|
||||
do
|
||||
echo "Installing additional tool $tool_name ..."
|
||||
echo y | $SDKMANAGER "$tool_name"
|
||||
done
|
||||
|
||||
# Download SDK tools to preserve backward compatibility
|
||||
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 -o -qq $sdkTools -d ${ANDROID_SDK_ROOT}
|
||||
rm -f $sdkTools
|
||||
fi
|
||||
|
||||
invoke_tests "Android"
|
||||
8
images/macos/scripts/build/apache.sh
Normal file
8
images/macos/scripts/build/apache.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
brew_smart_install httpd
|
||||
sudo sed -Ei '' 's/Listen .*/Listen 80/' $(brew --prefix)/etc/httpd/httpd.conf
|
||||
|
||||
invoke_tests "WebServers" "Apache"
|
||||
20
images/macos/scripts/build/audiodevice.sh
Normal file
20
images/macos/scripts/build/audiodevice.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "install switchaudio-osx"
|
||||
brew_smart_install "switchaudio-osx"
|
||||
|
||||
echo "install sox"
|
||||
brew_smart_install "sox"
|
||||
|
||||
# Big Sur doesn't support soundflower installation without user interaction https://github.com/mattingalls/Soundflower/releases/tag/2.0b2
|
||||
# Install blackhole-2ch for Big Sur instead
|
||||
|
||||
echo "install blackhole-2ch"
|
||||
brew_smart_install "blackhole-2ch"
|
||||
|
||||
echo "set BlackHole 2ch as input/output device"
|
||||
SwitchAudioSource -s "BlackHole 2ch" -t input
|
||||
SwitchAudioSource -s "BlackHole 2ch" -t output
|
||||
|
||||
invoke_tests "System" "Audio Device"
|
||||
18
images/macos/scripts/build/autologin.sh
Normal file
18
images/macos/scripts/build/autologin.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# This script was taken from https://github.com/timsutton/osx-vm-templates/blob/master/scripts/autologin.sh
|
||||
# Distributed by MIT license, license can be found at the bottom of this script
|
||||
|
||||
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"
|
||||
|
||||
: '
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2013-2017 Timothy Sutton
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
'
|
||||
16
images/macos/scripts/build/aws.sh
Normal file
16
images/macos/scripts/build/aws.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing aws...
|
||||
AWS_CLI_URL="https://awscli.amazonaws.com/AWSCLIV2.pkg"
|
||||
download_with_retries $AWS_CLI_URL "/tmp"
|
||||
sudo installer -pkg /tmp/AWSCLIV2.pkg -target /
|
||||
|
||||
echo Installing aws sam cli...
|
||||
brew tap aws/tap
|
||||
brew_smart_install aws-sam-cli
|
||||
|
||||
echo "Install aws cli session manager"
|
||||
brew install --cask session-manager-plugin
|
||||
|
||||
invoke_tests "Common" "AWS"
|
||||
21
images/macos/scripts/build/azcopy.sh
Normal file
21
images/macos/scripts/build/azcopy.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
arch=$(get_arch)
|
||||
|
||||
# Check MacOS architecture and if ARM install using brew
|
||||
if [ $arch == "arm64" ]; then
|
||||
brew_smart_install azcopy
|
||||
else
|
||||
AZCOPY_DOWNLOAD_URL="https://aka.ms/downloadazcopy-v10-mac"
|
||||
|
||||
download_with_retries $AZCOPY_DOWNLOAD_URL "/tmp" "azcopy.zip"
|
||||
unzip /tmp/azcopy.zip -d azcopy
|
||||
AZCOPY_EXTRACTED=$(echo azcopy/azcopy*)
|
||||
cp "$AZCOPY_EXTRACTED/azcopy" "/usr/local/bin/azcopy"
|
||||
chmod +x "/usr/local/bin/azcopy"
|
||||
|
||||
echo "Done, cleaning up"
|
||||
rm -rf azcopy*
|
||||
fi
|
||||
|
||||
invoke_tests "Common" "AzCopy"
|
||||
9
images/macos/scripts/build/bicep.sh
Normal file
9
images/macos/scripts/build/bicep.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing bicep cli...
|
||||
brew tap azure/bicep
|
||||
brew_smart_install bicep
|
||||
|
||||
invoke_tests "Common" "Bicep"
|
||||
20
images/macos/scripts/build/build-xcode-symlinks.sh
Normal file
20
images/macos/scripts/build/build-xcode-symlinks.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Link the existing Xcodes into the correct location for provisionator.
|
||||
|
||||
# These symlinks are necessary for Xamarin team to make sure that xamarin-provisionator can find them.
|
||||
|
||||
# Old style provisionator directories. This is maintained for
|
||||
# backwards compatibility only. Do not add new xcodes here.
|
||||
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
|
||||
50
images/macos/scripts/build/chrome.sh
Normal file
50
images/macos/scripts/build/chrome.sh
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
arch=$(get_arch)
|
||||
|
||||
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"
|
||||
|
||||
# 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"
|
||||
download_with_retries "$CHROME_VERSIONS_URL" "/tmp" "latest-patch-versions-per-build-with-downloads.json"
|
||||
CHROME_VERSIONS_JSON=$(cat /tmp/latest-patch-versions-per-build-with-downloads.json)
|
||||
|
||||
# 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_URL=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].downloads.chromedriver[] | select(.platform=="'"${CHROME_PLATFORM}"'").url')
|
||||
CHROMEDRIVER_ARCHIVE="chromedriver-${CHROME_PLATFORM}.zip"
|
||||
CHROMEDRIVER_DIR="/usr/local/share/chromedriver-${CHROME_PLATFORM}"
|
||||
CHROMEDRIVER_BIN="$CHROMEDRIVER_DIR/chromedriver"
|
||||
|
||||
download_with_retries "$CHROMEDRIVER_URL" "/tmp" "$CHROMEDRIVER_ARCHIVE"
|
||||
unzip -qq /tmp/$CHROMEDRIVER_ARCHIVE -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_URL=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].downloads.chrome[] | select(.platform=="'"${CHROME_PLATFORM}"'").url')
|
||||
CHROME_FOR_TESTING_ARCHIVE="chrome-${CHROME_PLATFORM}.zip"
|
||||
CHROME_FOR_TESTING_APP="Google Chrome for Testing.app"
|
||||
|
||||
download_with_retries $CHROME_FOR_TESTING_URL "/tmp" $CHROME_FOR_TESTING_ARCHIVE
|
||||
unzip -qq /tmp/$CHROME_FOR_TESTING_ARCHIVE -d /tmp/
|
||||
mv "/tmp/chrome-${CHROME_PLATFORM}/${CHROME_FOR_TESTING_APP}" "/Applications/${CHROME_FOR_TESTING_APP}"
|
||||
|
||||
echo "Installing Selenium"
|
||||
brew_smart_install "selenium-server"
|
||||
|
||||
invoke_tests "Browsers" "Chrome"
|
||||
7
images/macos/scripts/build/cleanup-brew.sh
Normal file
7
images/macos/scripts/build/cleanup-brew.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
###########################################################################
|
||||
# The script removes local Homebrew cache
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
rm -rf "$(brew --cache)"
|
||||
10
images/macos/scripts/build/cocoapods.sh
Normal file
10
images/macos/scripts/build/cocoapods.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# Setup the Cocoapods
|
||||
echo "Installing Cocoapods..."
|
||||
pod setup
|
||||
|
||||
# Create a symlink to /usr/local/bin since it was removed due to Homebrew change.
|
||||
ln -sf $(which pod) /usr/local/bin/pod
|
||||
|
||||
invoke_tests "Common" "CocoaPods"
|
||||
28
images/macos/scripts/build/codeql-bundle.sh
Normal file
28
images/macos/scripts/build/codeql-bundle.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Retrieve the CLI version of the latest CodeQL bundle.
|
||||
download_with_retries https://raw.githubusercontent.com/github/codeql-action/v2/src/defaults.json "/tmp" "codeql-defaults.json"
|
||||
bundle_version="$(jq -r '.cliVersion' /tmp/codeql-defaults.json)"
|
||||
bundle_tag_name="codeql-bundle-v$bundle_version"
|
||||
|
||||
echo "Downloading CodeQL bundle $bundle_version..."
|
||||
# Note that this is the all-platforms CodeQL bundle, to support scenarios where customers run
|
||||
# different operating systems within containers.
|
||||
download_with_retries "https://github.com/github/codeql-action/releases/download/$bundle_tag_name/codeql-bundle.tar.gz" "/tmp" "codeql-bundle.tar.gz"
|
||||
codeql_archive="/tmp/codeql-bundle.tar.gz"
|
||||
|
||||
codeql_toolcache_path="$AGENT_TOOLSDIRECTORY/CodeQL/$bundle_version/x64"
|
||||
mkdir -p "$codeql_toolcache_path"
|
||||
|
||||
echo "Unpacking the downloaded CodeQL bundle archive..."
|
||||
tar -xzf "$codeql_archive" -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 a file to indicate to the toolcache that setting up CodeQL is complete.
|
||||
touch "$codeql_toolcache_path.complete"
|
||||
|
||||
invoke_tests "Common" "CodeQL Bundle"
|
||||
96
images/macos/scripts/build/commonutils.sh
Normal file
96
images/macos/scripts/build/commonutils.sh
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Download and install YQ in cases when it is not available in the formulae as for macOS 11: https://formulae.brew.sh/formula/yq
|
||||
if is_BigSur; then
|
||||
download_with_retries "https://github.com/mikefarah/yq/releases/latest/download/yq_darwin_amd64" "/tmp" "yq"
|
||||
sudo install /tmp/yq /usr/local/bin/yq
|
||||
fi
|
||||
|
||||
# Monterey needs future review:
|
||||
# aliyun-cli, gnupg, helm have issues with building from the source code.
|
||||
# Added gmp for now, because toolcache ruby needs its libs. Remove it when php starts to build from source code.
|
||||
common_packages=$(get_toolset_value '.brew.common_packages[]')
|
||||
for package in $common_packages; do
|
||||
echo "Installing $package..."
|
||||
brew_smart_install "$package"
|
||||
done
|
||||
|
||||
cask_packages=$(get_toolset_value '.brew.cask_packages[]')
|
||||
for package in $cask_packages; do
|
||||
echo "Installing $package..."
|
||||
if is_Monterey && [[ $package == "virtualbox" ]]; then
|
||||
# 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.
|
||||
vbcask_url="https://raw.githubusercontent.com/Homebrew/homebrew-cask/aa3c55951fc9d687acce43e5c0338f42c1ddff7b/Casks/virtualbox.rb"
|
||||
download_with_retries $vbcask_url
|
||||
brew install ./virtualbox.rb
|
||||
rm ./virtualbox.rb
|
||||
else
|
||||
brew install --cask $package
|
||||
fi
|
||||
done
|
||||
|
||||
# Load "Parallels International GmbH"
|
||||
if is_Monterey; then
|
||||
sudo kextload /Applications/Parallels\ Desktop.app/Contents/Library/Extensions/10.9/prl_hypervisor.kext || true
|
||||
fi
|
||||
|
||||
# Execute AppleScript to change security preferences
|
||||
# System Preferences -> Security & Privacy -> General -> Unlock -> Allow -> Not now
|
||||
if is_Monterey; then
|
||||
if is_Veertu; then
|
||||
for retry in {4..0}; do
|
||||
echo "Executing AppleScript to change security preferences. Retries left: $retry"
|
||||
{
|
||||
set -e
|
||||
osascript -e 'tell application "System Events" to get application processes where visible is true'
|
||||
osascript $HOME/utils/confirm-identified-developers.scpt $USER_PASSWORD
|
||||
} && break
|
||||
|
||||
if [ "$retry" -eq 0 ]; then
|
||||
echo "Executing AppleScript failed. No retries left"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Executing AppleScript failed. Sleeping for 10 seconds and retrying"
|
||||
sleep 10
|
||||
done
|
||||
else
|
||||
echo "Executing AppleScript to change security preferences"
|
||||
osascript $HOME/utils/confirm-identified-developers.scpt $USER_PASSWORD
|
||||
fi
|
||||
fi
|
||||
|
||||
# Validate "Parallels International GmbH" kext
|
||||
if is_Monterey; then
|
||||
echo "Closing System Preferences window if it is still opened"
|
||||
killall "System Preferences" || true
|
||||
|
||||
echo "Checking parallels kexts"
|
||||
dbName="/var/db/SystemPolicyConfiguration/KextPolicy"
|
||||
dbQuery="SELECT * FROM kext_policy WHERE bundle_id LIKE 'com.parallels.kext.%';"
|
||||
kext=$(sudo sqlite3 $dbName "$dbQuery")
|
||||
|
||||
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
|
||||
echo "Unable to parse url for Parallels Desktop cask"
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
|
||||
# Invoke tests for all basic tools
|
||||
invoke_tests "BasicTools"
|
||||
28
images/macos/scripts/build/configure-hostname.sh
Normal file
28
images/macos/scripts/build/configure-hostname.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# Add script for changing hostname to run on startup to prevent duplicate hostnames across the environment. Hostname and Computername should contain .local in name to avoid name resolution issues
|
||||
tee -a /usr/local/bin/change_hostname.sh > /dev/null <<\EOF
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
name="Mac-$(python3 -c 'from time import time; print(int(round(time() * 1000)))')"
|
||||
scutil --set HostName "${name}.local"
|
||||
scutil --set LocalHostName $name
|
||||
scutil --set ComputerName "${name}.local"
|
||||
EOF
|
||||
|
||||
chmod +x "/usr/local/bin/change_hostname.sh"
|
||||
|
||||
sudo tee -a /Library/LaunchDaemons/change_hostname.plist > /dev/null <<\EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>change-hostname</string>
|
||||
<key>Program</key>
|
||||
<string>/usr/local/bin/change_hostname.sh</string>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
104
images/macos/scripts/build/configure-machine.sh
Normal file
104
images/macos/scripts/build/configure-machine.sh
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "Enabling developer mode..."
|
||||
sudo /usr/sbin/DevToolsSecurity --enable
|
||||
|
||||
# Turn off hibernation and get rid of the sleepimage
|
||||
sudo pmset hibernatemode 0
|
||||
sudo rm -f /var/vm/sleepimage
|
||||
|
||||
# Disable App Nap System Wide
|
||||
defaults write NSGlobalDomain NSAppSleepDisabled -bool YES
|
||||
|
||||
# Disable Keyboard Setup Assistant window
|
||||
if is_Veertu; then
|
||||
sudo defaults write /Library/Preferences/com.apple.keyboardtype "keyboardtype" -dict-add "3-7582-0" -int 40
|
||||
fi
|
||||
|
||||
# Change screen resolution to the maximum supported for 4Mb video memory
|
||||
if [ -d "/Library/Application Support/VMware Tools" ]; then
|
||||
sudo "/Library/Application Support/VMware Tools/vmware-resolutionSet" 1176 885
|
||||
fi
|
||||
|
||||
# Update VoiceOver Utility to allow VoiceOver to be controlled with AppleScript
|
||||
# by creating a special Accessibility DB file (SIP must be disabled) and
|
||||
# updating the user defaults system to reflect this change.
|
||||
if csrutil status | grep -Eq "System Integrity Protection status: (disabled|unknown)"; then
|
||||
sudo bash -c 'echo -n "a" > /private/var/db/Accessibility/.VoiceOverAppleScriptEnabled'
|
||||
fi
|
||||
defaults write com.apple.VoiceOver4/default SCREnableAppleScript -bool YES
|
||||
|
||||
# https://developer.apple.com/support/expiration/
|
||||
# Enterprise iOS Distribution Certificates generated between February 7 and September 1st, 2020 will expire on February 7, 2023.
|
||||
# Rotate the certificate before expiration to ensure your apps are installed and signed with an active certificate.
|
||||
# Confirm that the correct intermediate certificate is installed by verifying the expiration date is set to 2030.
|
||||
# sudo security delete-certificate -Z FF6797793A3CD798DC5B2ABEF56F73EDC9F83A64 /Library/Keychains/System.keychain
|
||||
# Big Sur requires user interaction to add a cert https://developer.apple.com/forums/thread/671582, we need to use a workaround with SecItemAdd swift method
|
||||
|
||||
swiftc -suppress-warnings "${HOME}/image-generation/add-certificate.swift"
|
||||
|
||||
|
||||
certs=(
|
||||
AppleWWDRCAG3.cer
|
||||
DeveloperIDG2CA.cer
|
||||
)
|
||||
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
|
||||
|
||||
rm -f ./add-certificate
|
||||
|
||||
# enable-automationmode-without-authentication
|
||||
if ! is_BigSur; then
|
||||
retry=10
|
||||
while [ $retry -gt 0 ]; do
|
||||
{
|
||||
osascript <<EOF
|
||||
tell application "Terminal"
|
||||
activate
|
||||
do script "automationmodetool enable-automationmode-without-authentication"
|
||||
delay 2
|
||||
tell application "System Events"
|
||||
keystroke "${PASSWORD}"
|
||||
keystroke return
|
||||
end tell
|
||||
end tell
|
||||
delay 5
|
||||
EOF
|
||||
} && break
|
||||
|
||||
retry=$((retry-1))
|
||||
if [ $retry -eq 0 ]; then
|
||||
echo "No retry attempts left"
|
||||
exit 1
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
|
||||
echo "Getting terminal windows"
|
||||
term_service=$(launchctl list | grep -i terminal | cut -f3)
|
||||
echo "Close terminal windows: gui/501/${term_service}"
|
||||
launchctl bootout gui/501/${term_service} && sleep 5
|
||||
|
||||
# test enable-automationmode-without-authentication
|
||||
if [[ ! "$(automationmodetool)" =~ "DOES NOT REQUIRE" ]]; then
|
||||
echo "Failed to enable enable-automationmode-without-authentication option"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create symlink for tests running
|
||||
if [ ! -d "/usr/local/bin" ];then
|
||||
sudo mkdir -p -m 775 /usr/local/bin
|
||||
sudo chown $USER:admin /usr/local/bin
|
||||
fi
|
||||
chmod +x $HOME/utils/invoke-tests.sh
|
||||
sudo ln -s $HOME/utils/invoke-tests.sh /usr/local/bin/invoke_tests
|
||||
7
images/macos/scripts/build/configure-ssh.sh
Normal file
7
images/macos/scripts/build/configure-ssh.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
[[ ! -d ~/.ssh ]] && mkdir ~/.ssh 2>/dev/null
|
||||
chmod 777 ~/.ssh
|
||||
|
||||
ssh-keyscan -t rsa,ecdsa,ed25519 github.com >> ~/.ssh/known_hosts
|
||||
ssh-keyscan -t rsa ssh.dev.azure.com >> ~/.ssh/known_hosts
|
||||
73
images/macos/scripts/build/configure-tccdb-macos.sh
Normal file
73
images/macos/scripts/build/configure-tccdb-macos.sh
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# This script adds permissions, which are required for some installed tools to work properly, to the TCC.db
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# /Library/Application\ Support/com.apple.TCC/TCC.db
|
||||
systemValuesArray=(
|
||||
"'kTCCServiceAccessibility','/usr/local/opt/runner/runprovisioner.sh',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1566321319"
|
||||
"'kTCCServicePostEvent','/usr/local/opt/runner/runprovisioner.sh',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1566321326"
|
||||
"'kTCCServiceSystemPolicyAllFiles','/usr/local/opt/runner/runprovisioner.sh',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
|
||||
"'kTCCServiceAccessibility','com.apple.dt.Xcode-Helper',0,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,NULL,1551941368"
|
||||
"'kTCCServiceSystemPolicyAllFiles','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
|
||||
"'kTCCServiceSystemPolicyAllFiles','/usr/libexec/sshd-keygen-wrapper',1,0,4,1,X'fade0c000000003c0000000100000006000000020000001d636f6d2e6170706c652e737368642d6b657967656e2d7772617070657200000000000003',NULL,0,'UNUSED',NULL,0,1639660695"
|
||||
"'kTCCServiceSystemPolicyAllFiles','com.apple.Terminal',0,2,4,1,X'fade0c000000003000000001000000060000000200000012636f6d2e6170706c652e5465726d696e616c000000000003',NULL,0,'UNUSED',NULL,0,1678990068"
|
||||
"'kTCCServiceAccessibility','/usr/libexec/sshd-keygen-wrapper',1,2,4,1,X'fade0c000000003c0000000100000006000000020000001d636f6d2e6170706c652e737368642d6b657967656e2d7772617070657200000000000003',NULL,0,'UNUSED',NULL,0,1644564233"
|
||||
"'kTCCServiceAccessibility','com.apple.Terminal',0,2,0,1,X'fade0c000000003000000001000000060000000200000012636f6d2e6170706c652e5465726d696e616c000000000003',NULL,NULL,'UNUSED',NULL,0,1591180502"
|
||||
"'kTCCServiceAccessibility','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
|
||||
"'kTCCServiceMicrophone','/usr/local/opt/runner/runprovisioner.sh',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,NULL,1576661342"
|
||||
"'kTCCServiceScreenCapture','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1599831148"
|
||||
"'kTCCServiceScreenCapture','com.devexpress.testcafe-browser-tools',0,2,3,1,X'fade0c0000000068000000010000000700000007000000080000001443fa4ca5141baeda21aeca1f50894673b440d4690000000800000014f8afcf6e69791b283e55bd0b03e39e422745770e0000000800000014bf4fc1aed64c871a49fc6bc9dd3878ce5d4d17c6',NULL,0,'UNUSED',NULL,0,1687952810"
|
||||
"'kTCCServicePostEvent','/Library/Application Support/Veertu/Anka/addons/ankarund',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1644565949"
|
||||
"'kTCCServiceScreenCapture','/usr/local/opt/runner/provisioner/provisioner',0,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||
"'kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.finder',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e66696e64657200000003',NULL,1592919552"
|
||||
"'kTCCServiceAccessibility','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,NULL,1592919552"
|
||||
# Allow Full Disk Access for "Microsoft Defender for macOS" to bypass installation on-flight
|
||||
"'kTCCServiceSystemPolicyAllFiles','com.microsoft.wdav',0,2,4,1,NULL,NULL,NULL,'UNUSED',NULL,0,1643970979"
|
||||
"'kTCCServiceSystemPolicyAllFiles','com.microsoft.wdav.epsext',0,2,4,1,NULL,NULL,NULL,'UNUSED',NULL,0,1643970979"
|
||||
"'kTCCServiceSystemPolicyNetworkVolumes','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
|
||||
"'kTCCServiceSystemPolicyNetworkVolumes','com.apple.Terminal',0,2,4,1,X'fade0c000000003000000001000000060000000200000012636f6d2e6170706c652e5465726d696e616c000000000003',NULL,0,'UNUSED',NULL,0,1678990068"
|
||||
)
|
||||
for values in "${systemValuesArray[@]}"; do
|
||||
if is_Sonoma; then
|
||||
# TCC access table in Sonoma has extra 4 columns: pid, pid_version, boot_uuid, last_reminded
|
||||
configure_system_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
|
||||
else
|
||||
configure_system_tccdb "$values"
|
||||
fi
|
||||
done
|
||||
|
||||
# $HOME/Library/Application\ Support/com.apple.TCC/TCC.db
|
||||
userValuesArray=(
|
||||
"'kTCCServiceUbiquity','com.apple.mail',0,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,NULL,1551941469"
|
||||
"'kTCCServiceUbiquity','com.apple.TextEdit',0,2,0,1,X'fade0c000000003000000001000000060000000200000012636f6d2e6170706c652e5465787445646974000000000003',NULL,NULL,'UNUSED',NULL,0,1566368356"
|
||||
"'kTCCServiceUbiquity','com.apple.CloudDocs.MobileDocumentsFileProvider',0,2,0,1,X'fade0c000000004c0000000100000006000000020000002f636f6d2e6170706c652e436c6f7564446f63732e4d6f62696c65446f63756d656e747346696c6550726f76696465720000000003',NULL,NULL,'UNUSED',NULL,0,1570793290"
|
||||
"'kTCCServiceAppleEvents','/usr/local/opt/runner/runprovisioner.sh',1,2,0,1,NULL,NULL,0,'com.apple.systemevents',NULL,NULL,1574241374"
|
||||
"'kTCCServiceSystemPolicyAllFiles','/usr/local/opt/runner/runprovisioner.sh',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
|
||||
"'kTCCServiceAppleEvents','/usr/libexec/sshd-keygen-wrapper',1,2,3,1,X'fade0c000000003c0000000100000006000000020000001d636f6d2e6170706c652e737368642d6b657967656e2d7772617070657200000000000003',NULL,0,'com.apple.systemevents',X'fade0c000000003400000001000000060000000200000016636f6d2e6170706c652e73797374656d6576656e7473000000000003',NULL,1644564201"
|
||||
"'kTCCServiceAppleEvents','com.apple.Terminal',0,2,0,1,X'fade0c000000003000000001000000060000000200000012636f6d2e6170706c652e5465726d696e616c000000000003',NULL,0,'com.apple.systemevents',X'fade0c000000003400000001000000060000000200000016636f6d2e6170706c652e73797374656d6576656e7473000000000003',NULL,1591180478"
|
||||
"'kTCCServiceAppleEvents','/usr/libexec/sshd-keygen-wrapper',1,2,0,1,X'fade0c000000003c0000000100000006000000020000001d636f6d2e6170706c652e737368642d6b657967656e2d7772617070657200000000000003',NULL,0,'com.apple.finder',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e66696e64657200000003',NULL,1591357685"
|
||||
"'kTCCServiceAppleEvents','/bin/bash',1,2,0,1,NULL,NULL,0,'com.apple.systemevents',NULL,NULL,1591532620"
|
||||
"'kTCCServiceAppleEvents','/bin/bash',1,2,0,1,NULL,NULL,0,'com.apple.finder',NULL,NULL,1592919552"
|
||||
"'kTCCServiceMicrophone','com.apple.CoreSimulator.SimulatorTrampoline',0,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,NULL,1576347152"
|
||||
"'kTCCServiceMicrophone','/usr/local/opt/runner/runprovisioner.sh',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,NULL,1576661342"
|
||||
"'kTCCServiceUbiquity','/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/Versions/A/Support/photolibraryd',1,2,5,1,NULL,NULL,NULL,'UNUSED',NULL,0,1619461750"
|
||||
"'kTCCServiceUbiquity','com.apple.PassKitCore',0,2,5,1,NULL,NULL,NULL,'UNUSED',NULL,0,1619516250"
|
||||
"'kTCCServiceAppleEvents','/Library/Application Support/Veertu/Anka/addons/ankarund',1,2,3,1,NULL,NULL,0,'com.apple.finder',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e66696e64657200000003',NULL,1629294900"
|
||||
"'kTCCServiceAppleEvents','/Library/Application Support/Veertu/Anka/addons/ankarund',1,2,3,1,NULL,NULL,0,'com.apple.systemevents',X'fade0c000000003400000001000000060000000200000016636f6d2e6170706c652e73797374656d6576656e7473000000000003',NULL,164456761"
|
||||
"'kTCCServiceAppleEvents','/Library/Application Support/Veertu/Anka/addons/ankarund',1,2,3,1,NULL,NULL,0,'com.apple.Terminal',X'fade0c000000003000000001000000060000000200000012636f6d2e6170706c652e5465726d696e616c000000000003',NULL,1655808179"
|
||||
"'kTCCServiceAppleEvents','/usr/libexec/sshd-keygen-wrapper',1,2,3,1,X'fade0c000000003c0000000100000006000000020000001d636f6d2e6170706c652e737368642d6b657967656e2d7772617070657200000000000003',NULL,0,'com.apple.Terminal',X'fade0c000000003000000001000000060000000200000012636f6d2e6170706c652e5465726d696e616c000000000003',NULL,1650386089"
|
||||
"'kTCCServicePostEvent','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
|
||||
"'kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.finder',X'fade0c000000002c00000001000000060000000200000010636f6d2e6170706c652e66696e64657200000003',NULL,1592919552"
|
||||
"'kTCCServiceScreenCapture','/usr/local/opt/runner/provisioner/provisioner',0,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||
"'kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,3,1,NULL,NULL,0,'com.apple.systemevents',X'fade0c000000003400000001000000060000000200000016636f6d2e6170706c652e73797374656d6576656e7473000000000003',NULL,1592919552"
|
||||
)
|
||||
for values in "${userValuesArray[@]}"; do
|
||||
if is_Sonoma; then
|
||||
# TCC access table in Sonoma has extra 4 columns: pid, pid_version, boot_uuid, last_reminded
|
||||
configure_user_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
|
||||
else
|
||||
configure_user_tccdb "$values"
|
||||
fi
|
||||
done
|
||||
47
images/macos/scripts/build/configure-toolset.ps1
Normal file
47
images/macos/scripts/build/configure-toolset.ps1
Normal file
@@ -0,0 +1,47 @@
|
||||
################################################################################
|
||||
## File: Configure-Toolset.ps1
|
||||
## Team: CI-Build
|
||||
## Desc: Configure toolset
|
||||
################################################################################
|
||||
|
||||
Import-Module "~/image-generation/helpers/Common.Helpers.psm1"
|
||||
|
||||
function Get-ToolsetToolFullPath
|
||||
{
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory)] [string] $ToolName,
|
||||
[Parameter(Mandatory)] [string] $ToolVersion,
|
||||
[Parameter(Mandatory)] [string] $ToolArchitecture
|
||||
)
|
||||
|
||||
$toolPath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $toolName
|
||||
$toolPathVersion = Join-Path -Path $toolPath -ChildPath $toolVersion
|
||||
$foundVersion = Get-Item $toolPathVersion | Sort-Object -Property {[version]$_.name} -Descending | Select-Object -First 1
|
||||
$installationDir = Join-Path -Path $foundVersion -ChildPath $toolArchitecture
|
||||
return $installationDir
|
||||
}
|
||||
|
||||
$arch = Get-Architecture
|
||||
$toolcache = Get-ToolsetValue "toolcache"
|
||||
|
||||
foreach ($tool in $toolcache)
|
||||
{
|
||||
$toolName = $tool.name
|
||||
$toolEnvironment = $tool.arch.$arch.variable_template
|
||||
|
||||
if (-not $toolEnvironment)
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
foreach ($toolVersion in $tool.arch.$arch.versions)
|
||||
{
|
||||
Write-Host "Set $toolName $toolVersion environment variable..."
|
||||
$toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $arch
|
||||
$envName = $toolEnvironment -f $toolVersion.split(".")
|
||||
|
||||
# Add environment variable name=value
|
||||
Add-EnvironmentVariable -Name $envName -Value $toolPath
|
||||
}
|
||||
}
|
||||
155
images/macos/scripts/build/delete-duplicate-sims.rb
Normal file
155
images/macos/scripts/build/delete-duplicate-sims.rb
Normal file
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# What is this for?
|
||||
# This script fixes an issue appeared for some Xcode users where it would show long identifiers
|
||||
# in the list of simulators instead of usual short names. This is caused by duplicate simulators
|
||||
# being sometimes created after switching between Xcode versions, with the same
|
||||
# device type + runtime pair occurring more than once in your list of available simulators.
|
||||
# Instead of showing the same simulator name twice, Xcode defaults to simulator identifiers.
|
||||
#
|
||||
# What it does?
|
||||
# The script queries Xcode's `simctl` utility for all simulators you have, finds duplicate type + runtime pairs,
|
||||
# and offers you to delete them. After that, Xcode should return to displaying the list of simulators normally.
|
||||
# When searching for duplicates, the script sorts simulators by their creation time to make sure it deletes
|
||||
# the copy that was created more recently.
|
||||
#
|
||||
# License
|
||||
# This script was taken from https://gist.github.com/vlas-voloshin/f9982128200345cd3fb7 and some modifications made
|
||||
# Distributed by MIT license, license can be found at the bottom of this script
|
||||
|
||||
class SimDevice
|
||||
|
||||
attr_accessor :runtime
|
||||
attr_accessor :name
|
||||
attr_accessor :identifier
|
||||
attr_accessor :timestamp
|
||||
|
||||
def initialize(runtime, name, identifier, timestamp)
|
||||
@runtime = runtime
|
||||
@name = name
|
||||
@identifier = identifier
|
||||
@timestamp = timestamp
|
||||
end
|
||||
|
||||
def to_s
|
||||
return "#{@name} - #{@runtime} (#{@identifier}) [#{@timestamp}]"
|
||||
end
|
||||
|
||||
def equivalent_to_device(device)
|
||||
return @runtime == device.runtime && @name == device.name
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Executes a shell command and returns the result from stdout
|
||||
def execute_simctl_command(command)
|
||||
return %x[xcrun simctl #{command}]
|
||||
end
|
||||
|
||||
# Retrieves the creation date/time of simulator with specified identifier
|
||||
def simulator_creation_date(identifier)
|
||||
directory = Dir.home() + "/Library/Developer/CoreSimulator/Devices/" + identifier
|
||||
if (Dir.exists?(directory))
|
||||
if (File::Stat.method_defined?(:birthtime))
|
||||
return File.stat(directory).birthtime
|
||||
else
|
||||
return File.stat(directory).ctime
|
||||
end
|
||||
else
|
||||
# Simulator directory is not yet created - treat it as if it was created right now (happens with new iOS 9 sims)
|
||||
return Time.now
|
||||
end
|
||||
end
|
||||
|
||||
# Deletes specified simulator
|
||||
def delete_device(device)
|
||||
execute_simctl_command("delete #{device.identifier}")
|
||||
end
|
||||
|
||||
puts("Searching for simulators...")
|
||||
|
||||
# Retrieve the list of existing simulators
|
||||
devices = []
|
||||
runtime = ""
|
||||
execute_simctl_command("list devices").lines.each do |line|
|
||||
case line[0]
|
||||
when '='
|
||||
# First header, skip it
|
||||
when '-'
|
||||
# Runtime header
|
||||
runtime = line.scan(/-- (.+?) --/).flatten[0]
|
||||
else
|
||||
name_and_identifier = line.scan(/\s+(.+?) \(([\w\d]+-[\w\d]+-[\w\d-]+)\)/)[0]
|
||||
name = name_and_identifier[0]
|
||||
identifier = name_and_identifier[1]
|
||||
timestamp = simulator_creation_date(identifier)
|
||||
device = SimDevice.new(runtime, name, identifier, timestamp)
|
||||
devices.push(device)
|
||||
end
|
||||
end
|
||||
|
||||
# Sort the simulators by their creation timestamp, ascending
|
||||
devices = devices.sort { |a, b| a.timestamp <=> b.timestamp }
|
||||
|
||||
duplicates = {}
|
||||
# Enumerate all devices except for the last one
|
||||
for i in 0..devices.count-2
|
||||
device = devices[i]
|
||||
# Enumerate all devices *after* this one (created *later*)
|
||||
for j in i+1..devices.count-1
|
||||
potential_duplicate = devices[j]
|
||||
if potential_duplicate.equivalent_to_device(device)
|
||||
duplicates[potential_duplicate] = device
|
||||
# Break out of the inner loop if a duplicate is found - if another duplicate exists,
|
||||
# it will be found when this one is reached in the outer loop
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if duplicates.count == 0
|
||||
puts("You don't have duplicate simulators!")
|
||||
exit()
|
||||
end
|
||||
|
||||
puts("Looks like you have #{duplicates.count} duplicate simulator#{duplicates.count > 1 ? "s" : ""}:")
|
||||
duplicates.each_pair do |duplicate, original|
|
||||
puts
|
||||
puts("#{duplicate}")
|
||||
puts("--- duplicate of ---")
|
||||
puts("#{original}")
|
||||
end
|
||||
puts
|
||||
|
||||
puts("Each duplicate was determined as the one created later than the 'original'.")
|
||||
|
||||
puts("Deleting...")
|
||||
duplicates.each_key do |duplicate|
|
||||
delete_device(duplicate)
|
||||
end
|
||||
|
||||
puts("Done!")
|
||||
|
||||
=begin
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2015-2019 Vlas Voloshin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
=end
|
||||
8
images/macos/scripts/build/disable-auto-updates.sh
Normal file
8
images/macos/scripts/build/disable-auto-updates.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# Disabling automatic updates
|
||||
sudo softwareupdate --schedule off
|
||||
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 0
|
||||
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 0
|
||||
defaults write com.apple.commerce AutoUpdate -bool false
|
||||
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool false
|
||||
61
images/macos/scripts/build/dotnet.sh
Normal file
61
images/macos/scripts/build/dotnet.sh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
###########################################################################
|
||||
# The main idea of this script is to automate dotnet installs
|
||||
# Based on:
|
||||
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
|
||||
#
|
||||
###########################################################################
|
||||
source ~/utils/utils.sh
|
||||
|
||||
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
|
||||
arch=$(get_arch)
|
||||
|
||||
# Download installer from dot.net and keep it locally
|
||||
DOTNET_INSTALL_SCRIPT="https://dot.net/v1/dotnet-install.sh"
|
||||
download_with_retries $DOTNET_INSTALL_SCRIPT .
|
||||
chmod +x ./dotnet-install.sh
|
||||
|
||||
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
|
||||
RELEASE_URL="https://raw.githubusercontent.com/dotnet/core/main/release-notes/${DOTNET_VERSION}/releases.json"
|
||||
download_with_retries "$RELEASE_URL" "/tmp" "dotnet_${DOTNET_VERSION}.json"
|
||||
|
||||
if [[ $DOTNET_VERSION == "6.0" ]]; then
|
||||
ARGS_LIST+=(
|
||||
$(cat /tmp/dotnet_${DOTNET_VERSION}.json | jq -r 'first(.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not))')
|
||||
)
|
||||
else
|
||||
ARGS_LIST+=(
|
||||
$(cat /tmp/dotnet_${DOTNET_VERSION}.json | \
|
||||
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
|
||||
./dotnet-install.sh --version $ARGS -NoPath --arch $arch
|
||||
done
|
||||
|
||||
rm ./dotnet-install.sh
|
||||
|
||||
# dotnet installer doesn't create symlink to executable in /user/local/bin
|
||||
# Moreover at that moment /user/local/bin doesn't exist (though already added to $PATH)
|
||||
ln -s ~/.dotnet/dotnet /usr/local/bin/dotnet
|
||||
|
||||
# Validate installation
|
||||
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 "Dotnet operations have been completed successfully..."
|
||||
|
||||
invoke_tests "Common" ".NET"
|
||||
63
images/macos/scripts/build/edge.sh
Normal file
63
images/macos/scripts/build/edge.sh
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
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)
|
||||
|
||||
echo "Version of Microsoft Edge: ${EDGE_VERSION}"
|
||||
|
||||
echo "Installing Microsoft Edge WebDriver..."
|
||||
|
||||
EDGE_DRIVER_VERSION_URL="https://msedgedriver.azureedge.net/LATEST_RELEASE_${EDGE_VERSION_MAJOR}_MACOS"
|
||||
download_with_retries "$EDGE_DRIVER_VERSION_URL" "/tmp" "edge-version"
|
||||
EDGE_DRIVER_LATEST_VERSION=$(cat /tmp/edge-version | iconv -f utf-16 -t utf-8 | 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}"
|
||||
|
||||
pushd "/tmp" > /dev/null
|
||||
download_with_retries $EDGE_DRIVER_URL "." "edgedriver.zip"
|
||||
|
||||
# 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
|
||||
|
||||
APPLICATION="/usr/local/bin/msedgedriver"
|
||||
EDGEDRIVER_DIR="/usr/local/share/edge_driver"
|
||||
EDGEDRIVER_BIN="$EDGEDRIVER_DIR/msedgedriver"
|
||||
|
||||
mkdir -p $EDGEDRIVER_DIR
|
||||
|
||||
unzip "edgedriver.zip" -d $EDGEDRIVER_DIR
|
||||
ln -s "$EDGEDRIVER_BIN" $APPLICATION
|
||||
echo "export EDGEWEBDRIVER=${EDGEDRIVER_DIR}" >> "${HOME}/.bashrc"
|
||||
popd > /dev/null
|
||||
|
||||
# Configure Edge Updater to prevent auto update
|
||||
# https://learn.microsoft.com/en-us/deployedge/edge-learnmore-edgeupdater-for-macos
|
||||
|
||||
sudo mkdir "/Library/Managed Preferences"
|
||||
|
||||
cat <<EOF | sudo tee "/Library/Managed Preferences/com.microsoft.EdgeUpdater.plist" > /dev/null
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>updatePolicies</key>
|
||||
<dict>
|
||||
<key>global</key>
|
||||
<dict>
|
||||
<key>UpdateDefault</key>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
sudo chown root:wheel "/Library/Managed Preferences/com.microsoft.EdgeUpdater.plist"
|
||||
|
||||
invoke_tests "Browsers" "Edge"
|
||||
43
images/macos/scripts/build/finalize-vm.sh
Normal file
43
images/macos/scripts/build/finalize-vm.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Close all finder windows because they can interfere with UI tests
|
||||
close_finder_window
|
||||
|
||||
# Remove Parallels Desktop
|
||||
# https://github.com/actions/runner-images/issues/6105
|
||||
if is_Monterey; then
|
||||
brew uninstall parallels
|
||||
fi
|
||||
|
||||
# Put documentation to $HOME root
|
||||
cp $HOME/image-generation/output/software-report/systeminfo.* $HOME/
|
||||
|
||||
# Put build vm assets scripts to proper directory
|
||||
mkdir -p /usr/local/opt/$USER/scripts
|
||||
mv $HOME/image-generation/assets/* /usr/local/opt/$USER/scripts
|
||||
|
||||
find /usr/local/opt/$USER/scripts -type f -name "*\.sh" -exec chmod +x {} \;
|
||||
|
||||
# Remove fastlane cached cookie
|
||||
rm -rf ~/.fastlane
|
||||
|
||||
# Clean up npm cache which collected during image-generation
|
||||
# we have to do that here because `npm install` is run in a few different places during image-generation
|
||||
npm cache clean --force
|
||||
|
||||
# Clean yarn cache
|
||||
yarn cache clean
|
||||
|
||||
# Clean up temporary directories
|
||||
sudo rm -rf ~/utils /tmp/*
|
||||
|
||||
# Erase all indexes and wait until the rebuilding process ends,
|
||||
# for now there is no way to get status of indexing process, it takes around 3 minutes to accomplish
|
||||
sudo mdutil -E /
|
||||
sudo log stream | grep -q -E 'mds.*Released.*BackgroundTask' || true
|
||||
echo "Indexing completed"
|
||||
|
||||
# delete symlink for tests running
|
||||
sudo rm -f /usr/local/bin/invoke_tests
|
||||
14
images/macos/scripts/build/firefox.sh
Normal file
14
images/macos/scripts/build/firefox.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "Installing Firefox..."
|
||||
brew install --cask firefox
|
||||
|
||||
echo "Installing Geckodriver..."
|
||||
brew_smart_install "geckodriver"
|
||||
geckoPath="$(brew --prefix geckodriver)/bin"
|
||||
|
||||
echo "Add GECKOWEBDRIVER to bashrc..."
|
||||
echo "export GECKOWEBDRIVER=${geckoPath}" >> "${HOME}/.bashrc"
|
||||
|
||||
invoke_tests "Browsers" "Firefox"
|
||||
51
images/macos/scripts/build/fix-xcode-simulators.ps1
Normal file
51
images/macos/scripts/build/fix-xcode-simulators.ps1
Normal file
@@ -0,0 +1,51 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Import-Module "$env:HOME/image-generation/helpers/Xcode.Helpers.psm1" -DisableNameChecking
|
||||
Import-Module "$env:HOME/image-generation/software-report/SoftwareReport.Xcode.psm1" -DisableNameChecking
|
||||
|
||||
function Ensure-SimulatorInstalled {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$RuntimeId,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$DeviceId,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$SimulatorName,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$XcodeVersion
|
||||
)
|
||||
|
||||
$simctlPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "simctl"
|
||||
if (-not (Test-Path $simctlPath)) {
|
||||
Write-Host "Skip validating simulator '$SimulatorName [$RuntimeId]' because Xcode $XcodeVersion is not installed"
|
||||
return
|
||||
}
|
||||
|
||||
$simulatorFullNameDebug = "$SimulatorName [$RuntimeId]"
|
||||
Write-Host "Checking Xcode simulator '$simulatorFullNameDebug' (Xcode $XcodeVersion)..."
|
||||
|
||||
# Get all available devices
|
||||
[string]$rawDevicesInfo = Invoke-Expression "$simctlPath list devices --json"
|
||||
$jsonDevicesInfo = ($rawDevicesInfo | ConvertFrom-Json).devices
|
||||
|
||||
# Checking if simulator already exists
|
||||
$existingSimulator = $jsonDevicesInfo.$RuntimeId | Where-Object { $_.deviceTypeIdentifier -eq $DeviceId } | Select-Object -First 1
|
||||
|
||||
if ($null -eq $existingSimulator) {
|
||||
Write-Host "Simulator '$simulatorFullNameDebug' is missed. Creating it..."
|
||||
Invoke-Expression "$simctlPath create '$SimulatorName' '$DeviceId' '$RuntimeId'"
|
||||
} elseif ($existingSimulator.name -ne $SimulatorName) {
|
||||
Write-Host "Simulator '$simulatorFullNameDebug' is named incorrectly. Renaming it from '$($existingSimulator.name)' to '$SimulatorName'..."
|
||||
Invoke-Expression "$simctlPath rename '$($existingSimulator.udid)' '$SimulatorName'"
|
||||
} else {
|
||||
Write-Host "Simulator '$simulatorFullNameDebug' is installed correctly."
|
||||
}
|
||||
}
|
||||
|
||||
# First run doesn't provide full data about devices
|
||||
Get-XcodeInfoList | Out-Null
|
||||
|
||||
Write-Host "Validating and fixing Xcode simulators..."
|
||||
Get-BrokenXcodeSimulatorsList | ForEach-Object {
|
||||
Ensure-SimulatorInstalled -RuntimeId $_.RuntimeId -DeviceId $_.DeviceId -SimulatorName $_.SimulatorName -XcodeVersion $_.XcodeVersion
|
||||
}
|
||||
16
images/macos/scripts/build/gcc.sh
Normal file
16
images/macos/scripts/build/gcc.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
gccVersions=$(get_toolset_value '.gcc.versions | .[]')
|
||||
|
||||
for gccVersion in $gccVersions; do
|
||||
brew_smart_install "gcc@${gccVersion}"
|
||||
done
|
||||
|
||||
# Delete default gfortran link if it exists https://github.com/actions/runner-images/issues/1280
|
||||
gfortranPath=$(which gfortran) || true
|
||||
if [ $gfortranPath ]; then
|
||||
rm $gfortranPath
|
||||
fi
|
||||
|
||||
invoke_tests "Common" "GCC"
|
||||
33
images/macos/scripts/build/git.sh
Normal file
33
images/macos/scripts/build/git.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing Git...
|
||||
brew_smart_install "git"
|
||||
|
||||
git config --global --add safe.directory "*"
|
||||
|
||||
echo Installing Git LFS
|
||||
brew_smart_install "git-lfs"
|
||||
|
||||
# Update global git config
|
||||
git lfs install
|
||||
# Update system git config
|
||||
sudo git lfs install --system
|
||||
|
||||
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
|
||||
git config --global advice.pushAlreadyExists false
|
||||
git config --global advice.pushFetchFirst false
|
||||
git config --global advice.pushNeedsForce false
|
||||
git config --global advice.statusHints false
|
||||
git config --global advice.statusUoption false
|
||||
git config --global advice.commitBeforeMerge false
|
||||
git config --global advice.resolveConflict false
|
||||
git config --global advice.implicitIdentity false
|
||||
git config --global advice.detachedHead false
|
||||
git config --global advice.amWorkDir false
|
||||
git config --global advice.rmHints false
|
||||
|
||||
invoke_tests "Git"
|
||||
11
images/macos/scripts/build/golang.sh
Normal file
11
images/macos/scripts/build/golang.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
DEFAULT_GO_VERSION=$(get_toolset_value '.go.default')
|
||||
echo "Installing Go..."
|
||||
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/
|
||||
|
||||
invoke_tests "Common" "Go"
|
||||
27
images/macos/scripts/build/haskell.sh
Normal file
27
images/macos/scripts/build/haskell.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
curl --proto '=https' --tlsv1.2 -fsSL https://get-ghcup.haskell.org | sh
|
||||
export PATH="$HOME/.ghcup/bin:$PATH"
|
||||
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}')
|
||||
|
||||
# Install 3 latest major versions(For instance 8.6.5, 8.8.4, 8.10.2)
|
||||
minorMajorVersions=$(echo "$availableVersions" | cut -d"." -f 1,2 | uniq | tail -n3)
|
||||
for majorMinorVersion in $minorMajorVersions; do
|
||||
fullVersion=$(echo "$availableVersions" | grep "$majorMinorVersion." | tail -n1)
|
||||
echo "install ghc version $fullVersion..."
|
||||
ghcup install $fullVersion
|
||||
ghcup set $fullVersion
|
||||
done
|
||||
|
||||
echo "install cabal..."
|
||||
ghcup install-cabal
|
||||
|
||||
echo "Updating stack..."
|
||||
ghcup install stack latest
|
||||
|
||||
invoke_tests "Haskell"
|
||||
39
images/macos/scripts/build/homebrew.sh
Normal file
39
images/macos/scripts/build/homebrew.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
arch=$(get_arch)
|
||||
|
||||
echo "Installing Homebrew..."
|
||||
download_with_retries "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" "/tmp" "homebrew-install.sh"
|
||||
/bin/bash /tmp/homebrew-install.sh
|
||||
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
/opt/homebrew/bin/brew update
|
||||
/opt/homebrew/bin/brew upgrade
|
||||
/opt/homebrew/bin/brew upgrade --cask
|
||||
/opt/homebrew/bin/brew cleanup
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
git clone https://github.com/Homebrew/homebrew-cask $(brew --repository)/Library/Taps/homebrew/homebrew-cask --origin=origin --template= --config core.fsmonitor=false --depth 1
|
||||
git clone https://github.com/Homebrew/homebrew-core $(brew --repository)/Library/Taps/homebrew/homebrew-core --origin=origin --template= --config core.fsmonitor=false --depth 1
|
||||
|
||||
brew tap homebrew/cask
|
||||
brew tap homebrew/core
|
||||
|
||||
echo "Disabling Homebrew analytics..."
|
||||
brew analytics off
|
||||
|
||||
# jq is required for further installation scripts
|
||||
echo "Installing jq..."
|
||||
brew_smart_install jq
|
||||
|
||||
echo "Installing curl..."
|
||||
brew_smart_install curl
|
||||
|
||||
echo "Installing wget..."
|
||||
brew_smart_install "wget"
|
||||
|
||||
# init brew bundle feature
|
||||
brew tap Homebrew/bundle
|
||||
8
images/macos/scripts/build/llvm.sh
Normal file
8
images/macos/scripts/build/llvm.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
llvmVersion=$(get_toolset_value '.llvm.version')
|
||||
|
||||
brew_smart_install "llvm@${llvmVersion}"
|
||||
|
||||
invoke_tests "LLVM"
|
||||
42
images/macos/scripts/build/max-files.sh
Normal file
42
images/macos/scripts/build/max-files.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
Launch_Daemons="/Library/LaunchDaemons"
|
||||
|
||||
# EOF in quotes to disable variable expansion
|
||||
echo "Creating limit.maxfiles.plist"
|
||||
cat > "${Launch_Daemons}/limit.maxfiles.plist" << EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>limit.maxfiles</string>
|
||||
<key>Program</key>
|
||||
<string>/Users/runner/limit-maxfiles.sh</string>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>ServiceIPC</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
# Creating script for applying workaround https://developer.apple.com/forums/thread/735798
|
||||
|
||||
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"
|
||||
|
||||
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"
|
||||
|
||||
21
images/macos/scripts/build/miniconda.sh
Normal file
21
images/macos/scripts/build/miniconda.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
download_with_retries "https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" "/tmp" "miniconda.sh"
|
||||
|
||||
chmod +x /tmp/miniconda.sh
|
||||
sudo /tmp/miniconda.sh -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"
|
||||
fi
|
||||
|
||||
echo "export CONDA=/usr/local/miniconda" >> $HOME/.bashrc
|
||||
|
||||
invoke_tests "Common" "Miniconda"
|
||||
18
images/macos/scripts/build/mongodb.sh
Normal file
18
images/macos/scripts/build/mongodb.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# MongoDB object-value database
|
||||
# Install latest release version of MongoDB Community Edition
|
||||
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x
|
||||
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"
|
||||
|
||||
if ! which mongo ; then
|
||||
brew link "$versionToInstall"
|
||||
fi
|
||||
|
||||
invoke_tests "Databases" "MongoDB"
|
||||
54
images/macos/scripts/build/mono.sh
Normal file
54
images/macos/scripts/build/mono.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
################################################################################
|
||||
## File: mono.sh
|
||||
## Desc: Installs Mono Framework
|
||||
################################################################################
|
||||
|
||||
# Source utility functions
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Create a temporary directory to store downloaded files
|
||||
TMP_DIR=$(mktemp -d /tmp/visualstudio.XXXX)
|
||||
|
||||
# Install Mono Framework
|
||||
MONO_VERSION_FULL=$(get_toolset_value '.mono.framework.version')
|
||||
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_PKG_NAME=${MONO_PKG_URL##*/}
|
||||
MONO_VERSIONS_PATH='/Library/Frameworks/Mono.framework/Versions'
|
||||
|
||||
download_with_retries "$MONO_PKG_URL" "$TMP_DIR"
|
||||
echo "Installing $MONO_PKG_NAME..."
|
||||
sudo installer -pkg "$TMP_DIR/$MONO_PKG_NAME" -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_NAME=${NUNIT_ARCHIVE_URL##*/}
|
||||
NUNIT_PATH="/Library/Developer/nunit"
|
||||
NUNIT_VERSION_PATH="$NUNIT_PATH/$NUNIT_VERSION"
|
||||
|
||||
download_with_retries "$NUNIT_ARCHIVE_URL" "$TMP_DIR"
|
||||
echo "Installing $NUNIT_ARCHIVE_NAME..."
|
||||
sudo mkdir -p "$NUNIT_VERSION_PATH"
|
||||
sudo unzip -q "$TMP_DIR/$NUNIT_ARCHIVE_NAME" -d "$NUNIT_VERSION_PATH"
|
||||
|
||||
# Create a wrapper script for nunit3-console
|
||||
echo "Creating nunit3-console wrapper..."
|
||||
NUNIT3_CONSOLE_WRAPPER=nunit3-console
|
||||
cat <<EOF > "${TMP_DIR}/${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 "${TMP_DIR}/${NUNIT3_CONSOLE_WRAPPER}"
|
||||
sudo chmod +x "${TMP_DIR}/${NUNIT3_CONSOLE_WRAPPER}"
|
||||
sudo mv "${TMP_DIR}/${NUNIT3_CONSOLE_WRAPPER}" "${MONO_VERSIONS_PATH}/${MONO_VERSION}/Commands/${NUNIT3_CONSOLE_WRAPPER}"
|
||||
|
||||
# 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}"
|
||||
|
||||
# Invoke tests for Xamarin and Mono
|
||||
invoke_tests "Xamarin" "Mono"
|
||||
8
images/macos/scripts/build/nginx.sh
Normal file
8
images/macos/scripts/build/nginx.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
brew_smart_install nginx
|
||||
sudo sed -Ei '' 's/listen.*/listen 80;/' $(brew --prefix)/etc/nginx/nginx.conf
|
||||
|
||||
invoke_tests "WebServers" "Nginx"
|
||||
22
images/macos/scripts/build/node.sh
Normal file
22
images/macos/scripts/build/node.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
defaultVersion=$(get_toolset_value '.node.default')
|
||||
|
||||
echo "Installing Node.js $defaultVersion"
|
||||
brew_smart_install "node@$defaultVersion"
|
||||
brew link node@$defaultVersion --force --overwrite
|
||||
|
||||
echo Installing yarn...
|
||||
download_with_retries "https://yarnpkg.com/install.sh" "/tmp" "yarn-install.sh"
|
||||
bash /tmp/yarn-install.sh
|
||||
|
||||
if is_BigSur || is_Monterey; then
|
||||
npm_global_packages=$(get_toolset_value '.npm.global_packages[].name')
|
||||
for module in ${npm_global_packages[@]}; do
|
||||
echo "Install $module"
|
||||
npm install -g $module
|
||||
done
|
||||
fi
|
||||
|
||||
invoke_tests "Node" "Node.js"
|
||||
15
images/macos/scripts/build/ntpconf.sh
Normal file
15
images/macos/scripts/build/ntpconf.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
echo Additional NTP servers adding into /etc/ntp.conf file...
|
||||
cat > /etc/ntp.conf << EOF
|
||||
server 0.pool.ntp.org
|
||||
server 1.pool.ntp.org
|
||||
server 2.pool.ntp.org
|
||||
server 3.pool.ntp.org
|
||||
server time.apple.com
|
||||
server time.windows.com
|
||||
EOF
|
||||
|
||||
# Set the timezone to UTC.
|
||||
echo The Timezone setting to UTC...
|
||||
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
|
||||
30
images/macos/scripts/build/nvm.sh
Normal file
30
images/macos/scripts/build/nvm.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
###########################################################################
|
||||
# The script installs node version manager with node versions 10,12 and 14
|
||||
#
|
||||
###########################################################################
|
||||
source ~/utils/utils.sh
|
||||
|
||||
[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
|
||||
VERSION=$(curl "${authString[@]}" -fsSL https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r '.tag_name')
|
||||
download_with_retries "https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh" "/tmp" "nvm-install.sh"
|
||||
bash /tmp/nvm-install.sh
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
. ~/.bashrc
|
||||
nvm --version
|
||||
nodeVersions=$(get_toolset_value '.node.nvm_versions[]')
|
||||
for version in ${nodeVersions[@]}
|
||||
do
|
||||
nvm install v${version}
|
||||
done
|
||||
|
||||
# set system node as default
|
||||
nvm alias default system
|
||||
else
|
||||
echo error
|
||||
fi
|
||||
|
||||
echo "Node version manager has been installed successfully"
|
||||
|
||||
invoke_tests "Node" "nvm"
|
||||
39
images/macos/scripts/build/open_windows_check.sh
Normal file
39
images/macos/scripts/build/open_windows_check.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Close System Preferences window because in Ventura arm64 it is opened by default on Apperance tab
|
||||
if is_Arm64; then
|
||||
echo "Close System Preferences window"
|
||||
osascript -e 'tell application "System Preferences" to quit'
|
||||
fi
|
||||
|
||||
retry=10
|
||||
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
|
||||
echo "No retry attempts left"
|
||||
exit 1
|
||||
fi
|
||||
sleep 30
|
||||
done
|
||||
IFS=',' read -r -a windowslist <<< "$openwindows"
|
||||
|
||||
if [ -n "${openwindows}" ]; then
|
||||
echo "Found opened window:"
|
||||
fi
|
||||
|
||||
for window in "${windowslist[@]}"; do
|
||||
if [[ $window =~ "NotificationCenter" ]]; then
|
||||
echo "[Warning] $window"
|
||||
else
|
||||
echo " - ${window}" | xargs
|
||||
scripterror=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${scripterror}" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
96
images/macos/scripts/build/openjdk.sh
Normal file
96
images/macos/scripts/build/openjdk.sh
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
createEnvironmentVariable() {
|
||||
local JAVA_VERSION=$1
|
||||
local DEFAULT=$2
|
||||
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
INSTALL_PATH_PATTERN=$(echo ${AGENT_TOOLSDIRECTORY}/Java_Temurin-Hotspot_jdk/${JAVA_VERSION}*/arm64/Contents/Home/)
|
||||
else
|
||||
INSTALL_PATH_PATTERN=$(echo ${AGENT_TOOLSDIRECTORY}/Java_Temurin-Hotspot_jdk/${JAVA_VERSION}*/x64/Contents/Home/)
|
||||
fi
|
||||
|
||||
if [[ ${DEFAULT} == "True" ]]; then
|
||||
echo "Setting up JAVA_HOME variable to ${INSTALL_PATH_PATTERN}"
|
||||
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"
|
||||
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"
|
||||
fi
|
||||
}
|
||||
|
||||
installOpenJDK() {
|
||||
local JAVA_VERSION=$1
|
||||
|
||||
# Get link for Java binaries and Java version
|
||||
download_with_retries "https://api.adoptium.net/v3/assets/latest/${JAVA_VERSION}/hotspot" "/tmp" "openjdk-hotspot.json"
|
||||
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
asset=$(jq -r '.[] | select(.binary.os=="mac" and .binary.image_type=="jdk" and .binary.architecture=="aarch64")' /tmp/openjdk-hotspot.json)
|
||||
else
|
||||
asset=$(jq -r '.[] | select(.binary.os=="mac" and .binary.image_type=="jdk" and .binary.architecture=="x64")' /tmp/openjdk-hotspot.json)
|
||||
fi
|
||||
|
||||
archivePath=$(echo ${asset} | jq -r '.binary.package.link')
|
||||
fullVersion=$(echo ${asset} | jq -r '.version.semver' | tr '+' '-')
|
||||
|
||||
# Remove 'LTS' suffix from the version if present
|
||||
fullVersion="${fullVersion//.LTS/}"
|
||||
|
||||
JAVA_TOOLCACHE_PATH=${AGENT_TOOLSDIRECTORY}/Java_Temurin-Hotspot_jdk
|
||||
javaToolcacheVersionPath=$JAVA_TOOLCACHE_PATH/${fullVersion}
|
||||
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
javaToolcacheVersionArchPath=${javaToolcacheVersionPath}/arm64
|
||||
else
|
||||
javaToolcacheVersionArchPath=${javaToolcacheVersionPath}/x64
|
||||
fi
|
||||
|
||||
# Download and extract Java binaries
|
||||
download_with_retries ${archivePath} /tmp OpenJDK-${fullVersion}.tar.gz
|
||||
|
||||
echo "Creating ${javaToolcacheVersionArchPath} directory"
|
||||
mkdir -p ${javaToolcacheVersionArchPath}
|
||||
|
||||
tar -xf /tmp/OpenJDK-${fullVersion}.tar.gz -C ${javaToolcacheVersionArchPath} --strip-components=1
|
||||
|
||||
# Create complete file
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
touch ${javaToolcacheVersionPath}/arm64.complete
|
||||
else
|
||||
touch ${javaToolcacheVersionPath}/x64.complete
|
||||
fi
|
||||
|
||||
# Create a symlink to '/Library/Java/JavaVirtualMachines'
|
||||
# so '/usr/libexec/java_home' will be able to find Java
|
||||
sudo ln -sf ${javaToolcacheVersionArchPath} /Library/Java/JavaVirtualMachines/Temurin-Hotspot-${JAVA_VERSION}.jdk
|
||||
}
|
||||
|
||||
arch=$(get_arch)
|
||||
defaultVersion=$(get_toolset_value '.java.'$arch'.default')
|
||||
jdkVersionsToInstall=($(get_toolset_value ".java.${arch}.versions[]"))
|
||||
|
||||
for jdkVersionToInstall in ${jdkVersionsToInstall[@]}; do
|
||||
installOpenJDK ${jdkVersionToInstall}
|
||||
|
||||
if [[ ${jdkVersionToInstall} == ${defaultVersion} ]]
|
||||
then
|
||||
createEnvironmentVariable ${jdkVersionToInstall} True
|
||||
else
|
||||
createEnvironmentVariable ${jdkVersionToInstall} False
|
||||
fi
|
||||
done
|
||||
|
||||
echo Installing Maven...
|
||||
brew_smart_install "maven"
|
||||
|
||||
echo Installing Gradle ...
|
||||
brew_smart_install "gradle"
|
||||
|
||||
invoke_tests "Java"
|
||||
20
images/macos/scripts/build/openssl.sh
Normal file
20
images/macos/scripts/build/openssl.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "Install openssl@1.1"
|
||||
brew_smart_install "openssl@1.1"
|
||||
|
||||
if ! is_Arm64; then
|
||||
# Symlink brew openssl@1.1 to `/usr/local/bin` as Homebrew refuses
|
||||
ln -sf $(brew --prefix openssl@1.1)/bin/openssl /usr/local/bin/openssl
|
||||
else
|
||||
# arm64 has a different installation prefix for brew
|
||||
ln -sf $(brew --prefix openssl@1.1)/bin/openssl /opt/homebrew/bin/openssl
|
||||
fi
|
||||
|
||||
if ! is_Arm64; then
|
||||
# Most of buildsystems and scripts look up ssl here
|
||||
ln -sf $(brew --cellar openssl@1.1)/1.1* /usr/local/opt/openssl
|
||||
fi
|
||||
|
||||
invoke_tests "OpenSSL"
|
||||
11
images/macos/scripts/build/php.sh
Normal file
11
images/macos/scripts/build/php.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing PHP
|
||||
phpVersionToolset=$(get_toolset_value '.php.version')
|
||||
brew_smart_install "php@${phpVersionToolset}"
|
||||
|
||||
echo Installing composer
|
||||
brew_smart_install "composer"
|
||||
|
||||
invoke_tests "PHP"
|
||||
21
images/macos/scripts/build/pipx-packages.sh
Normal file
21
images/macos/scripts/build/pipx-packages.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
export PATH="$PATH:/opt/pipx_bin"
|
||||
|
||||
toolset=$(get_toolset_path)
|
||||
pipx_packages=$(jq -r ".pipx[] .package" $toolset)
|
||||
|
||||
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
|
||||
done
|
||||
|
||||
invoke_tests "PipxPackages"
|
||||
33
images/macos/scripts/build/postgresql.sh
Normal file
33
images/macos/scripts/build/postgresql.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Fetch PostgreSQL version to install from the toolset
|
||||
toolsetVersion=$(get_toolset_value '.postgresql.version')
|
||||
|
||||
# Install latest version of PostgreSQL
|
||||
brew_smart_install postgresql@$toolsetVersion
|
||||
|
||||
# Service PostgreSQL should be started before use
|
||||
postgreService=$(brew services list | grep -oe "postgresql\S*")
|
||||
brew services start $postgreService
|
||||
|
||||
# Verify PostgreSQL is ready for accept incoming connections
|
||||
echo "Check PostgreSQL service is running"
|
||||
i=10
|
||||
COMMAND='pg_isready'
|
||||
while [ $i -gt 0 ]; do
|
||||
echo "Check PostgreSQL service status"
|
||||
eval $COMMAND && break
|
||||
((i--))
|
||||
if [ $i == 0 ]; then
|
||||
echo "PostgreSQL service not ready, all attempts exhausted"
|
||||
exit 1
|
||||
fi
|
||||
echo "PostgreSQL service not ready, wait 10 more sec, attempts left: $i"
|
||||
sleep 10
|
||||
done
|
||||
|
||||
# Stop PostgreSQL
|
||||
brew services stop $postgreService
|
||||
|
||||
invoke_tests "Databases" "PostgreSQL"
|
||||
55
images/macos/scripts/build/powershell.sh
Normal file
55
images/macos/scripts/build/powershell.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing PowerShell...
|
||||
arch=$(get_arch)
|
||||
|
||||
download_with_retries "https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json" "/tmp" "powershell-metadata.json"
|
||||
psver=$(cat /tmp/powershell-metadata.json | jq -r '.LTSReleaseTag[0]')
|
||||
psDownloadUrl=$(get_github_package_download_url "PowerShell/PowerShell" "contains(\"osx-$arch.pkg\")" "$psver" "$API_PAT")
|
||||
download_with_retries $psDownloadUrl "/tmp" "powershell.pkg"
|
||||
|
||||
# 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 /tmp/powershell.pkg
|
||||
|
||||
|
||||
sudo installer -pkg /tmp/powershell.pkg -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
|
||||
# Check MacOS architecture and sudo on Arm64
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
sudo pwsh -command "& {Install-Module $module -Force -Scope AllUsers}"
|
||||
else
|
||||
pwsh -command "& {Install-Module $module -Force -Scope AllUsers}"
|
||||
fi
|
||||
else
|
||||
for version in ${moduleVersions[@]}; do
|
||||
# Check MacOS architecture and sudo on Arm64
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
echo " - $version"
|
||||
sudo pwsh -command "& {Install-Module $module -RequiredVersion $version -Force -Scope AllUsers}"
|
||||
else
|
||||
echo " - $version"
|
||||
pwsh -command "& {Install-Module $module -RequiredVersion $version -Force -Scope AllUsers}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
# Fix permission root => runner after installing powershell for arm64 arch
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
sudo chown -R $USER ~/.local ~/.cache ~/.config
|
||||
fi
|
||||
|
||||
# A dummy call to initialize .IdentityService directory
|
||||
pwsh -command "& {Import-Module Az}"
|
||||
|
||||
# powershell link was removed in powershell-6.0.0-beta9
|
||||
sudo ln -s /usr/local/bin/pwsh /usr/local/bin/powershell
|
||||
|
||||
invoke_tests "Powershell"
|
||||
42
images/macos/scripts/build/preimagedata.sh
Normal file
42
images/macos/scripts/build/preimagedata.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
arch=$(get_arch)
|
||||
imagedata_file="$HOME/imagedata.json"
|
||||
image_version=$(echo $IMAGE_VERSION | cut -d _ -f 2)
|
||||
os_name=$(sw_vers -productName)
|
||||
os_version=$(sw_vers -productVersion)
|
||||
os_build=$(sw_vers -buildVersion)
|
||||
label_version=$(echo $os_version | cut -d. -f1)
|
||||
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
image_label="macos-${label_version}-arm64"
|
||||
else
|
||||
image_label="macos-${label_version}"
|
||||
fi
|
||||
release_label="macOS-${label_version}"
|
||||
|
||||
if is_VenturaX64 || is_SonomaX64; then
|
||||
software_url="https://github.com/actions/runner-images/blob/${image_label}/${image_version}/images/macos/${image_label}-Readme.md"
|
||||
releaseUrl="https://github.com/actions/runner-images/releases/tag/${image_label}%2F${image_version}"
|
||||
else
|
||||
software_url="https://github.com/actions/runner-images/blob/${release_label}/${image_version}/images/macos/${image_label}-Readme.md"
|
||||
releaseUrl="https://github.com/actions/runner-images/releases/tag/${release_label}%2F${image_version}"
|
||||
fi
|
||||
|
||||
cat <<EOF > $imagedata_file
|
||||
[
|
||||
{
|
||||
"group": "Operating System",
|
||||
"detail": "${os_name}\n${os_version}\n${os_build}"
|
||||
},
|
||||
{
|
||||
"group": "Runner Image",
|
||||
"detail": "Image: ${image_label}\nVersion: ${image_version}\nIncluded Software: ${software_url}\nImage Release: ${releaseUrl}"
|
||||
}
|
||||
]
|
||||
EOF
|
||||
|
||||
echo "export ImageVersion=$image_version" >> $HOME/.bashrc
|
||||
echo "export ImageOS=$IMAGE_OS" >> $HOME/.bashrc
|
||||
92
images/macos/scripts/build/pypy.sh
Normal file
92
images/macos/scripts/build/pypy.sh
Normal file
@@ -0,0 +1,92 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
################################################################################
|
||||
## File: pypy.sh
|
||||
## Desc: Installs PyPy
|
||||
################################################################################
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
function InstallPyPy
|
||||
{
|
||||
PACKAGE_URL=$1
|
||||
|
||||
PACKAGE_TAR_NAME=$(echo $PACKAGE_URL | awk -F/ '{print $NF}')
|
||||
echo "Downloading tar archive '$PACKAGE_TAR_NAME'"
|
||||
PACKAGE_TAR_TEMP_PATH="/tmp/$PACKAGE_TAR_NAME"
|
||||
download_with_retries $PACKAGE_URL "/tmp" "$PACKAGE_TAR_NAME"
|
||||
|
||||
echo "Expand '$PACKAGE_TAR_NAME' to the /tmp folder"
|
||||
tar xf $PACKAGE_TAR_TEMP_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
|
||||
PYPY_MAJOR="pypy$MAJOR_VERSION"
|
||||
else
|
||||
PYPY_MAJOR="pypy"
|
||||
fi
|
||||
|
||||
PACKAGE_TEMP_FOLDER="/tmp/$PACKAGE_NAME"
|
||||
PYTHON_FULL_VERSION=$("$PACKAGE_TEMP_FOLDER/bin/$PYPY_MAJOR" -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))")
|
||||
PYPY_FULL_VERSION=$("$PACKAGE_TEMP_FOLDER/bin/$PYPY_MAJOR" -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))")
|
||||
echo "Put '$PYPY_FULL_VERSION' to PYPY_VERSION file"
|
||||
echo $PYPY_FULL_VERSION > "$PACKAGE_TEMP_FOLDER/PYPY_VERSION"
|
||||
|
||||
# PyPy folder structure
|
||||
PYPY_TOOLCACHE_PATH=$AGENT_TOOLSDIRECTORY/PyPy
|
||||
PYPY_TOOLCACHE_VERSION_PATH=$PYPY_TOOLCACHE_PATH/$PYTHON_FULL_VERSION
|
||||
PYPY_TOOLCACHE_VERSION_ARCH_PATH=$PYPY_TOOLCACHE_VERSION_PATH/x64
|
||||
|
||||
echo "Check if PyPy hostedtoolcache folder exist..."
|
||||
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"
|
||||
mv $PACKAGE_TEMP_FOLDER $PYPY_TOOLCACHE_VERSION_ARCH_PATH
|
||||
|
||||
echo "Create additional symlinks (Required for UsePythonVersion Azure DevOps task)"
|
||||
cd $PYPY_TOOLCACHE_VERSION_ARCH_PATH/bin
|
||||
|
||||
PYPY_FULL_VERSION=$(./$PYPY_MAJOR -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))")
|
||||
echo "PYPY_FULL_VERSION is $PYPY_FULL_VERSION"
|
||||
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
|
||||
|
||||
chmod +x ./python ./$PYTHON_MAJOR
|
||||
|
||||
echo "Install latest Pip"
|
||||
./python -m ensurepip
|
||||
./python -m pip install --ignore-installed pip
|
||||
|
||||
echo "Create complete file"
|
||||
touch $PYPY_TOOLCACHE_VERSION_PATH/x64.complete
|
||||
|
||||
echo "Remove '$PACKAGE_TAR_TEMP_PATH'"
|
||||
rm -f $PACKAGE_TAR_TEMP_PATH
|
||||
}
|
||||
|
||||
arch=$(get_arch)
|
||||
download_with_retries "https://downloads.python.org/pypy/versions.json" "/tmp" "pypy-versions.json"
|
||||
toolsetVersions=$(get_toolset_value '.toolcache[] | select(.name | contains("PyPy")) | .arch.'$arch'.versions[]')
|
||||
|
||||
for toolsetVersion in $toolsetVersions; do
|
||||
latestMajorPyPyVersion=$(cat /tmp/pypy-versions.json |
|
||||
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'"
|
||||
exit 1
|
||||
fi
|
||||
InstallPyPy $latestMajorPyPyVersion
|
||||
done
|
||||
46
images/macos/scripts/build/python.sh
Normal file
46
images/macos/scripts/build/python.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "Installing Python Tooling"
|
||||
|
||||
if is_Monterey || is_BigSur; then
|
||||
echo "Install latest Python 2"
|
||||
Python2Url="https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg"
|
||||
download_with_retries $Python2Url "/tmp" "python2.pkg"
|
||||
|
||||
sudo installer -showChoiceChangesXML -pkg /tmp/python2.pkg -target / > /tmp/python2_choices.xml
|
||||
|
||||
# To avoid symlink conflicts, remove tools installation in /usr/local/bin using installer choices
|
||||
xmllint --shell /tmp/python2_choices.xml <<EOF
|
||||
cd //array/dict[string[text()='org.python.Python.PythonUnixTools-2.7']]/integer
|
||||
set 0
|
||||
save
|
||||
EOF
|
||||
|
||||
sudo installer -applyChoiceChangesXML /tmp/python2_choices.xml -pkg /tmp/python2.pkg -target /
|
||||
|
||||
pip install --upgrade pip
|
||||
|
||||
echo "Install Python2 certificates"
|
||||
bash -c "/Applications/Python\ 2.7/Install\ Certificates.command"
|
||||
fi
|
||||
|
||||
# Close Finder window
|
||||
if is_Veertu; then
|
||||
close_finder_window
|
||||
fi
|
||||
|
||||
echo "Brew Installing Python 3"
|
||||
brew_smart_install "python@3.11"
|
||||
|
||||
echo "Installing pipx"
|
||||
export PIPX_BIN_DIR=/usr/local/opt/pipx_bin
|
||||
export PIPX_HOME=/usr/local/opt/pipx
|
||||
|
||||
brew_smart_install "pipx"
|
||||
|
||||
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"
|
||||
3
images/macos/scripts/build/reboot.sh
Normal file
3
images/macos/scripts/build/reboot.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
shutdown -r now
|
||||
4
images/macos/scripts/build/rosetta.sh
Normal file
4
images/macos/scripts/build/rosetta.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
echo 'Installing Rosetta'
|
||||
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
|
||||
55
images/macos/scripts/build/ruby.sh
Normal file
55
images/macos/scripts/build/ruby.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
arch=$(get_arch)
|
||||
DEFAULT_RUBY_VERSION=$(get_toolset_value '.ruby.default')
|
||||
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
|
||||
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"
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
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"
|
||||
fi
|
||||
|
||||
if ! is_Arm64; then
|
||||
echo "Install Ruby from toolset..."
|
||||
[ -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"
|
||||
|
||||
echo "Check if Ruby hostedtoolcache folder exists..."
|
||||
if [ ! -d $RUBY_PATH ]; then
|
||||
mkdir -p $RUBY_PATH
|
||||
fi
|
||||
|
||||
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)
|
||||
RUBY_VERSION_PATH="$RUBY_PATH/$RUBY_VERSION"
|
||||
|
||||
echo "Create Ruby $RUBY_VERSION directory..."
|
||||
mkdir -p $RUBY_VERSION_PATH
|
||||
|
||||
echo "Downloading tar archive $PACKAGE_TAR_NAME"
|
||||
DOWNLOAD_URL="https://github.com/ruby/ruby-builder/releases/download/toolcache/${PACKAGE_TAR_NAME}"
|
||||
download_with_retries $DOWNLOAD_URL "/tmp" $PACKAGE_TAR_NAME
|
||||
|
||||
echo "Expand '$PACKAGE_TAR_NAME' to the '$RUBY_VERSION_PATH' folder"
|
||||
tar xf "/tmp/$PACKAGE_TAR_NAME" -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
|
||||
done
|
||||
fi
|
||||
invoke_tests "Ruby.$arch"
|
||||
18
images/macos/scripts/build/rubygem.sh
Normal file
18
images/macos/scripts/build/rubygem.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
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
|
||||
for gem in $gemsToInstall; do
|
||||
echo "Installing gem $gem"
|
||||
gem install $gem
|
||||
done
|
||||
fi
|
||||
|
||||
invoke_tests "RubyGem"
|
||||
23
images/macos/scripts/build/rust.sh
Normal file
23
images/macos/scripts/build/rust.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing Rustup...
|
||||
brew_smart_install "rustup-init"
|
||||
|
||||
echo Installing Rust language...
|
||||
rustup-init -y --no-modify-path --default-toolchain=stable --profile=minimal
|
||||
|
||||
echo Initialize environment variables...
|
||||
CARGO_HOME=$HOME/.cargo
|
||||
|
||||
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...
|
||||
rm -rf $CARGO_HOME/registry/*
|
||||
|
||||
invoke_tests "Rust"
|
||||
16
images/macos/scripts/build/safari.sh
Normal file
16
images/macos/scripts/build/safari.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
echo "Enabling safari driver..."
|
||||
# https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari
|
||||
# Safari’s executable is located at /usr/bin/safaridriver
|
||||
# Configure Safari to Enable WebDriver Support
|
||||
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
|
||||
/usr/libexec/PlistBuddy -c 'delete AllowRemoteAutomation' $safari_plist || true
|
||||
/usr/libexec/PlistBuddy -c 'add AllowRemoteAutomation bool true' $safari_plist
|
||||
|
||||
invoke_tests "Browsers" "Safari"
|
||||
26
images/macos/scripts/build/screensaver-off.sh
Normal file
26
images/macos/scripts/build/screensaver-off.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# set screensaver idleTime to 0, to prevent turning screensaver on
|
||||
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
|
||||
rm -rf /Users/$USERNAME/Library/Preferences/com.apple.screensaver.plist
|
||||
rm -rf /Users/$USERNAME/Library/Preferences/ByHost/com.apple.screensaver.plist
|
||||
|
||||
defaults write /Users/$USERNAME/Library/Preferences/com.apple.screensaver.$macUUID.plist idleTime -string 0
|
||||
defaults write /Users/$USERNAME/Library/Preferences/com.apple.screensaver.$macUUID.plist CleanExit "YES"
|
||||
defaults write /Users/$USERNAME/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist idleTime -string 0
|
||||
defaults write /Users/$USERNAME/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist CleanExit "YES"
|
||||
defaults write /Users/$USERNAME/Library/Preferences/com.apple.screensaver.plist idleTime -string 0
|
||||
defaults write /Users/$USERNAME/Library/Preferences/com.apple.screensaver.plist CleanExit "YES"
|
||||
defaults write /Users/$USERNAME/Library/Preferences/ByHost/com.apple.screensaver.plist idleTime -string 0
|
||||
defaults write /Users/$USERNAME/Library/Preferences/ByHost/com.apple.screensaver.plist CleanExit "YES"
|
||||
|
||||
chown -R $USERNAME:staff /Users/$USERNAME/Library/Preferences/ByHost/
|
||||
chown -R $USERNAME:staff /Users/$USERNAME/Library/Preferences/
|
||||
|
||||
killall cfprefsd
|
||||
|
||||
# Set values to 0, to prevent sleep at all
|
||||
pmset -a displaysleep 0 sleep 0 disksleep 0
|
||||
14
images/macos/scripts/build/shell-change.sh
Normal file
14
images/macos/scripts/build/shell-change.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
arch=$(get_arch)
|
||||
|
||||
echo "Changing shell to bash"
|
||||
sudo chsh -s /bin/bash $USERNAME
|
||||
sudo chsh -s /bin/bash root
|
||||
|
||||
# Check MacOS architecture and add HOMEBREW PATH to bashrc
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
echo "Adding Homebrew environment to bash"
|
||||
/opt/homebrew/bin/brew shellenv >> ~/.bashrc
|
||||
fi
|
||||
16
images/macos/scripts/build/swiftlint.sh
Normal file
16
images/macos/scripts/build/swiftlint.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
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)
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_FROM_API=1 brew install swiftlint
|
||||
else
|
||||
brew_smart_install "swiftlint"
|
||||
fi
|
||||
|
||||
invoke_tests "Linters" "SwiftLint"
|
||||
58
images/macos/scripts/build/toolset.ps1
Normal file
58
images/macos/scripts/build/toolset.ps1
Normal file
@@ -0,0 +1,58 @@
|
||||
################################################################################
|
||||
## File: toolset.ps1
|
||||
## Team: CI-Build
|
||||
## Desc: Install toolset
|
||||
################################################################################
|
||||
Import-Module "~/image-generation/helpers/Tests.Helpers.psm1"
|
||||
Import-Module "~/image-generation/helpers/Common.Helpers.psm1"
|
||||
|
||||
Function Install-Asset {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[object] $ReleaseAsset
|
||||
)
|
||||
|
||||
$assetFolderPath = Join-Path "/tmp" "$($ReleaseAsset.filename)-temp-dir"
|
||||
New-Item -ItemType Directory -Path $assetFolderPath | Out-Null
|
||||
$assetArchivePath = Join-Path $assetFolderPath $ReleaseAsset.filename
|
||||
|
||||
Write-Host "Download $($ReleaseAsset.filename) archive to the $assetFolderPath folder..."
|
||||
Start-DownloadWithRetry -Url $ReleaseAsset.download_url -DownloadPath $assetFolderPath
|
||||
|
||||
Write-Host "Extract $($ReleaseAsset.filename) content..."
|
||||
tar -xzf $assetArchivePath -C $assetFolderPath
|
||||
|
||||
Write-Host "Invoke installation script..."
|
||||
Push-Location -Path $assetFolderPath
|
||||
Invoke-Expression "bash ./setup.sh"
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
$arch = Get-Architecture
|
||||
|
||||
# Get toolcache content from toolset
|
||||
$toolsToInstall = @("Python", "Node", "Go")
|
||||
$tools = Get-ToolsetValue "toolcache" | Where-Object {$toolsToInstall -contains $_.Name}
|
||||
|
||||
foreach ($tool in $tools) {
|
||||
# Get versions manifest for current tool
|
||||
$assets = Invoke-RestMethodWithRetry -Url $tool.url
|
||||
|
||||
# Get github release asset for each version
|
||||
foreach ($version in $tool.arch.$arch.versions) {
|
||||
$asset = $assets | Where-Object version -like $version `
|
||||
| Select-Object -ExpandProperty files `
|
||||
| Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $arch)} `
|
||||
| Select-Object -First 1
|
||||
|
||||
Write-Host "Installing $($tool.name) $version..."
|
||||
if ($null -ne $asset) {
|
||||
Install-Asset -ReleaseAsset $asset
|
||||
} else {
|
||||
Write-Host "Asset was not found in versions manifest"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-PesterTests "Toolcache"
|
||||
22
images/macos/scripts/build/vcpkg.sh
Normal file
22
images/macos/scripts/build/vcpkg.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Set env variable for vcpkg
|
||||
VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg
|
||||
echo "export VCPKG_INSTALLATION_ROOT=${VCPKG_INSTALLATION_ROOT}" | tee -a ~/.bashrc
|
||||
|
||||
# workaround https://github.com/microsoft/vcpkg/issues/27786
|
||||
|
||||
mkdir -p /Users/runner/.vcpkg
|
||||
touch /Users/runner/.vcpkg/vcpkg.path.txt
|
||||
|
||||
# Install vcpkg
|
||||
git clone https://github.com/Microsoft/vcpkg $VCPKG_INSTALLATION_ROOT
|
||||
$VCPKG_INSTALLATION_ROOT/bootstrap-vcpkg.sh
|
||||
$VCPKG_INSTALLATION_ROOT/vcpkg integrate install
|
||||
chmod -R 0777 $VCPKG_INSTALLATION_ROOT
|
||||
ln -sf $VCPKG_INSTALLATION_ROOT/vcpkg /usr/local/bin
|
||||
|
||||
rm -rf /Users/runner/.vcpkg
|
||||
|
||||
invoke_tests "Common" "vcpkg"
|
||||
49
images/macos/scripts/build/vsmac.sh
Normal file
49
images/macos/scripts/build/vsmac.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
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')
|
||||
else
|
||||
VSMAC_DOWNLOAD_URL=$(buildVSMacDownloadUrl $VSMAC_VERSION)
|
||||
fi
|
||||
|
||||
echo "Installing Visual Studio ${VSMAC_VERSION} for Mac"
|
||||
TMPMOUNT=`/usr/bin/mktemp -d /tmp/visualstudio.XXXX`
|
||||
TMPMOUNT_DOWNLOADS="$TMPMOUNT/downloads"
|
||||
mkdir $TMPMOUNT_DOWNLOADS
|
||||
|
||||
download_with_retries $VSMAC_DOWNLOAD_URL $TMPMOUNT_DOWNLOADS
|
||||
|
||||
echo "Mounting Visual Studio..."
|
||||
VISUAL_STUDIO_NAME=${VSMAC_DOWNLOAD_URL##*/}
|
||||
hdiutil attach "$TMPMOUNT_DOWNLOADS/$VISUAL_STUDIO_NAME" -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"
|
||||
fi
|
||||
|
||||
popd
|
||||
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
|
||||
install_vsmac $VERSION $DEFAULT_VSMAC_VERSION
|
||||
done
|
||||
|
||||
invoke_tests "Common" "VSMac"
|
||||
84
images/macos/scripts/build/xamarin.sh
Normal file
84
images/macos/scripts/build/xamarin.sh
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
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')
|
||||
|
||||
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'
|
||||
|
||||
TMPMOUNT=`/usr/bin/mktemp -d /tmp/visualstudio.XXXX`
|
||||
TMPMOUNT_FRAMEWORKS="$TMPMOUNT/frameworks"
|
||||
createBackupFolders
|
||||
|
||||
pushd $TMPMOUNT
|
||||
|
||||
# Download NUnit console
|
||||
downloadNUnitConsole
|
||||
|
||||
# Install Mono sdks
|
||||
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
|
||||
sudo mv -v $TMPMOUNT_FRAMEWORKS/ios/* $IOS_VERSIONS_PATH/
|
||||
|
||||
# Install Xamarin.Mac sdks
|
||||
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
|
||||
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<BUNDLES_COUNT; BUNDLE_INDEX++)); do
|
||||
SYMLINK=$(get_toolset_value ".xamarin.bundles[$BUNDLE_INDEX].symlink")
|
||||
MONO=$(get_toolset_value ".xamarin.bundles[$BUNDLE_INDEX].mono")
|
||||
IOS=$(get_toolset_value ".xamarin.bundles[$BUNDLE_INDEX].ios")
|
||||
MAC=$(get_toolset_value ".xamarin.bundles[$BUNDLE_INDEX].mac")
|
||||
ANDROID=$(get_toolset_value ".xamarin.bundles[$BUNDLE_INDEX].android")
|
||||
createBundle $SYMLINK $MONO $IOS $MAC $ANDROID
|
||||
done
|
||||
|
||||
# Symlinks for the latest Xamarin bundle
|
||||
createBundleLink $LATEST_SDK_SYMLINK "Latest"
|
||||
createBundleLink $CURRENT_SDK_SYMLINK "Current"
|
||||
|
||||
#
|
||||
# Fix nuget in some mono versions because of known bugs
|
||||
#
|
||||
|
||||
# Creating UWP Shim to hack UWP build failure
|
||||
createUWPShim
|
||||
|
||||
popd
|
||||
|
||||
echo "Clean up packages..."
|
||||
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"
|
||||
mkdir -p $PREFERENCES_XAMARIN_DIR
|
||||
/usr/libexec/PlistBuddy -c "add :AppleSdkRoot string /Applications/Xcode_${DEFAULT_XCODE_VERSION}.app" $PREFERENCES_XAMARIN_DIR/Settings.plist
|
||||
|
||||
# Temporary workaround to recreate nuget.config file with a correct feed https://github.com/actions/runner-images/issues/5768
|
||||
rm -rf $HOME/.config/NuGet/NuGet.Config
|
||||
nuget config
|
||||
|
||||
invoke_tests "Xamarin"
|
||||
46
images/macos/scripts/build/xcode-clt.sh
Normal file
46
images/macos/scripts/build/xcode-clt.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
is_clt_installed() {
|
||||
clt_path=`xcode-select -p 2>&1`
|
||||
[[ -d "$clt_path" ]]
|
||||
}
|
||||
|
||||
install_clt() {
|
||||
echo "Searching online for the Command Line Tools"
|
||||
# This temporary file prompts the 'softwareupdate' utility to list the Command Line Tools
|
||||
clt_placeholder="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"
|
||||
sudo touch $clt_placeholder
|
||||
cltPattern="Command Line Tools"
|
||||
|
||||
clt_label_command="/usr/sbin/softwareupdate -l |
|
||||
grep -B 1 -E '${cltPattern}' |
|
||||
awk -F'*' '/^ *\\*/ {print \$2}' |
|
||||
sed -e 's/^ *Label: //' -e 's/^ *//' |
|
||||
sort -V |
|
||||
tail -n1"
|
||||
clt_label=$(eval $clt_label_command) || true
|
||||
if [[ -n "$clt_label" ]]; then
|
||||
echo "Installing $clt_label"
|
||||
sudo "/usr/sbin/softwareupdate" "-i" "$clt_label"
|
||||
fi
|
||||
sudo "/bin/rm" "-f" "$clt_placeholder"
|
||||
}
|
||||
|
||||
echo "Installing Command Line Tools..."
|
||||
install_clt
|
||||
|
||||
# Retry the installation if tools are not installed from the first attempt
|
||||
retries=30
|
||||
sleepInterval=60
|
||||
while ! is_clt_installed; do
|
||||
if [[ $retries -eq 0 ]]; then
|
||||
echo "Unable to find the Command Line Tools, all the attempts exhausted"
|
||||
exit 1
|
||||
fi
|
||||
echo "Command Line Tools not found, trying to install them via softwareupdates, $retries attempts left"
|
||||
install_clt
|
||||
((retries--))
|
||||
echo "Wait $sleepInterval seconds before the next check for installed Command Line Tools"
|
||||
sleep $sleepInterval
|
||||
done
|
||||
30
images/macos/scripts/build/xcode-postbuild.sh
Normal file
30
images/macos/scripts/build/xcode-postbuild.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
XCODE_LIST=($(get_toolset_value '.xcode.versions | reverse | .[].link'))
|
||||
DEFAULT_XCODE_VERSION=$(get_toolset_value '.xcode.default')
|
||||
|
||||
# https://github.com/microsoft/appcenter/issues/847
|
||||
# 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
|
||||
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"
|
||||
|
||||
# Erase a device's contents and settings
|
||||
xcrun simctl erase all
|
||||
|
||||
#add sleep due to sometimes "xcrun simctl list" takes more than a few moments and script fails when trying to remove CoreSimulatorSerivce
|
||||
sleep 10
|
||||
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"
|
||||
25
images/macos/scripts/build/xcode-sims.sh
Normal file
25
images/macos/scripts/build/xcode-sims.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
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."
|
||||
67
images/macos/scripts/build/xcode.ps1
Normal file
67
images/macos/scripts/build/xcode.ps1
Normal file
@@ -0,0 +1,67 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Import-Module "$env:HOME/image-generation/helpers/Common.Helpers.psm1"
|
||||
Import-Module "$env:HOME/image-generation/helpers/Xcode.Installer.psm1" -DisableNameChecking
|
||||
|
||||
$ARCH = Get-Architecture
|
||||
[Array]$xcodeVersions = Get-ToolsetValue "xcode.$ARCH.versions"
|
||||
write-host $xcodeVersions
|
||||
$defaultXcode = Get-ToolsetValue "xcode.default"
|
||||
[Array]::Reverse($xcodeVersions)
|
||||
$threadCount = "5"
|
||||
|
||||
Write-Host "Installing Xcode versions..."
|
||||
$xcodeVersions | ForEach-Object -ThrottleLimit $threadCount -Parallel {
|
||||
$ErrorActionPreference = "Stop"
|
||||
Import-Module "$env:HOME/image-generation/helpers/Common.Helpers.psm1"
|
||||
Import-Module "$env:HOME/image-generation/helpers/Xcode.Installer.psm1" -DisableNameChecking
|
||||
|
||||
Install-XcodeVersion -Version $_.version -LinkTo $_.link
|
||||
Confirm-XcodeIntegrity -Version $_.link
|
||||
}
|
||||
|
||||
$xcodeVersions | ForEach-Object {
|
||||
Approve-XcodeLicense -Version $_.link
|
||||
}
|
||||
|
||||
Write-Host "Configuring Xcode versions..."
|
||||
$xcodeVersions | ForEach-Object {
|
||||
Write-Host "Configuring Xcode $($_.link) ..."
|
||||
Invoke-XcodeRunFirstLaunch -Version $_.link
|
||||
|
||||
if ($_.install_runtimes -eq 'true') {
|
||||
# Additional simulator runtimes are included by default for Xcode < 14
|
||||
Install-AdditionalSimulatorRuntimes -Version $_.link
|
||||
}
|
||||
|
||||
ForEach($runtime in $_.runtimes) {
|
||||
Write-Host "Installing Additional runtimes for Xcode '$runtime' ..."
|
||||
$xcodebuildPath = Get-XcodeToolPath -Version $_.link -ToolName 'xcodebuild'
|
||||
Invoke-ValidateCommand "sudo $xcodebuildPath -downloadPlatform $runtime" | Out-Null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Invoke-XcodeRunFirstLaunch -Version $defaultXcode
|
||||
|
||||
Write-Host "Configuring Xcode symlinks..."
|
||||
$xcodeVersions | ForEach-Object {
|
||||
Build-XcodeSymlinks -Version $_.link -Symlinks $_.symlinks
|
||||
|
||||
# Skip creating symlink to install multiple releases of the same Xcode version side-by-side
|
||||
if ($_."skip-symlink" -ne "true") {
|
||||
Build-ProvisionatorSymlink -Version $_.link
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Rebuilding Launch Services database ..."
|
||||
$xcodeVersions | ForEach-Object {
|
||||
Rebuild-XcodeLaunchServicesDb -Version $_.link
|
||||
}
|
||||
|
||||
Write-Host "Setting default Xcode to $defaultXcode"
|
||||
Switch-Xcode -Version $defaultXcode
|
||||
New-Item -Path "/Applications/Xcode.app" -ItemType SymbolicLink -Value (Get-XcodeRootPath -Version $defaultXcode) | Out-Null
|
||||
|
||||
Write-Host "Setting environment variables 'XCODE_<VERSION>_DEVELOPER_DIR'"
|
||||
Set-XcodeDeveloperDirEnvironmentVariables -XcodeList $xcodeVersions.link
|
||||
201
images/macos/scripts/docs-gen/SoftwareReport.Android.psm1
Normal file
201
images/macos/scripts/docs-gen/SoftwareReport.Android.psm1
Normal file
@@ -0,0 +1,201 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/SoftwareReport.Helpers.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
|
||||
function Split-TableRowByColumns {
|
||||
param(
|
||||
[string] $Row
|
||||
)
|
||||
return $Row.Split("|") | ForEach-Object { $_.trim() }
|
||||
}
|
||||
|
||||
function Get-AndroidSDKRoot {
|
||||
return Join-Path $env:HOME "Library" "Android" "sdk"
|
||||
}
|
||||
|
||||
function Get-AndroidSDKManagerPath {
|
||||
$androidSDKDir = Get-AndroidSDKRoot
|
||||
return Join-Path $androidSDKDir "cmdline-tools" "latest" "bin" "sdkmanager"
|
||||
}
|
||||
|
||||
function Get-AndroidInstalledPackages {
|
||||
$androidSDKManagerPath = Get-AndroidSDKManagerPath
|
||||
$androidSDKManagerList = Invoke-Expression "$androidSDKManagerPath --list_installed"
|
||||
return $androidSDKManagerList
|
||||
}
|
||||
|
||||
function Get-AndroidPackages {
|
||||
$androidSDKDir = Get-AndroidSDKRoot
|
||||
$androidSDKManagerPath = Get-AndroidSDKManagerPath
|
||||
|
||||
$packagesListFile = Join-Path $androidSDKDir "packages-list.txt"
|
||||
|
||||
if (-Not (Test-Path -Path $packagesListFile -PathType Leaf)) {
|
||||
(& $androidSDKManagerPath --list --verbose) |
|
||||
Where-Object { $_ -Match "^[^\s]" } |
|
||||
Where-Object { $_ -NotMatch "^(Loading |Info: Parsing |---|\[=+|Installed |Available )" } |
|
||||
Where-Object { $_ -NotMatch "^[^;]*$" } |
|
||||
Out-File -FilePath $packagesListFile
|
||||
|
||||
Write-Host Android packages list:
|
||||
Get-Content $packagesListFile
|
||||
}
|
||||
|
||||
return Get-Content $packagesListFile
|
||||
}
|
||||
|
||||
function Build-AndroidTable {
|
||||
Write-Host "Build-AndroidTable"
|
||||
$packageInfo = Get-AndroidInstalledPackages
|
||||
return @(
|
||||
@{
|
||||
"Package" = "Android Command Line Tools"
|
||||
"Version" = Get-AndroidCommandLineToolsVersion
|
||||
},
|
||||
@{
|
||||
"Package" = "Android Emulator"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Emulator"
|
||||
},
|
||||
@{
|
||||
"Package" = "Android SDK Build-tools"
|
||||
"Version" = Get-AndroidBuildToolVersions -PackageInfo $packageInfo
|
||||
},
|
||||
@{
|
||||
"Package" = "Android SDK Platforms"
|
||||
"Version" = Get-AndroidPlatformVersions -PackageInfo $packageInfo
|
||||
},
|
||||
@{
|
||||
"Package" = "Android SDK Platform-Tools"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Platform-Tools"
|
||||
},
|
||||
@{
|
||||
"Package" = "Android SDK Tools"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Tools"
|
||||
},
|
||||
@{
|
||||
"Package" = "Android Support Repository"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Support Repository"
|
||||
},
|
||||
@{
|
||||
"Package" = "CMake"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "cmake"
|
||||
},
|
||||
@{
|
||||
"Package" = "Google APIs"
|
||||
"Version" = Get-AndroidGoogleAPIsVersions -PackageInfo $packageInfo
|
||||
},
|
||||
@{
|
||||
"Package" = "Google Play services"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Play services"
|
||||
},
|
||||
@{
|
||||
"Package" = "Google Repository"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Repository"
|
||||
},
|
||||
@{
|
||||
"Package" = "NDK"
|
||||
"Version" = Get-AndroidNDKVersions
|
||||
},
|
||||
@{
|
||||
"Package" = "SDK Patch Applier v4"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "SDK Patch Applier v4"
|
||||
}
|
||||
) | Where-Object { $_.Version } | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
"Package Name" = $_.Package
|
||||
"Version" = $_.Version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Build-AndroidEnvironmentTable {
|
||||
$androidVersions = Get-Item env:ANDROID_*
|
||||
|
||||
$shoulddResolveLink = 'ANDROID_NDK', 'ANDROID_NDK_HOME', 'ANDROID_NDK_ROOT', 'ANDROID_NDK_LATEST_HOME'
|
||||
return $androidVersions | Sort-Object -Property Name | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
"Name" = $_.Name
|
||||
"Value" = if ($shoulddResolveLink.Contains($_.Name )) { Get-PathWithLink($_.Value) } else { $_.Value }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-AndroidPackageVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo,
|
||||
[Parameter(Mandatory)]
|
||||
[object] $MatchedString
|
||||
)
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match $MatchedString } | ForEach-Object {
|
||||
$packageInfoParts = Split-TableRowByColumns $_
|
||||
return $packageInfoParts[1]
|
||||
}
|
||||
return ($versions -Join "<br>")
|
||||
}
|
||||
|
||||
function Get-AndroidPlatformVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo
|
||||
)
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match "Android SDK Platform " } | ForEach-Object {
|
||||
$packageInfoParts = Split-TableRowByColumns $_
|
||||
$revision = $packageInfoParts[1]
|
||||
$version = $packageInfoParts[0].split(";")[1]
|
||||
return "$version (rev $revision)"
|
||||
}
|
||||
[array]::Reverse($versions)
|
||||
return ($versions -Join "<br>")
|
||||
}
|
||||
|
||||
function Get-AndroidCommandLineToolsVersion {
|
||||
$commandLineTools = Get-AndroidSDKManagerPath
|
||||
(& $commandLineTools --version | Out-String).Trim() -match "(?<version>^(\d+\.){1,}\d+$)" | Out-Null
|
||||
$commandLineToolsVersion = $Matches.Version
|
||||
return $commandLineToolsVersion
|
||||
}
|
||||
|
||||
function Get-AndroidBuildToolVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo
|
||||
)
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match "Android SDK Build-Tools" } | ForEach-Object {
|
||||
$packageInfoParts = Split-TableRowByColumns $_
|
||||
return $packageInfoParts[1]
|
||||
}
|
||||
$groupVersions = @()
|
||||
$versions | ForEach-Object {
|
||||
$majorVersion = $_.Split(".")[0]
|
||||
$groupVersions += $versions | Where-Object { $_.StartsWith($majorVersion) } | Join-String -Separator " "
|
||||
}
|
||||
return ($groupVersions | Sort-Object -Descending -Unique | Join-String -Separator "<br>")
|
||||
}
|
||||
|
||||
function Get-AndroidGoogleAPIsVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo
|
||||
)
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match "Google APIs" } | ForEach-Object {
|
||||
$packageInfoParts = Split-TableRowByColumns $_
|
||||
return $packageInfoParts[0].split(";")[1]
|
||||
}
|
||||
return ($versions -Join "<br>")
|
||||
}
|
||||
|
||||
function Get-AndroidNDKVersions {
|
||||
$ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk"
|
||||
$versions += Get-ChildItem -Path $ndkFolderPath -Name
|
||||
$ndkDefaultVersion = Get-ToolsetValue "android.ndk.default"
|
||||
$ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1
|
||||
|
||||
return ($versions | ForEach-Object {
|
||||
$defaultPostfix = ( $_ -eq $ndkDefaultFullVersion ) ? " (default)" : ""
|
||||
$_ + $defaultPostfix
|
||||
} | Join-String -Separator "<br>")
|
||||
}
|
||||
117
images/macos/scripts/docs-gen/SoftwareReport.Browsers.psm1
Normal file
117
images/macos/scripts/docs-gen/SoftwareReport.Browsers.psm1
Normal file
@@ -0,0 +1,117 @@
|
||||
function Build-BrowserSection {
|
||||
|
||||
$nodes = @()
|
||||
$os = Get-OSVersion
|
||||
|
||||
$nodes += @(
|
||||
[ToolVersionNode]::new("Safari", $(Get-SafariVersion))
|
||||
[ToolVersionNode]::new("SafariDriver", $(Get-SafariDriverVersion))
|
||||
[ToolVersionNode]::new("Google Chrome", $(Get-ChromeVersion))
|
||||
[ToolVersionNode]::new("Google Chrome for Testing", $(Get-ChromeForTestingVersion))
|
||||
[ToolVersionNode]::new("ChromeDriver", $(Get-ChromeDriverVersion))
|
||||
)
|
||||
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$nodes += @(
|
||||
[ToolVersionNode]::new("Microsoft Edge", $(Get-EdgeVersion))
|
||||
[ToolVersionNode]::new("Microsoft Edge WebDriver", $(Get-EdgeDriverVersion))
|
||||
[ToolVersionNode]::new("Mozilla Firefox", $(Get-FirefoxVersion))
|
||||
[ToolVersionNode]::new("geckodriver", $(Get-GeckodriverVersion))
|
||||
)
|
||||
}
|
||||
|
||||
$nodes += @(
|
||||
[ToolVersionNode]::new("Selenium server", $(Get-SeleniumVersion))
|
||||
)
|
||||
|
||||
return $nodes
|
||||
}
|
||||
|
||||
function Get-SafariVersion {
|
||||
$version = Run-Command "defaults read /Applications/Safari.app/Contents/Info CFBundleShortVersionString"
|
||||
$build = Run-Command "defaults read /Applications/Safari.app/Contents/Info CFBundleVersion"
|
||||
return "$version ($build)"
|
||||
}
|
||||
|
||||
function Get-SafariDriverVersion {
|
||||
$version = Run-Command "safaridriver --version" | Take-Part -Part 3, 4
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-ChromeVersion {
|
||||
$chromePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
||||
$version = Run-Command "'${chromePath}' --version"
|
||||
return ($version -replace ("^Google Chrome")).Trim()
|
||||
}
|
||||
|
||||
function Get-ChromeForTestingVersion {
|
||||
$chromePath = "/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
|
||||
$version = Run-Command "'${chromePath}' --version"
|
||||
return ($version -replace ("^Google Chrome for Testing")).Trim()
|
||||
}
|
||||
|
||||
function Get-ChromeDriverVersion {
|
||||
$rawOutput = Run-Command "chromedriver --version"
|
||||
$version = $rawOutput | Take-Part -Part 1
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-EdgeVersion {
|
||||
$edgePath = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
|
||||
$version = Run-Command "'${edgePath}' --version"
|
||||
return ($version -replace ("^Microsoft Edge")).Trim()
|
||||
}
|
||||
|
||||
function Get-EdgeDriverVersion {
|
||||
return Run-Command "msedgedriver --version" | Take-Part -Part 3
|
||||
}
|
||||
|
||||
function Get-FirefoxVersion {
|
||||
$firefoxPath = "/Applications/Firefox.app/Contents/MacOS/firefox"
|
||||
$version = Run-Command "'${firefoxPath}' --version"
|
||||
return ($version -replace "^Mozilla Firefox").Trim()
|
||||
}
|
||||
|
||||
function Get-GeckodriverVersion {
|
||||
$version = Run-Command "geckodriver --version" | Select-Object -First 1
|
||||
return ($version -replace "^geckodriver").Trim()
|
||||
}
|
||||
|
||||
function Get-SeleniumVersion {
|
||||
$os = Get-OSVersion
|
||||
if ($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
|
||||
$cellarPath = "/opt/homebrew/Cellar"
|
||||
} else {
|
||||
$cellarPath = "/usr/local/Cellar"
|
||||
}
|
||||
$seleniumVersion = (Get-ChildItem -Path "$cellarPath/selenium-server*/*").Name
|
||||
return $seleniumVersion
|
||||
}
|
||||
|
||||
function Build-BrowserWebdriversEnvironmentTable {
|
||||
$node = [HeaderNode]::new("Environment variables")
|
||||
|
||||
$table = @(
|
||||
@{
|
||||
"Name" = "CHROMEWEBDRIVER"
|
||||
"Value" = $env:CHROMEWEBDRIVER
|
||||
},
|
||||
@{
|
||||
"Name" = "EDGEWEBDRIVER"
|
||||
"Value" = $env:EDGEWEBDRIVER
|
||||
},
|
||||
@{
|
||||
"Name" = "GECKOWEBDRIVER"
|
||||
"Value" = $env:GECKOWEBDRIVER
|
||||
}
|
||||
) | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
"Name" = $_.Name
|
||||
"Value" = $_.Value
|
||||
}
|
||||
}
|
||||
|
||||
$node.AddTable($table)
|
||||
|
||||
return $node
|
||||
}
|
||||
628
images/macos/scripts/docs-gen/SoftwareReport.Common.psm1
Normal file
628
images/macos/scripts/docs-gen/SoftwareReport.Common.psm1
Normal file
@@ -0,0 +1,628 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
function Get-BashVersion {
|
||||
$version = bash -c 'echo ${BASH_VERSION}'
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-DotnetVersionList {
|
||||
$sdkRawList = Run-Command "dotnet --list-sdks"
|
||||
return $sdkRawList | ForEach-Object { Take-Part $_ -Part 0 }
|
||||
}
|
||||
|
||||
function Get-GoVersion {
|
||||
$goOutput = Run-Command "go version" | Take-Part -Part 2
|
||||
if ($goOutput.StartsWith("go")) {
|
||||
$goOutput = $goOutput.Substring(2)
|
||||
}
|
||||
|
||||
return $goOutput
|
||||
}
|
||||
|
||||
function Get-RVersion {
|
||||
$rVersion = Run-Command "R --version | grep 'R version'" | Take-Part -Part 2
|
||||
return $rVersion
|
||||
}
|
||||
|
||||
function Get-RustVersion {
|
||||
$rustVersion = Run-Command "rustc --version" | Take-Part -Part 1
|
||||
return $rustVersion
|
||||
}
|
||||
|
||||
function Get-RustfmtVersion {
|
||||
$version = Run-Command "rustfmt --version" | Take-Part -Part 1
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-RustdocVersion {
|
||||
$version = Run-Command "rustdoc --version" | Take-Part -Part 1
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-RustCargoVersion {
|
||||
$version = Run-Command "cargo --version" | Take-Part -Part 1
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-RustClippyVersion {
|
||||
$version = Run-Command "cargo clippy --version" | Take-Part -Part 1
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-Bindgen {
|
||||
$bindgenVersion = Run-Command "bindgen --version" | Take-Part -Part 1
|
||||
return $bindgenVersion
|
||||
}
|
||||
|
||||
function Get-Cbindgen {
|
||||
$cbindgenVersion = Run-Command "cbindgen --version" | Take-Part -Part 1
|
||||
return $cbindgenVersion
|
||||
}
|
||||
|
||||
function Get-Cargooutdated {
|
||||
$cargoOutdatedVersion = Run-Command "cargo outdated --version" | Take-Part -Part 1
|
||||
return $cargoOutdatedVersion
|
||||
}
|
||||
|
||||
function Get-Cargoaudit {
|
||||
$cargoAuditVersion = Run-Command "cargo-audit --version" | Take-Part -Part 1
|
||||
return $cargoAuditVersion
|
||||
}
|
||||
|
||||
function Get-RustupVersion {
|
||||
$rustupVersion = Run-Command "rustup --version" | Select-Object -First 1 | Take-Part -Part 1
|
||||
return $rustupVersion
|
||||
}
|
||||
|
||||
function Get-VcpkgVersion {
|
||||
$vcpkgVersion = Run-Command "vcpkg version" | Select-Object -First 1 | Take-Part -Part 5 | Take-Part -Part 0 -Delimiter "-"
|
||||
$commitId = git -C "/usr/local/share/vcpkg" rev-parse --short HEAD
|
||||
return "$vcpkgVersion (build from commit $commitId)"
|
||||
}
|
||||
|
||||
function Get-GccVersions {
|
||||
$versionList = Get-ToolsetValue -KeyPath gcc.versions
|
||||
$versionList | Foreach-Object {
|
||||
$nameVersion = Run-Command "gcc-${_} --version" | Select-Object -First 1
|
||||
$version = ($nameVersion -replace "^gcc-${_}").Trim() -replace '\).*$', ')'
|
||||
return [ToolVersionNode]::new("GCC ${_}", "$version - available by ``gcc-${_}`` alias")
|
||||
}
|
||||
}
|
||||
|
||||
function Get-FortranVersions {
|
||||
$versionList = Get-ToolsetValue -KeyPath gcc.versions
|
||||
$versionList | Foreach-Object {
|
||||
$nameVersion = Run-Command "gfortran-${_} --version" | Select-Object -First 1
|
||||
$version = ($nameVersion -replace "^GNU Fortran").Trim() -replace '\).*$', ')'
|
||||
return [ToolVersionNode]::new("GNU Fortran ${_}", "$version - available by ``gfortran-${_}`` alias")
|
||||
}
|
||||
}
|
||||
|
||||
function Get-ClangLLVMVersions {
|
||||
$clangVersionRegex = [Regex]::new("(?<version>\d+\.\d+\.\d+)")
|
||||
|
||||
$defaultClangOutput = Run-Command "clang --version" | Out-String
|
||||
$defaultClangVersion = $clangVersionRegex.Match($defaultClangOutput).Groups['version'].Value
|
||||
|
||||
$homebrewClangPath = '$(brew --prefix llvm@{0})/bin/clang' -f (Get-ToolsetValue 'llvm.version')
|
||||
$homebrewClangOutput = Run-Command "$homebrewClangPath --version" | Out-String
|
||||
$homebrewClangVersion = $clangVersionRegex.Match($homebrewClangOutput).Groups['version'].Value
|
||||
|
||||
return @(
|
||||
[ToolVersionNode]::new("Clang/LLVM", $defaultClangVersion)
|
||||
[ToolVersionNode]::new("Clang/LLVM (Homebrew)", "$homebrewClangVersion - available on ``$homebrewClangPath``")
|
||||
)
|
||||
}
|
||||
|
||||
function Get-NVMVersion {
|
||||
$nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh"
|
||||
$nvmInitCommand = ". ${nvmPath} > /dev/null 2>&1 || true"
|
||||
$nodejsVersion = Run-Command "${nvmInitCommand} && nvm --version"
|
||||
return $nodejsVersion
|
||||
}
|
||||
|
||||
function Get-PipVersion {
|
||||
param (
|
||||
[Parameter(Mandatory)][ValidateRange(2, 3)]
|
||||
[int] $Version
|
||||
)
|
||||
|
||||
$command = If ($Version -eq 2) { "/Library/Frameworks/Python.framework/Versions/2.7/bin/pip --version" } Else { "pip3 --version" }
|
||||
$commandOutput = Run-Command $command
|
||||
$versionPart1 = $commandOutput | Take-Part -Part 1
|
||||
$versionPart2 = $commandOutput | Take-Part -Part 4
|
||||
$versionPart3 = $commandOutput | Take-Part -Part 5
|
||||
return "${versionPart1} ${versionPart2} ${versionPart3}"
|
||||
}
|
||||
|
||||
function Get-PipxVersion {
|
||||
$pipxVersion = Run-Command "pipx --version" -SuppressStderr
|
||||
return $pipxVersion
|
||||
}
|
||||
|
||||
function Get-NVMNodeVersionList {
|
||||
$nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh"
|
||||
$nvmInitCommand = ". ${nvmPath} > /dev/null 2>&1 || true"
|
||||
$nodejsVersionsRaw = Run-Command "${nvmInitCommand} && nvm ls"
|
||||
$nodeVersions = $nodejsVersionsRaw | ForEach-Object { $_.TrimStart(" ").TrimEnd(" *") } | Where-Object { $_.StartsWith("v") }
|
||||
return $nodeVersions | ForEach-Object { $_.TrimStart("v") }
|
||||
}
|
||||
|
||||
function Build-OSInfoSection {
|
||||
param (
|
||||
[string] $ImageName
|
||||
)
|
||||
|
||||
$fieldsToInclude = @("System Version:", "Kernel Version:")
|
||||
$rawSystemInfo = Invoke-Expression "system_profiler SPSoftwareDataType"
|
||||
$parsedSystemInfo = $rawSystemInfo | Where-Object { -not ($_ | Select-String -NotMatch $fieldsToInclude) } | ForEach-Object { $_.Trim() }
|
||||
$parsedSystemInfo[0] -match "System Version: macOS (?<version>\d+)" | Out-Null
|
||||
$version = $Matches.Version
|
||||
$systemVersion = $parsedSystemInfo[0].Replace($fieldsToInclude[0],"").Trim()
|
||||
$kernelVersion = $parsedSystemInfo[1].Replace($fieldsToInclude[1],"").Trim()
|
||||
|
||||
$osInfoNode = [HeaderNode]::new("macOS $version")
|
||||
$osInfoNode.AddToolVersion("OS Version:", $systemVersion)
|
||||
$osInfoNode.AddToolVersion("Kernel Version:", $kernelVersion)
|
||||
$osInfoNode.AddToolVersion("Image Version:", $ImageName.Split('_')[1])
|
||||
return $osInfoNode
|
||||
}
|
||||
|
||||
function Get-MonoVersion {
|
||||
$monoVersion = mono --version | Out-String | Take-Part -Part 4
|
||||
return $monoVersion
|
||||
}
|
||||
|
||||
function Get-MSBuildVersion {
|
||||
$msbuildVersion = msbuild -version | Select-Object -Last 1
|
||||
$monoVersion = Get-MonoVersion
|
||||
return "$msbuildVersion (Mono $monoVersion)"
|
||||
}
|
||||
|
||||
function Get-NodeVersion {
|
||||
$nodeVersion = Run-Command "node --version"
|
||||
return $nodeVersion.TrimStart("v")
|
||||
}
|
||||
|
||||
function Get-PerlVersion {
|
||||
$version = Run-Command "perl -e 'print substr(`$^V,1)'"
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-PythonVersion {
|
||||
$pythonVersion = Run-Command "/Library/Frameworks/Python.framework/Versions/2.7/bin/python --version"
|
||||
return ($pythonVersion -replace "^Python").Trim()
|
||||
}
|
||||
|
||||
function Get-Python3Version {
|
||||
$python3Version = Run-Command "python3 --version"
|
||||
return ($python3Version -replace "^Python").Trim()
|
||||
}
|
||||
|
||||
function Get-RubyVersion {
|
||||
$rubyVersion = Run-Command "ruby --version" | Take-Part -Part 1
|
||||
return $rubyVersion
|
||||
}
|
||||
|
||||
function Get-PHPVersion {
|
||||
$PHPVersion = Run-Command "php --version" | Select-Object -First 1 | Take-Part -Part 0,1
|
||||
return ($PHPVersion -replace "^PHP").Trim()
|
||||
}
|
||||
|
||||
function Get-JuliaVersion {
|
||||
$juliaVersion = Run-Command "julia --version" | Take-Part -Part 0,2
|
||||
return ($juliaVersion -replace "^Julia").Trim()
|
||||
}
|
||||
|
||||
function Get-BundlerVersion {
|
||||
$bundlerVersion = Run-Command "bundle --version"
|
||||
return ($bundlerVersion -replace "^Bundler version").Trim()
|
||||
}
|
||||
|
||||
function Get-CarthageVersion {
|
||||
$carthageVersion = Run-Command "carthage version" -SuppressStderr
|
||||
return $carthageVersion
|
||||
}
|
||||
|
||||
function Get-CocoaPodsVersion {
|
||||
$cocoaPodsVersion = Run-Command "pod --version"
|
||||
return $cocoaPodsVersion
|
||||
}
|
||||
|
||||
function Get-HomebrewVersion {
|
||||
$homebrewVersion = Run-Command "brew --version" | Select-Object -First 1
|
||||
return ($homebrewVersion -replace "^Homebrew").Trim()
|
||||
}
|
||||
|
||||
function Get-NPMVersion {
|
||||
$NPMVersion = Run-Command "npm --version"
|
||||
return $NPMVersion
|
||||
}
|
||||
|
||||
function Get-YarnVersion {
|
||||
$yarmVersion = Run-Command "yarn --version"
|
||||
return $yarmVersion
|
||||
}
|
||||
|
||||
function Get-NuGetVersion {
|
||||
$nugetVersion = Run-Command "nuget help" | Select-Object -First 1 | Take-Part -Part 2
|
||||
return $nugetVersion
|
||||
}
|
||||
|
||||
function Get-CondaVersion {
|
||||
$condaVersion = Invoke-Expression "conda --version"
|
||||
return ($condaVersion -replace "^conda").Trim()
|
||||
}
|
||||
|
||||
function Get-RubyGemsVersion {
|
||||
$rubyGemsVersion = Run-Command "gem --version"
|
||||
return $rubyGemsVersion
|
||||
}
|
||||
|
||||
function Get-ComposerVersion {
|
||||
$composerVersion = Run-Command "composer --version" | Take-Part -Part 2
|
||||
return $composerVersion
|
||||
}
|
||||
|
||||
function Get-MavenVersion {
|
||||
$mavenVersion = Run-Command "mvn -version" | Select-Object -First 1 | Take-Part -Part 2
|
||||
return $mavenVersion
|
||||
}
|
||||
|
||||
#gradle output differs on the first launch – a welcome message, that we don't need is rendered. The solution is to take the last "Gradle" occurrence from the output
|
||||
function Get-GradleVersion {
|
||||
$gradleVersion = (Run-Command "gradle --version" | Select-String "Gradle")[-1]
|
||||
return ($gradleVersion.Line -replace "^Gradle").Trim()
|
||||
}
|
||||
|
||||
function Get-ApacheAntVersion {
|
||||
$apacheAntVersion = Run-Command "ant -version" | Take-Part -Part 0,1,3
|
||||
return ($apacheAntVersion -replace "^Apache Ant\(TM\)").Trim()
|
||||
}
|
||||
|
||||
function Get-CurlVersion {
|
||||
$curlVersion = Run-Command "curl --version" | Select-Object -First 1 | Take-Part -Part 1
|
||||
return $curlVersion
|
||||
}
|
||||
|
||||
function Get-GitVersion {
|
||||
$gitVersion = Run-Command "git --version" | Take-Part -Part -1
|
||||
return $gitVersion
|
||||
}
|
||||
|
||||
function Get-GitLFSVersion {
|
||||
$gitLFSVersion = Run-Command "git-lfs version" | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/"
|
||||
return $gitLFSVersion
|
||||
}
|
||||
|
||||
function Get-GitHubCLIVersion {
|
||||
$ghVersion = Run-Command "gh --version" | Select-String "gh version" | Select-Object -First 1 | Take-Part -Part 2
|
||||
return $ghVersion
|
||||
}
|
||||
|
||||
function Get-WgetVersion {
|
||||
$wgetVersion = Run-Command "wget --version" | Select-String "GNU Wget" | Take-Part -Part 2
|
||||
return $wgetVersion
|
||||
}
|
||||
|
||||
function Get-SVNVersion {
|
||||
$svnVersion = Run-Command "svn --version --quiet"
|
||||
return $svnVersion
|
||||
}
|
||||
|
||||
function Get-PackerVersion {
|
||||
# Packer 1.7.1 has a bug and outputs version to stderr instead of stdout https://github.com/hashicorp/packer/issues/10855
|
||||
$result = Run-Command -Command "packer --version"
|
||||
$packerVersion = [regex]::matches($result, "(\d+.){2}\d+").Value
|
||||
return $packerVersion
|
||||
}
|
||||
|
||||
function Get-OpenSSLVersion {
|
||||
$opensslVersion = Run-Command "openssl version"
|
||||
return ($opensslVersion -replace "^OpenSSL").Trim()
|
||||
}
|
||||
|
||||
function Get-JqVersion {
|
||||
$jqVersion = Run-Command "jq --version" | Take-Part -Part 1 -Delimiter "-"
|
||||
return $jqVersion
|
||||
}
|
||||
|
||||
function Get-GPGVersion {
|
||||
$gpgVersion = Run-Command "gpg --version" | Select-String 'gpg (GnuPG)' -SimpleMatch
|
||||
return ($gpgVersion.Line -replace "^gpg \(GnuPG\)").Trim()
|
||||
}
|
||||
|
||||
function Get-PostgresClientVersion {
|
||||
$postgresClientVersion = Run-Command "psql --version"
|
||||
return ($postgresClientVersion -replace "^psql \(PostgreSQL\)").Trim()
|
||||
}
|
||||
|
||||
function Get-PostgresServerVersion {
|
||||
$postgresServerVersion = Run-Command "pg_config --version"
|
||||
return ($postgresServerVersion -replace "^PostgreSQL").Trim()
|
||||
}
|
||||
|
||||
function Get-Aria2Version {
|
||||
$aria2Version = Run-Command "aria2c --version" | Select-Object -First 1 | Take-Part -Part 2
|
||||
return $aria2Version
|
||||
}
|
||||
|
||||
function Get-AzcopyVersion {
|
||||
$azcopyVersion = Run-Command "azcopy --version" | Take-Part -Part 2
|
||||
return $azcopyVersion
|
||||
}
|
||||
|
||||
function Get-ZstdVersion {
|
||||
$zstdVersion = Run-Command "zstd --version" | Take-Part -Part 1 -Delimiter "v" | Take-Part -Part 0 -Delimiter ","
|
||||
return $zstdVersion
|
||||
}
|
||||
|
||||
function Get-BazelVersion {
|
||||
$bazelVersion = Run-Command "bazel --version" | Take-Part -Part 0 -Delimiter "-"
|
||||
return ($bazelVersion -replace "^bazel").Trim()
|
||||
}
|
||||
|
||||
function Get-BazeliskVersion {
|
||||
$bazeliskVersion = Run-Command "brew list bazelisk --versions"
|
||||
return ($bazeliskVersion -replace "^bazelisk").Trim()
|
||||
}
|
||||
|
||||
function Get-HelmVersion {
|
||||
$helmVersion = Run-Command "helm version --short"
|
||||
return $helmVersion
|
||||
}
|
||||
|
||||
function Get-MongoVersion {
|
||||
$mongo = Run-Command "mongo --version" | Select-String "MongoDB shell version" | Take-Part -Part 3
|
||||
return $mongo.TrimStart("v").Trim()
|
||||
}
|
||||
|
||||
function Get-MongodVersion {
|
||||
$mongod = Run-Command "mongod --version" | Select-String "db version " | Take-Part -Part 2
|
||||
return $mongod.TrimStart("v").Trim()
|
||||
}
|
||||
|
||||
function Get-7zipVersion {
|
||||
$7zip = Run-Command "7z i" | Select-String "7-Zip" | Take-Part -Part 0,2
|
||||
return ($7zip -replace "^7-Zip").Trim()
|
||||
}
|
||||
|
||||
function Get-GnuTarVersion {
|
||||
$gnuTar = Run-Command "gtar --version" | Select-String "tar" | Take-Part -Part 3
|
||||
return "$gnuTar - available by 'gtar' alias"
|
||||
}
|
||||
|
||||
function Get-BsdtarVersion {
|
||||
$bsdtar = Run-Command "tar --version" | Take-Part -Part 1
|
||||
return "$bsdtar - available by 'tar' alias"
|
||||
}
|
||||
|
||||
function Get-NewmanVersion {
|
||||
$newmanVersion = Run-Command "newman --version"
|
||||
return $newmanVersion
|
||||
}
|
||||
|
||||
function Get-VirtualBoxVersion {
|
||||
$virtualBox = Run-Command "vboxmanage -v"
|
||||
return $virtualBox
|
||||
}
|
||||
|
||||
function Get-VagrantVersion {
|
||||
$vagrant = Run-Command "vagrant -v"
|
||||
return ($vagrant -replace "^Vagrant").Trim()
|
||||
}
|
||||
|
||||
function Get-ParallelVersion {
|
||||
$parallelVersion = Run-Command "parallel --version" | Select-String "GNU parallel" | Select-Object -First 1
|
||||
return ($parallelVersion -replace "^GNU parallel").Trim()
|
||||
}
|
||||
|
||||
function Get-FastlaneVersion {
|
||||
$fastlaneVersion = Run-Command "fastlane --version" | Select-String "^fastlane [0-9]" | Take-Part -Part 1
|
||||
return $fastlaneVersion
|
||||
}
|
||||
|
||||
function Get-CmakeVersion {
|
||||
$cmakeVersion = Run-Command "cmake --version" | Select-Object -First 1 | Take-Part -Part 2
|
||||
return $cmakeVersion
|
||||
}
|
||||
|
||||
function Get-AppCenterCLIVersion {
|
||||
$appcenterCLIVersion = Run-Command "appcenter --version" | Take-Part -Part 2
|
||||
return $appcenterCLIVersion
|
||||
}
|
||||
|
||||
function Get-AzureCLIVersion {
|
||||
$azureCLIVersion = (az version | ConvertFrom-Json).'azure-cli'
|
||||
return $azureCLIVersion
|
||||
}
|
||||
|
||||
function Get-AzureDevopsVersion {
|
||||
$azdevopsVersion = (az version | ConvertFrom-Json).extensions.'azure-devops'
|
||||
return $azdevopsVersion
|
||||
}
|
||||
|
||||
function Get-AWSCLIVersion {
|
||||
$awsVersion = Run-Command "aws --version" | Take-Part -Part 0 | Take-Part -Delimiter "/" -Part 1
|
||||
return $awsVersion
|
||||
}
|
||||
|
||||
function Get-AWSSAMCLIVersion {
|
||||
$awsSamVersion = Run-Command "sam --version" | Take-Part -Part 3
|
||||
return $awsSamVersion
|
||||
}
|
||||
|
||||
function Get-AWSSessionManagerCLIVersion {
|
||||
$awsSessionManagerVersion = Run-Command "session-manager-plugin --version"
|
||||
return $awsSessionManagerVersion
|
||||
}
|
||||
|
||||
function Get-AliyunCLIVersion {
|
||||
$aliyunVersion = Run-Command "aliyun --version" | Select-String "Alibaba Cloud Command Line Interface Version " | Take-Part -Part 6
|
||||
return $aliyunVersion
|
||||
}
|
||||
|
||||
function Get-GHCupVersion {
|
||||
$ghcUpVersion = (Run-Command "ghcup --version" | Take-Part -Part 5).Replace('v','')
|
||||
return $ghcUpVersion
|
||||
}
|
||||
|
||||
function Get-GHCVersion {
|
||||
$ghcVersion = Run-Command "ghc --version" | Take-Part -Part 7
|
||||
return $ghcVersion
|
||||
}
|
||||
|
||||
function Get-CabalVersion {
|
||||
$cabalVersion = Run-Command "cabal --version" | Take-Part -Part 3
|
||||
return $cabalVersion
|
||||
}
|
||||
|
||||
function Get-SwitchAudioOsxVersion {
|
||||
$switchAudioVersion = Get-BrewPackageVersion -CommandName "SwitchAudioSource"
|
||||
return $switchAudioVersion
|
||||
}
|
||||
|
||||
function Get-SoxVersion {
|
||||
$soxVersion = Get-BrewPackageVersion -CommandName "sox"
|
||||
return $soxVersion
|
||||
}
|
||||
|
||||
function Get-StackVersion {
|
||||
$stackVersion = Run-Command "stack --version" | Take-Part -Part 1 | ForEach-Object {$_.replace(",","")}
|
||||
return $stackVersion
|
||||
}
|
||||
|
||||
function Get-SwiftFormatVersion {
|
||||
$swiftFormatVersion = Run-Command "swiftformat --version"
|
||||
return $swiftFormatVersion
|
||||
}
|
||||
|
||||
function Get-YamllintVersion {
|
||||
$yamllintVersion = Run-Command "yamllint --version"
|
||||
return ($yamllintVersion -replace "^Yamllint").Trim()
|
||||
}
|
||||
|
||||
function Get-SwiftLintVersion {
|
||||
$swiftlintVersion = Run-Command "swiftlint version"
|
||||
return $swiftlintVersion
|
||||
}
|
||||
|
||||
function Get-PowershellVersion {
|
||||
$powershellVersion = Run-Command "powershell --version"
|
||||
return ($powershellVersion -replace "^PowerShell").Trim()
|
||||
}
|
||||
|
||||
function Get-SwigVersion {
|
||||
$swigVersion = Run-Command "swig -version" | Select-Object -First 2 | Take-Part -Part 2
|
||||
return $swigVersion
|
||||
}
|
||||
|
||||
function Get-BicepVersion {
|
||||
$bicepVersion = Run-Command "bicep --version" | Take-Part -Part 3
|
||||
return $bicepVersion
|
||||
}
|
||||
|
||||
function Get-KotlinVersion {
|
||||
$kotlinVersion = Run-Command "kotlin -version" | Take-Part -Part 2
|
||||
return $kotlinVersion
|
||||
}
|
||||
|
||||
function Get-SbtVersion {
|
||||
$sbtVersion = Run-Command "sbt -version" | Take-Part -Part 3
|
||||
return $sbtVersion
|
||||
}
|
||||
|
||||
function Get-JazzyVersion {
|
||||
$jazzyVersion = Run-Command "jazzy --version" | Take-Part -Part 2
|
||||
return $jazzyVersion
|
||||
}
|
||||
|
||||
function Get-ZlibVersion {
|
||||
$zlibVersion = brew info --json zlib | jq -r '.[].installed[].version'
|
||||
return $zlibVersion
|
||||
}
|
||||
|
||||
function Get-LibXftVersion {
|
||||
$libXftVersion = brew info --json libxft | jq -r '.[].installed[].version'
|
||||
return $libXftVersion
|
||||
}
|
||||
|
||||
function Get-LibXextVersion {
|
||||
$libXextVersion = brew info --json libxext | jq -r '.[].installed[].version'
|
||||
return $libXextVersion
|
||||
}
|
||||
|
||||
function Get-TclTkVersion {
|
||||
$tcltkVersion = brew info --json tcl-tk | jq -r '.[].installed[].version'
|
||||
return $tcltkVersion
|
||||
}
|
||||
|
||||
function Get-YqVersion {
|
||||
$yqVersion = Run-Command "yq --version"
|
||||
$yqVersion -match "\d{1,2}\.\d{1,2}\.\d{1,2}" | Out-Null
|
||||
return ($Matches[0])
|
||||
}
|
||||
|
||||
function Get-ImageMagickVersion {
|
||||
$imagemagickVersion = Run-Command "magick --version" | Select-Object -First 1 | Take-Part -Part 1,2
|
||||
return ($imagemagickVersion -replace "^ImageMagick").Trim()
|
||||
}
|
||||
|
||||
function Build-PackageManagementEnvironmentTable {
|
||||
$node = [HeaderNode]::new("Environment variables")
|
||||
|
||||
$table = @(
|
||||
@{
|
||||
"Name" = "CONDA"
|
||||
"Value" = $env:CONDA
|
||||
},
|
||||
@{
|
||||
"Name" = "VCPKG_INSTALLATION_ROOT"
|
||||
"Value" = $env:VCPKG_INSTALLATION_ROOT
|
||||
}
|
||||
) | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
"Name" = $_.Name
|
||||
"Value" = $_.Value
|
||||
}
|
||||
}
|
||||
|
||||
$node.AddTable($table)
|
||||
|
||||
return $node
|
||||
}
|
||||
|
||||
function Build-MiscellaneousEnvironmentTable {
|
||||
return @(
|
||||
@{
|
||||
"Name" = "PARALLELS_DMG_URL"
|
||||
"Value" = $env:PARALLELS_DMG_URL
|
||||
}
|
||||
) | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
"Name" = $_.Name
|
||||
"Value" = $_.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Get-CodeQLBundleVersion {
|
||||
$CodeQLVersionWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
|
||||
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionWildcard | Select-Object -First 1 -Expand FullName
|
||||
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql"
|
||||
$CodeQLVersion = & $CodeQLPath version --quiet
|
||||
return $CodeQLVersion
|
||||
}
|
||||
|
||||
function Get-ColimaVersion {
|
||||
$colimaVersion = Run-Command "colima version" | Select-String "colima version" | Take-Part -Part 2
|
||||
return $colimaVersion
|
||||
}
|
||||
|
||||
function Get-PKGConfigVersion {
|
||||
$pkgconfigVersion = Run-Command "pkg-config --version"
|
||||
return $pkgconfigVersion
|
||||
}
|
||||
319
images/macos/scripts/docs-gen/SoftwareReport.Generator.ps1
Normal file
319
images/macos/scripts/docs-gen/SoftwareReport.Generator.ps1
Normal file
@@ -0,0 +1,319 @@
|
||||
using module ./software-report-base/SoftwareReport.psm1
|
||||
using module ./software-report-base/SoftwareReport.Nodes.psm1
|
||||
|
||||
param (
|
||||
[Parameter(Mandatory)][string]
|
||||
$OutputDirectory,
|
||||
$ImageName
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Import-Module "$PSScriptRoot/SoftwareReport.Common.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/SoftwareReport.Xcode.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/SoftwareReport.Android.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/SoftwareReport.Java.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/SoftwareReport.Xamarin.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/SoftwareReport.Toolcache.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/SoftwareReport.Browsers.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/SoftwareReport.WebServers.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/../helpers/SoftwareReport.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
|
||||
|
||||
# Operating System info
|
||||
$os = Get-OSVersion
|
||||
|
||||
# OS info
|
||||
$osInfo = Build-OSInfoSection $ImageName
|
||||
|
||||
# Software report
|
||||
$softwareReport = [SoftwareReport]::new($osInfo)
|
||||
$installedSoftware = $softwareReport.Root.AddHeader("Installed Software")
|
||||
|
||||
# Language and Runtime
|
||||
$languageAndRuntime = $installedSoftware.AddHeader("Language and Runtime")
|
||||
$languageAndRuntime.AddToolVersionsListInline(".NET Core SDK", $(Get-DotnetVersionList), '^\d+\.\d+\.\d')
|
||||
$languageAndRuntime.AddToolVersion("Bash", $(Get-BashVersion))
|
||||
$languageAndRuntime.AddNodes($(Get-ClangLLVMVersions))
|
||||
$languageAndRuntime.AddNodes($(Get-GccVersions))
|
||||
$languageAndRuntime.AddNodes($(Get-FortranVersions))
|
||||
$languageAndRuntime.AddToolVersion("Julia", $(Get-JuliaVersion))
|
||||
$languageAndRuntime.AddToolVersion("Kotlin", $(Get-KotlinVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$languageAndRuntime.AddToolVersion("Go", $(Get-GoVersion))
|
||||
}
|
||||
$languageAndRuntime.AddToolVersion("Mono", $(Get-MonoVersion))
|
||||
$languageAndRuntime.AddToolVersion("Node.js", $(Get-NodeVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$languageAndRuntime.AddToolVersion("MSBuild", $(Get-MSBuildVersion))
|
||||
$languageAndRuntime.AddToolVersion("NVM", $(Get-NVMVersion))
|
||||
$languageAndRuntime.AddToolVersionsListInline("NVM - Cached node versions", $(Get-NVMNodeVersionList), '^\d+')
|
||||
}
|
||||
$languageAndRuntime.AddToolVersion("Perl", $(Get-PerlVersion))
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$languageAndRuntime.AddToolVersion("PHP", $(Get-PHPVersion))
|
||||
}
|
||||
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$languageAndRuntime.AddToolVersion("Python", $(Get-PythonVersion))
|
||||
}
|
||||
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$languageAndRuntime.AddToolVersion("Python3", $(Get-Python3Version))
|
||||
}
|
||||
$languageAndRuntime.AddToolVersion("R", $(Get-RVersion))
|
||||
$languageAndRuntime.AddToolVersion("Ruby", $(Get-RubyVersion))
|
||||
|
||||
# Package Management
|
||||
$packageManagement = $installedSoftware.AddHeader("Package Management")
|
||||
$packageManagement.AddToolVersion("Bundler", $(Get-BundlerVersion))
|
||||
$packageManagement.AddToolVersion("Carthage", $(Get-CarthageVersion))
|
||||
$packageManagement.AddToolVersion("CocoaPods", $(Get-CocoaPodsVersion))
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$packageManagement.AddToolVersion("Composer", $(Get-ComposerVersion))
|
||||
}
|
||||
$packageManagement.AddToolVersion("Homebrew", $(Get-HomebrewVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$packageManagement.AddToolVersion("Miniconda", $(Get-CondaVersion))
|
||||
}
|
||||
$packageManagement.AddToolVersion("NPM", $(Get-NPMVersion))
|
||||
$packageManagement.AddToolVersion("NuGet", $(Get-NuGetVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$packageManagement.AddToolVersion("Pip", $(Get-PipVersion -Version 2))
|
||||
}
|
||||
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$packageManagement.AddToolVersion("Pip3", $(Get-PipVersion -Version 3))
|
||||
$packageManagement.AddToolVersion("Pipx", $(Get-PipxVersion))
|
||||
}
|
||||
|
||||
$packageManagement.AddToolVersion("RubyGems", $(Get-RubyGemsVersion))
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$packageManagement.AddToolVersion("Vcpkg", $(Get-VcpkgVersion))
|
||||
}
|
||||
$packageManagement.AddToolVersion("Yarn", $(Get-YarnVersion))
|
||||
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$packageManagement.AddNode($(Build-PackageManagementEnvironmentTable))
|
||||
}
|
||||
# Project Management
|
||||
$projectManagement = $installedSoftware.AddHeader("Project Management")
|
||||
$projectManagement.AddToolVersion("Apache Ant", $(Get-ApacheAntVersion))
|
||||
$projectManagement.AddToolVersion("Apache Maven", $(Get-MavenVersion))
|
||||
$projectManagement.AddToolVersion("Gradle", $(Get-GradleVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$projectManagement.AddToolVersion("Sbt", $(Get-SbtVersion))
|
||||
}
|
||||
|
||||
# Utilities
|
||||
$utilities = $installedSoftware.AddHeader("Utilities")
|
||||
$utilities.AddToolVersion("7-Zip", $(Get-7zipVersion))
|
||||
$utilities.AddToolVersion("aria2", $(Get-Aria2Version))
|
||||
$utilities.AddToolVersion("azcopy", $(Get-AzcopyVersion))
|
||||
$utilities.AddToolVersion("bazel", $(Get-BazelVersion))
|
||||
$utilities.AddToolVersion("bazelisk", $(Get-BazeliskVersion))
|
||||
$utilities.AddToolVersion("bsdtar", $(Get-BsdtarVersion))
|
||||
$utilities.AddToolVersion("Curl", $(Get-CurlVersion))
|
||||
$utilities.AddToolVersion("Git", $(Get-GitVersion))
|
||||
$utilities.AddToolVersion("Git LFS", $(Get-GitLFSVersion))
|
||||
$utilities.AddToolVersion("GitHub CLI", $(Get-GitHubCLIVersion))
|
||||
$utilities.AddToolVersion("GNU Tar", $(Get-GnuTarVersion))
|
||||
$utilities.AddToolVersion("GNU Wget", $(Get-WgetVersion))
|
||||
$utilities.AddToolVersion("gpg (GnuPG)", $(Get-GPGVersion))
|
||||
if ($os.IsBigSur) {
|
||||
$utilities.AddToolVersion("helm", $(Get-HelmVersion))
|
||||
}
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$utilities.AddToolVersion("ImageMagick", $(Get-ImageMagickVersion))
|
||||
}
|
||||
$utilities.AddToolVersion("jq", $(Get-JqVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$utilities.AddToolVersion("mongo", $(Get-MongoVersion))
|
||||
$utilities.AddToolVersion("mongod", $(Get-MongodVersion))
|
||||
}
|
||||
if ($os.IsBigSur) {
|
||||
$utilities.AddToolVersion("Newman", $(Get-NewmanVersion))
|
||||
}
|
||||
$utilities.AddToolVersion("OpenSSL", $(Get-OpenSSLVersion))
|
||||
$utilities.AddToolVersion("Packer", $(Get-PackerVersion))
|
||||
$utilities.AddToolVersion("pkg-config", $(Get-PKGConfigVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$utilities.AddToolVersion("PostgreSQL", $(Get-PostgresServerVersion))
|
||||
$utilities.AddToolVersion("psql (PostgreSQL)", $(Get-PostgresClientVersion))
|
||||
$utilities.AddToolVersion("Sox", $(Get-SoxVersion))
|
||||
$utilities.AddToolVersion("Subversion (SVN)", $(Get-SVNVersion))
|
||||
$utilities.AddToolVersion("Switchaudio-osx", $(Get-SwitchAudioOsxVersion))
|
||||
}
|
||||
if ($os.IsMonterey) {
|
||||
$utilities.AddToolVersion("Vagrant", $(Get-VagrantVersion))
|
||||
$utilities.AddToolVersion("VirtualBox", $(Get-VirtualBoxVersion))
|
||||
}
|
||||
$utilities.AddToolVersion("yq", $(Get-YqVersion))
|
||||
$utilities.AddToolVersion("zstd", $(Get-ZstdVersion))
|
||||
|
||||
# Tools
|
||||
$tools = $installedSoftware.AddHeader("Tools")
|
||||
if ($os.IsBigSur) {
|
||||
$tools.AddToolVersion("Aliyun CLI", $(Get-AliyunCLIVersion))
|
||||
}
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$tools.AddToolVersion("App Center CLI", $(Get-AppCenterCLIVersion))
|
||||
}
|
||||
$tools.AddToolVersion("AWS CLI", $(Get-AWSCLIVersion))
|
||||
$tools.AddToolVersion("AWS SAM CLI", $(Get-AWSSAMCLIVersion))
|
||||
$tools.AddToolVersion("AWS Session Manager CLI", $(Get-AWSSessionManagerCLIVersion))
|
||||
$tools.AddToolVersion("Azure CLI", $(Get-AzureCLIVersion))
|
||||
$tools.AddToolVersion("Azure CLI (azure-devops)", $(Get-AzureDevopsVersion))
|
||||
$tools.AddToolVersion("Bicep CLI", $(Get-BicepVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$tools.AddToolVersion("Cabal", $(Get-CabalVersion))
|
||||
}
|
||||
$tools.AddToolVersion("Cmake", $(Get-CmakeVersion))
|
||||
$tools.AddToolVersion("CodeQL Action Bundle", $(Get-CodeQLBundleVersion))
|
||||
if ($os.IsMonterey) {
|
||||
$tools.AddToolVersion("Colima", $(Get-ColimaVersion))
|
||||
}
|
||||
$tools.AddToolVersion("Fastlane", $(Get-FastlaneVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$tools.AddToolVersion("GHC", $(Get-GHCVersion))
|
||||
$tools.AddToolVersion("GHCup", $(Get-GHCupVersion))
|
||||
$tools.AddToolVersion("Jazzy", $(Get-JazzyVersion))
|
||||
}
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$tools.AddToolVersion("Stack", $(Get-StackVersion))
|
||||
}
|
||||
$tools.AddToolVersion("SwiftFormat", $(Get-SwiftFormatVersion))
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$tools.AddToolVersion("Swig", $(Get-SwigVersion))
|
||||
}
|
||||
$tools.AddToolVersion("Xcode Command Line Tools", $(Get-XcodeCommandLineToolsVersion))
|
||||
|
||||
# Linters
|
||||
$linters = $installedSoftware.AddHeader("Linters")
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$linters.AddToolVersion("SwiftLint", $(Get-SwiftLintVersion))
|
||||
}
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$linters.AddToolVersion("Yamllint", $(Get-YamllintVersion))
|
||||
}
|
||||
|
||||
# Browsers
|
||||
$browsers = $installedSoftware.AddHeader("Browsers")
|
||||
$browsers.AddNodes($(Build-BrowserSection))
|
||||
$browsers.AddNode($(Build-BrowserWebdriversEnvironmentTable))
|
||||
|
||||
# Java
|
||||
$java = $installedSoftware.AddHeader("Java")
|
||||
$java.AddTable($(Get-JavaVersions))
|
||||
|
||||
# Toolcache
|
||||
if (-not $os.IsSonoma) {
|
||||
$toolcache = $installedSoftware.AddHeader("Cached Tools")
|
||||
$toolcache.AddNodes($(Build-ToolcacheSection))
|
||||
|
||||
# Rust
|
||||
$rust = $installedSoftware.AddHeader("Rust Tools")
|
||||
$rust.AddToolVersion("Cargo", $(Get-RustCargoVersion))
|
||||
$rust.AddToolVersion("Rust", $(Get-RustVersion))
|
||||
$rust.AddToolVersion("Rustdoc", $(Get-RustdocVersion))
|
||||
$rust.AddToolVersion("Rustup", $(Get-RustupVersion))
|
||||
|
||||
$rustPackages = $rust.AddHeader("Packages")
|
||||
if (-not $os.IsVentura) {
|
||||
$rustPackages.AddToolVersion("Bindgen", $(Get-Bindgen))
|
||||
$rustPackages.AddToolVersion("Cargo-audit", $(Get-Cargoaudit))
|
||||
$rustPackages.AddToolVersion("Cargo-outdated", $(Get-Cargooutdated))
|
||||
$rustPackages.AddToolVersion("Cbindgen", $(Get-Cbindgen))
|
||||
}
|
||||
$rustPackages.AddToolVersion("Clippy", $(Get-RustClippyVersion))
|
||||
$rustPackages.AddToolVersion("Rustfmt", $(Get-RustfmtVersion))
|
||||
}
|
||||
|
||||
# PowerShell
|
||||
$powerShell = $installedSoftware.AddHeader("PowerShell Tools")
|
||||
$powerShell.AddToolVersion("PowerShell", $(Get-PowershellVersion))
|
||||
|
||||
$powerShellModules = $powerShell.AddHeader("PowerShell Modules")
|
||||
$powerShellModules.AddNodes($(Get-PowerShellModules))
|
||||
|
||||
# Web Servers
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$webServers = $installedSoftware.AddHeader("Web Servers")
|
||||
$webServers.AddTable($(Build-WebServersSection))
|
||||
}
|
||||
|
||||
# Xamarin section
|
||||
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
|
||||
$xamarin = $installedSoftware.AddHeader("Xamarin")
|
||||
$vsForMac = $xamarin.AddHeader("Visual Studio for Mac")
|
||||
$vsForMac.AddTable($(Build-VSMacTable))
|
||||
$note =
|
||||
@'
|
||||
To use Visual Studio 2019 by default rename the app:
|
||||
mv "/Applications/Visual Studio.app" "/Applications/Visual Studio 2022.app"
|
||||
mv "/Applications/Visual Studio 2019.app" "/Applications/Visual Studio.app"
|
||||
'@
|
||||
$vsForMacNotes = $vsForMac.AddHeader("Notes")
|
||||
$vsForMacNotes.AddNote($note)
|
||||
|
||||
$xamarinBundles = $xamarin.AddHeader("Xamarin bundles")
|
||||
$xamarinBundles.AddTable($(Build-XamarinTable))
|
||||
|
||||
$unitTestFramework = $xamarin.AddHeader("Unit Test Framework")
|
||||
$unitTestFramework.AddToolVersion("NUnit", $(Get-NUnitVersion))
|
||||
}
|
||||
|
||||
# Xcode section
|
||||
$xcode = $installedSoftware.AddHeader("Xcode")
|
||||
# First run doesn't provide full data about devices and runtimes
|
||||
Get-XcodeInfoList | Out-Null
|
||||
|
||||
$xcodeInfo = Get-XcodeInfoList
|
||||
$xcode.AddTable($(Build-XcodeTable $xcodeInfo))
|
||||
|
||||
$xcodeTools = $xcode.AddHeader("Xcode Support Tools")
|
||||
$xcodeTools.AddNodes($(Build-XcodeSupportToolsSection))
|
||||
|
||||
$installedSdks = $xcode.AddHeader("Installed SDKs")
|
||||
$installedSdks.AddTable($(Build-XcodeSDKTable $xcodeInfo))
|
||||
|
||||
$installedSimulators = $xcode.AddHeader("Installed Simulators")
|
||||
$installedSimulators.AddTable($(Build-XcodeSimulatorsTable $xcodeInfo))
|
||||
|
||||
# Android section
|
||||
$android = $installedSoftware.AddHeader("Android")
|
||||
$androidTable = Build-AndroidTable
|
||||
$android.AddTable($androidTable)
|
||||
|
||||
$androidEnv = $android.AddHeader("Environment variables")
|
||||
$androidEnv.AddTable($(Build-AndroidEnvironmentTable))
|
||||
|
||||
if ($os.IsBigSur -or $os.IsMonterey) {
|
||||
$miscellaneous = $installedSoftware.AddHeader("Miscellaneous")
|
||||
$miscellaneous.AddToolVersion("libXext", $(Get-LibXextVersion))
|
||||
$miscellaneous.AddToolVersion("libXft", $(Get-LibXftVersion))
|
||||
$miscellaneous.AddToolVersion("Tcl/Tk", $(Get-TclTkVersion))
|
||||
$miscellaneous.AddToolVersion("Zlib", $(Get-ZlibVersion))
|
||||
}
|
||||
|
||||
if ($os.IsMonterey) {
|
||||
$miscellaneousEnv = $miscellaneous.AddHeader("Environment variables")
|
||||
$miscellaneousEnv.AddTable($(Build-MiscellaneousEnvironmentTable))
|
||||
|
||||
$notes = @'
|
||||
If you want to use Parallels Desktop you should download a package from URL stored in
|
||||
PARALLELS_DMG_URL environment variable. A system extension is allowed for this version.
|
||||
'@
|
||||
$miscellaneousEnvNotes = $miscellaneousEnv.AddHeader("Notes")
|
||||
$miscellaneousEnvNotes.AddNote($notes)
|
||||
}
|
||||
|
||||
if (-not (Test-Path $OutputDirectory)) { New-Item -Path $OutputDirectory -ItemType Directory | Out-Null }
|
||||
|
||||
#
|
||||
# Write final reports
|
||||
#
|
||||
Write-Host $markdownExtended
|
||||
$softwareReport.ToJson() | Out-File -FilePath "${OutputDirectory}/systeminfo.json" -Encoding UTF8NoBOM
|
||||
$softwareReport.ToMarkdown() | Out-File -FilePath "${OutputDirectory}/systeminfo.md" -Encoding UTF8NoBOM
|
||||
27
images/macos/scripts/docs-gen/SoftwareReport.Java.psm1
Normal file
27
images/macos/scripts/docs-gen/SoftwareReport.Java.psm1
Normal file
@@ -0,0 +1,27 @@
|
||||
function Get-JavaVersions {
|
||||
$defaultJavaPath = (Get-Item env:JAVA_HOME).value
|
||||
|
||||
$os = Get-OSVersion
|
||||
if ($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
|
||||
$javaVersions = Get-Item env:JAVA_HOME_*_arm64
|
||||
} else {
|
||||
$javaVersions = Get-Item env:JAVA_HOME_*_X64
|
||||
}
|
||||
$sortRules = @{
|
||||
Expression = { [Int32]$_.Name.Split("_")[2] }
|
||||
Descending = $false
|
||||
}
|
||||
|
||||
return $javaVersions | Sort-Object $sortRules | ForEach-Object {
|
||||
$javaPath = $_.Value
|
||||
# Take semver from the java path
|
||||
$version = $javaPath.split('/')[5]
|
||||
$fullVersion = $version.Replace('-', '+')
|
||||
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
|
||||
|
||||
[PSCustomObject] @{
|
||||
"Version" = $fullVersion + $defaultPostfix
|
||||
"Environment Variable" = $_.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
63
images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1
Normal file
63
images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1
Normal file
@@ -0,0 +1,63 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
function Get-ToolcacheRubyVersions {
|
||||
$toolcachePath = Join-Path $env:HOME "hostedtoolcache" "Ruby"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
}
|
||||
|
||||
function Get-ToolcachePythonVersions {
|
||||
$toolcachePath = Join-Path $env:HOME "hostedtoolcache" "Python"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
}
|
||||
|
||||
function Get-ToolcachePyPyVersions {
|
||||
$toolcachePath = Join-Path $env:HOME "hostedtoolcache/PyPy/*/x64"
|
||||
Get-ChildItem -Path $toolcachePath | Sort-Object { [Version] $_.Parent.Name } | ForEach-Object {
|
||||
$foundVersionPath = $_.FullName
|
||||
$foundVersionName = (Get-Item ($foundVersionPath -replace "x64") | Sort-Object -Property {[version]$_.name} -Descending | Select-Object -First 1).name
|
||||
$arrPyPyVersion = ((& "$foundVersionPath/bin/python" -c "import sys;print(sys.version.split('\n')[1])") -split " ")
|
||||
$pypyVersion = "$($arrPyPyVersion[0]) $($arrPyPyVersion[1])"
|
||||
return "{0} {1}]" -f $foundVersionName, $pypyVersion
|
||||
}
|
||||
}
|
||||
|
||||
function Get-ToolcacheNodeVersions {
|
||||
$toolcachePath = Join-Path $env:HOME "hostedtoolcache" "Node"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
}
|
||||
|
||||
function Get-ToolcacheGoVersions {
|
||||
$toolcachePath = Join-Path $env:HOME "hostedtoolcache" "Go"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
}
|
||||
|
||||
function Build-ToolcacheSection {
|
||||
|
||||
$nodes = @()
|
||||
|
||||
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
|
||||
$nodes += @(
|
||||
[ToolVersionsListNode]::new("Ruby", $(Get-ToolcacheRubyVersions), '^\d+\.\d+', "List"),
|
||||
[ToolVersionsListNode]::new("PyPy", $(Get-ToolcachePyPyVersions), '^\d+\.\d+', "List")
|
||||
)
|
||||
}
|
||||
|
||||
$nodes += @(
|
||||
[ToolVersionsListNode]::new("Python", $(Get-ToolcachePythonVersions), '^\d+\.\d+', "List"),
|
||||
[ToolVersionsListNode]::new("Node.js", $(Get-ToolcacheNodeVersions), '^\d+', "List"),
|
||||
[ToolVersionsListNode]::new("Go", $(Get-ToolcacheGoVersions), '^\d+\.\d+', "List")
|
||||
)
|
||||
|
||||
return $nodes
|
||||
}
|
||||
|
||||
function Get-PowerShellModules {
|
||||
$modules = (Get-ToolsetValue powershellModules).name
|
||||
$modules | ForEach-Object {
|
||||
$moduleName = $_
|
||||
$moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique
|
||||
return [ToolVersionsListNode]::new($moduleName, $moduleVersions, '^\d+', "Inline")
|
||||
}
|
||||
}
|
||||
36
images/macos/scripts/docs-gen/SoftwareReport.WebServers.psm1
Normal file
36
images/macos/scripts/docs-gen/SoftwareReport.WebServers.psm1
Normal file
@@ -0,0 +1,36 @@
|
||||
function Get-ApacheVersion {
|
||||
$name = "httpd"
|
||||
$port = 80
|
||||
$version = brew list $name --versions | Take-Part -Part 1
|
||||
$serviceStatus = (brew services list) -match $name | Take-Part -Part 1
|
||||
$configFile = "$(brew --prefix)/etc/httpd/httpd.conf"
|
||||
return [PsCustomObject]@{
|
||||
"Name" = $name
|
||||
"Version" = $version
|
||||
"ConfigFile" = $configFile
|
||||
"ServiceStatus" = $serviceStatus
|
||||
"ListenPort" = $port
|
||||
}
|
||||
}
|
||||
|
||||
function Get-NginxVersion {
|
||||
$name = "nginx"
|
||||
$port = 80
|
||||
$version = brew list $name --versions | Take-Part -Part 1
|
||||
$serviceStatus = (brew services list) -match $name | Take-Part -Part 1
|
||||
$configFile = "$(brew --prefix)/etc/nginx/nginx.conf"
|
||||
return [PsCustomObject]@{
|
||||
"Name" = $name
|
||||
"Version" = $version
|
||||
"ConfigFile" = $configFile
|
||||
"ServiceStatus" = $serviceStatus
|
||||
"ListenPort" = $port
|
||||
}
|
||||
}
|
||||
|
||||
function Build-WebServersSection {
|
||||
return @(
|
||||
(Get-ApacheVersion),
|
||||
(Get-NginxVersion)
|
||||
)
|
||||
}
|
||||
48
images/macos/scripts/docs-gen/SoftwareReport.Xamarin.psm1
Normal file
48
images/macos/scripts/docs-gen/SoftwareReport.Xamarin.psm1
Normal file
@@ -0,0 +1,48 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
|
||||
function Build-VSMacTable {
|
||||
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
|
||||
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
|
||||
|
||||
return $vsMacVersions | ForEach-Object {
|
||||
$isDefault = $_ -eq $defaultVSMacVersion
|
||||
$vsPath = "/Applications/Visual Studio $_.app"
|
||||
if ($isDefault) {
|
||||
$vsPath = "/Applications/Visual Studio.app"
|
||||
}
|
||||
|
||||
$plistPath = "$vsPath/Contents/Info.plist"
|
||||
$build = Run-Command "/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' '$plistPath'"
|
||||
$defaultPostfix = $isDefault ? " (default)" : ""
|
||||
|
||||
[PSCustomObject] @{
|
||||
"Version" = $_ + $defaultPostfix
|
||||
"Build" = $build
|
||||
"Path" = $vsPath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-NUnitVersion {
|
||||
$version = Run-Command "nunit3-console --version" | Select-Object -First 1 | Take-Part -Part 3
|
||||
return $version
|
||||
}
|
||||
|
||||
function Build-XamarinTable {
|
||||
$xamarinBundles = Get-ToolsetValue "xamarin.bundles"
|
||||
$defaultSymlink = Get-ToolsetValue "xamarin.bundle-default"
|
||||
if ($defaultSymlink -eq "latest") {
|
||||
$defaultSymlink = $xamarinBundles[0].symlink
|
||||
}
|
||||
|
||||
return $xamarinBundles | ForEach-Object {
|
||||
$defaultPostfix = ($_.symlink -eq $defaultSymlink ) ? " (default)" : ""
|
||||
[PSCustomObject] @{
|
||||
"symlink" = $_.symlink + $defaultPostfix
|
||||
"Xamarin.Mono" = $_.mono
|
||||
"Xamarin.iOS" = $_.ios
|
||||
"Xamarin.Mac" = $_.mac
|
||||
"Xamarin.Android" = $_.android
|
||||
}
|
||||
}
|
||||
}
|
||||
254
images/macos/scripts/docs-gen/SoftwareReport.Xcode.psm1
Normal file
254
images/macos/scripts/docs-gen/SoftwareReport.Xcode.psm1
Normal file
@@ -0,0 +1,254 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
function Get-XcodePaths {
|
||||
$xcodePaths = Get-ChildItemWithoutSymlinks "/Applications" -Filter "Xcode_*.app"
|
||||
return $xcodePaths | Select-Object -ExpandProperty Fullname
|
||||
}
|
||||
|
||||
function Get-XcodeSDKList {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$XcodeRootPath
|
||||
)
|
||||
|
||||
$versionInfo = Get-XcodeVersionInfo -XcodeRootPath $XcodeRootPath
|
||||
$xcodebuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild"
|
||||
if ($versionInfo.Version -le [System.Version]::Parse("9.4.1")) {
|
||||
$output = Invoke-Expression "$xcodebuildPath -showsdks"
|
||||
$sdkList = $output | Where-Object { $_ -Match "-sdk" }
|
||||
|
||||
return $sdkList | ForEach-Object {
|
||||
$displayName, $canonicalName = $_.Split("-sdk")
|
||||
return @{
|
||||
canonicalName = $canonicalName.Trim()
|
||||
displayName = $displayName.Trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[string]$output = Invoke-Expression "$xcodebuildPath -showsdks -json"
|
||||
return $output | ConvertFrom-Json
|
||||
}
|
||||
|
||||
function Get-XcodeInfoList {
|
||||
$defaultXcodeRootPath = Get-DefaultXcodeRootPath
|
||||
|
||||
$xcodeInfo = @{}
|
||||
Get-XcodePaths | ForEach-Object {
|
||||
$xcodeRootPath = $_
|
||||
Switch-Xcode -XcodeRootPath $xcodeRootPath
|
||||
|
||||
$versionInfo = Get-XcodeVersionInfo -XcodeRootPath $xcodeRootPath
|
||||
$versionInfo.Path = $xcodeRootPath
|
||||
$versionInfo.IsDefault = ($xcodeRootPath -eq $defaultXcodeRootPath)
|
||||
$versionInfo.IsStable = Test-XcodeStableRelease -XcodeRootPath $xcodeRootPath
|
||||
|
||||
$xcodeInfo.Add($xcodeRootPath, [PSCustomObject] @{
|
||||
VersionInfo = $versionInfo
|
||||
SDKInfo = Get-XcodeSDKList -XcodeRootPath $xcodeRootPath
|
||||
SimulatorsInfo = Get-XcodeSimulatorsInfo
|
||||
})
|
||||
}
|
||||
|
||||
Switch-Xcode -XcodeRootPath $defaultXcodeRootPath
|
||||
|
||||
return $xcodeInfo
|
||||
}
|
||||
|
||||
function Get-XcodePlatformOrder {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[string] $PlatformName
|
||||
)
|
||||
|
||||
Switch ($PlatformName) {
|
||||
"macOS" { 1 }
|
||||
"iOS" { 2 }
|
||||
"Simulator - iOS" { 3 }
|
||||
"tvOS" { 4 }
|
||||
"Simulator - tvOS" { 5 }
|
||||
"watchOS" { 6 }
|
||||
"Simulator - watchOS" { 7 }
|
||||
Default { 100 }
|
||||
}
|
||||
}
|
||||
|
||||
function Get-XcodeCommandLineToolsVersion {
|
||||
$xcodeCommandLineToolsVersion = Run-Command "pkgutil --pkg-info com.apple.pkg.CLTools_Executables" | Select -Index 1 | Take-Part -Part 1
|
||||
return $xcodeCommandLineToolsVersion
|
||||
}
|
||||
|
||||
function Build-XcodeTable {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[hashtable] $xcodeInfo
|
||||
)
|
||||
|
||||
$sortRules = @{
|
||||
Expression = { $_.Version }
|
||||
Descending = $true
|
||||
}
|
||||
|
||||
$xcodeList = $xcodeInfo.Values | ForEach-Object { $_.VersionInfo } | Sort-Object $sortRules
|
||||
return $xcodeList | ForEach-Object {
|
||||
$defaultPostfix = If ($_.IsDefault) { " (default)" } else { "" }
|
||||
$betaPostfix = If ($_.IsStable) { "" } else { " (beta)" }
|
||||
return [PSCustomObject] @{
|
||||
"Version" = $_.Version.ToString() + $betaPostfix + $defaultPostfix
|
||||
"Build" = $_.Build
|
||||
"Path" = $_.Path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Build-XcodeDevicesList {
|
||||
param (
|
||||
[Parameter(Mandatory)][object] $XcodeInfo,
|
||||
[Parameter(Mandatory)][object] $Runtime
|
||||
)
|
||||
|
||||
$runtimeId = $Runtime.identifier
|
||||
$runtimeName = $Runtime.name
|
||||
$output = $XcodeInfo.SimulatorsInfo.devices.$runtimeId
|
||||
if ($null -eq $output) {
|
||||
$output = $XcodeInfo.SimulatorsInfo.devices.$runtimeName
|
||||
}
|
||||
|
||||
return $output
|
||||
}
|
||||
|
||||
function Build-XcodeSDKTable {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[hashtable] $xcodeInfo
|
||||
)
|
||||
|
||||
$sdkNames = @()
|
||||
$xcodeInfo.Values | ForEach-Object {
|
||||
$_.SDKInfo | ForEach-Object {
|
||||
$sdkNames += $_.canonicalName
|
||||
}
|
||||
}
|
||||
|
||||
$sdkNames = $sdkNames | Select-Object -Unique
|
||||
return $sdkNames | ForEach-Object {
|
||||
$sdkName = $_
|
||||
$sdkDisplayName = ""
|
||||
$xcodeList = @()
|
||||
$xcodeInfo.Values | ForEach-Object {
|
||||
$sdk = $_.SDKInfo | Where-Object { $_.canonicalName -eq $sdkName } | Select-Object -First 1
|
||||
if ($sdk) {
|
||||
$sdkDisplayName = $sdk.displayName
|
||||
$xcodeList += $_.VersionInfo.Version
|
||||
}
|
||||
}
|
||||
|
||||
$xcodeList = $xcodeList | Sort-Object
|
||||
|
||||
return [PSCustomObject] @{
|
||||
"SDK" = $sdkDisplayName
|
||||
"SDK Name" = $sdkName
|
||||
"Xcode Version" = [String]::Join(", ", $xcodeList)
|
||||
}
|
||||
} | Sort-Object {
|
||||
# Sort rule 1
|
||||
$sdkNameParts = $_."SDK".Split(" ")
|
||||
$platformName = [String]::Join(" ", $sdkNameParts[0..($sdkNameParts.Length - 2)])
|
||||
return Get-XcodePlatformOrder $platformName
|
||||
}, {
|
||||
# Sort rule 2
|
||||
$sdkNameParts = $_."SDK".Split(" ")
|
||||
return [System.Version]::Parse($sdkNameParts[-1])
|
||||
}
|
||||
}
|
||||
|
||||
function Format-XcodeSimulatorName {
|
||||
param(
|
||||
[Parameter(Mandatory)][string] $Device
|
||||
)
|
||||
|
||||
$formattedDeviceName = $Device.Replace("ʀ", "R")
|
||||
return $formattedDeviceName
|
||||
}
|
||||
|
||||
function Build-XcodeSimulatorsTable {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[hashtable] $xcodeInfo
|
||||
)
|
||||
|
||||
$runtimes = @()
|
||||
$xcodeInfo.Values | ForEach-Object {
|
||||
$_.SimulatorsInfo.runtimes | ForEach-Object {
|
||||
$runtimes += $_
|
||||
}
|
||||
}
|
||||
|
||||
$runtimes = $runtimes | Sort-Object @{ Expression = { $_.identifier } } -Unique
|
||||
|
||||
return $runtimes | ForEach-Object {
|
||||
$runtime = $_
|
||||
$runtimeDevices = @()
|
||||
$xcodeList = @()
|
||||
|
||||
$xcodeInfo.Values | ForEach-Object {
|
||||
$runtimeFound = $_.SimulatorsInfo.runtimes | Where-Object { $_.identifier -eq $runtime.identifier } | Select-Object -First 1
|
||||
if ($runtimeFound) {
|
||||
$devicesToAdd = Build-XcodeDevicesList -XcodeInfo $_ -Runtime $runtimeFound
|
||||
$runtimeDevices += $devicesToAdd | Select-Object -ExpandProperty name
|
||||
$xcodeList += $_.VersionInfo.Version
|
||||
}
|
||||
}
|
||||
|
||||
$xcodeList = $xcodeList | Sort-Object
|
||||
$runtimeDevices = $runtimeDevices | ForEach-Object { Format-XcodeSimulatorName $_ } | Select-Object -Unique
|
||||
$sortedRuntimeDevices = $runtimeDevices | Sort-Object @{
|
||||
Expression = { $_.Split(" ")[0] };
|
||||
Descending = $true;
|
||||
}, {
|
||||
$_.Split(" ") | Select-Object -Skip 1 | Join-String -Separator " "
|
||||
}
|
||||
|
||||
return [PSCustomObject] @{
|
||||
"OS" = $runtime.name
|
||||
"Xcode Version" = [String]::Join("<br>", $xcodeList)
|
||||
"Simulators" = [String]::Join("<br>", $sortedRuntimeDevices)
|
||||
}
|
||||
} | Sort-Object {
|
||||
# Sort rule 1
|
||||
$sdkNameParts = $_."OS".Split(" ")
|
||||
$platformName = [String]::Join(" ", $sdkNameParts[0..($sdkNameParts.Length - 2)])
|
||||
return Get-XcodePlatformOrder $platformName
|
||||
}, {
|
||||
# Sort rule 2
|
||||
$sdkNameParts = $_."OS".Split(" ")
|
||||
return [System.Version]::Parse($sdkNameParts[-1])
|
||||
}
|
||||
}
|
||||
|
||||
function Build-XcodeSupportToolsSection {
|
||||
$toolNodes = @()
|
||||
|
||||
$xcpretty = Run-Command "xcpretty --version"
|
||||
$xcversion = Run-Command "xcversion --version" | Select-String "^[0-9]"
|
||||
|
||||
$toolNodes += [ToolVersionNode]::new("xcpretty", $xcpretty)
|
||||
if ($os.IsBigSur -or $os.IsMonterey) {
|
||||
$toolNodes += [ToolVersionNode]::new("xcversion", $xcversion)
|
||||
}
|
||||
|
||||
$nomadOutput = Run-Command "gem list nomad-cli"
|
||||
$nomadCLI = [regex]::matches($nomadOutput, "(\d+.){2}\d+").Value
|
||||
$nomadShenzhenOutput = Run-Command "ipa -version"
|
||||
$nomadShenzhen = [regex]::matches($nomadShenzhenOutput, "(\d+.){2}\d+").Value
|
||||
|
||||
if ($os.IsBigSur) {
|
||||
$toolNodes += [ToolVersionNode]::new("Nomad CLI", $nomadCLI)
|
||||
$toolNodes += [ToolVersionNode]::new("Nomad shenzhen CLI", $nomadShenzhen)
|
||||
}
|
||||
|
||||
return $toolNodes
|
||||
}
|
||||
206
images/macos/scripts/helpers/Common.Helpers.psm1
Normal file
206
images/macos/scripts/helpers/Common.Helpers.psm1
Normal file
@@ -0,0 +1,206 @@
|
||||
function Get-CommandResult {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Command,
|
||||
[switch] $Multiline
|
||||
)
|
||||
# Bash trick to suppress and show error output because some commands write to stderr (for example, "python --version")
|
||||
$stdout = & bash -c "$Command 2>&1"
|
||||
$exitCode = $LASTEXITCODE
|
||||
return @{
|
||||
Output = If ($Multiline -eq $true) { $stdout } else { [string]$stdout }
|
||||
ExitCode = $exitCode
|
||||
}
|
||||
}
|
||||
|
||||
# Gets path to the tool, analogue of 'which tool'
|
||||
function Get-WhichTool($tool) {
|
||||
return (Get-Command $tool).Path
|
||||
}
|
||||
|
||||
# Gets value of environment variable by the name
|
||||
function Get-EnvironmentVariable($variable) {
|
||||
return [System.Environment]::GetEnvironmentVariable($variable)
|
||||
}
|
||||
|
||||
# Returns the object with information about current OS
|
||||
# It can be used for OS-specific tests
|
||||
function Get-OSVersion {
|
||||
$osVersion = [Environment]::OSVersion
|
||||
$osVersionMajorMinor = $osVersion.Version.ToString(2)
|
||||
$processorArchitecture = arch
|
||||
return [PSCustomObject]@{
|
||||
Version = $osVersion.Version
|
||||
Platform = $osVersion.Platform
|
||||
IsArm64 = $processorArchitecture -eq "arm64"
|
||||
IsBigSur = $osVersion.Version.Major -eq "11"
|
||||
IsMonterey = $osVersion.Version.Major -eq "12"
|
||||
IsVentura = $($osVersion.Version.Major -eq "13")
|
||||
IsVenturaArm64 = $($osVersion.Version.Major -eq "13" -and $processorArchitecture -eq "arm64")
|
||||
IsVenturaX64 = $($osVersion.Version.Major -eq "13" -and $processorArchitecture -ne "arm64")
|
||||
IsSonoma = $($osVersion.Version.Major -eq "14")
|
||||
IsSonomaArm64 = $($osVersion.Version.Major -eq "14" -and $processorArchitecture -eq "arm64")
|
||||
IsSonomaX64 = $($osVersion.Version.Major -eq "14" -and $processorArchitecture -ne "arm64")
|
||||
}
|
||||
}
|
||||
|
||||
function Get-ChildItemWithoutSymlinks {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Path,
|
||||
[string] $Filter
|
||||
)
|
||||
|
||||
$files = Get-ChildItem -Path $Path -Filter $Filter
|
||||
$files = $files | Where-Object { !$_.LinkType } # cut symlinks
|
||||
return $files
|
||||
}
|
||||
|
||||
# Get the value of specific toolset node
|
||||
# Example, invoke `Get-ToolsetValue "xamarin.bundles"` to get value of `$toolsetJson.xamarin.bundles`
|
||||
function Get-ToolsetValue {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $KeyPath
|
||||
)
|
||||
$toolsetPath = Join-Path $env:HOME "image-generation" "toolset.json"
|
||||
$jsonNode = Get-Content -Raw $toolsetPath | ConvertFrom-Json
|
||||
|
||||
$pathParts = $KeyPath.Split(".")
|
||||
# try to walk through all arguments consequentially to resolve specific json node
|
||||
$pathParts | ForEach-Object {
|
||||
$jsonNode = $jsonNode.$_
|
||||
}
|
||||
return $jsonNode
|
||||
}
|
||||
|
||||
function Get-ToolcachePackages {
|
||||
$toolcachePath = Join-Path $env:HOME "image-generation" "toolcache.json"
|
||||
return Get-Content -Raw $toolcachePath | ConvertFrom-Json
|
||||
}
|
||||
|
||||
function Invoke-RestMethodWithRetry {
|
||||
param (
|
||||
[Parameter()]
|
||||
[string]
|
||||
$Url
|
||||
)
|
||||
Invoke-RestMethod $Url -MaximumRetryCount 10 -RetryIntervalSec 30
|
||||
}
|
||||
|
||||
function Invoke-ValidateCommand {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Command,
|
||||
[Uint] $Timeout = 0
|
||||
)
|
||||
|
||||
if ($Timeout -eq 0)
|
||||
{
|
||||
$output = Invoke-Expression -Command $Command
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Command '$Command' has finished with exit code $LASTEXITCODE"
|
||||
}
|
||||
return $output
|
||||
}
|
||||
else
|
||||
{
|
||||
$job = $command | Start-Job -ScriptBlock {
|
||||
$output = Invoke-Expression -Command $input
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw 'Command failed'
|
||||
}
|
||||
return $output
|
||||
}
|
||||
$waitObject = $job | Wait-Job -Timeout $Timeout
|
||||
if(-not $waitObject)
|
||||
{
|
||||
throw "Command '$Command' has timed out"
|
||||
}
|
||||
if($waitObject.State -eq 'Failed')
|
||||
{
|
||||
throw "Command '$Command' has failed"
|
||||
}
|
||||
Receive-Job -Job $job
|
||||
}
|
||||
}
|
||||
|
||||
function Start-DownloadWithRetry {
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Url,
|
||||
[string] $Name,
|
||||
[string] $DownloadPath = "${env:Temp}",
|
||||
[int] $Retries = 20,
|
||||
[int] $Interval = 30
|
||||
)
|
||||
|
||||
if ([String]::IsNullOrEmpty($Name)) {
|
||||
$Name = [IO.Path]::GetFileName($Url)
|
||||
}
|
||||
|
||||
$filePath = Join-Path -Path $DownloadPath -ChildPath $Name
|
||||
|
||||
#Default retry logic for the package.
|
||||
while ($Retries -gt 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Write-Host "Downloading package from: $Url to path $filePath ."
|
||||
(New-Object System.Net.WebClient).DownloadFile($Url, $filePath)
|
||||
break
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "There is an error during package downloading:`n $_"
|
||||
$Retries--
|
||||
|
||||
if ($Retries -eq 0)
|
||||
{
|
||||
Write-Host "File can't be downloaded. Please try later or check that file exists by url: $Url"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Waiting $Interval seconds before retrying. Retries left: $Retries"
|
||||
Start-Sleep -Seconds $Interval
|
||||
}
|
||||
}
|
||||
|
||||
return $filePath
|
||||
}
|
||||
|
||||
function Add-EnvironmentVariable {
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory)] [string] $Name,
|
||||
[Parameter(Mandatory)] [string] $Value,
|
||||
[string] $FilePath = "${env:HOME}/.bashrc"
|
||||
)
|
||||
|
||||
$envVar = "export {0}={1}" -f $Name, $Value
|
||||
Add-Content -Path $FilePath -Value $envVar
|
||||
}
|
||||
|
||||
function isVeertu {
|
||||
return (Test-Path -Path "/Library/Application Support/Veertu")
|
||||
}
|
||||
|
||||
function Get-Architecture {
|
||||
$arch = arch
|
||||
if ($arch -ne "arm64")
|
||||
{
|
||||
$arch = "x64"
|
||||
}
|
||||
|
||||
return $arch
|
||||
}
|
||||
|
||||
function Test-CommandExists {
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory)] [string] $Command
|
||||
)
|
||||
|
||||
[boolean] (Get-Command $Command -ErrorAction 'SilentlyContinue')
|
||||
}
|
||||
54
images/macos/scripts/helpers/SoftwareReport.Helpers.psm1
Normal file
54
images/macos/scripts/helpers/SoftwareReport.Helpers.psm1
Normal file
@@ -0,0 +1,54 @@
|
||||
function Run-Command {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Command,
|
||||
[switch] $SuppressStderr
|
||||
)
|
||||
# Bash trick to suppress and show error output because some commands write to stderr (for example, "python --version")
|
||||
$redirectOutputArguments = If ($SuppressStderr) { "2> /dev/null" } Else { "2>&1" }
|
||||
$stdout = & bash -c "${Command} ${redirectOutputArguments}"
|
||||
|
||||
return $stdout
|
||||
}
|
||||
|
||||
function Take-Part {
|
||||
param (
|
||||
[Parameter(ValueFromPipeline)]
|
||||
[string] $toolOutput,
|
||||
[string] $Delimiter = " ",
|
||||
[int[]] $Part
|
||||
)
|
||||
$parts = $toolOutput.Split($Delimiter, [System.StringSplitOptions]::RemoveEmptyEntries)
|
||||
$selectedParts = $parts[$Part]
|
||||
return [string]::Join($Delimiter, $selectedParts)
|
||||
}
|
||||
|
||||
function Get-LinkTarget {
|
||||
param (
|
||||
[string] $inputPath
|
||||
)
|
||||
$link = Get-Item $inputPath | Select-Object -ExpandProperty Target
|
||||
if ($link) {
|
||||
return " -> $link"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
function Get-PathWithLink {
|
||||
param (
|
||||
[string] $inputPath
|
||||
)
|
||||
$link = Get-LinkTarget($inputPath)
|
||||
return "${inputPath}${link}"
|
||||
}
|
||||
|
||||
function Get-BrewPackageVersion {
|
||||
param (
|
||||
[string] $CommandName
|
||||
)
|
||||
|
||||
(Get-LinkTarget (Get-Command $CommandName).Source | Out-String) -match "(?<version>(\d+.){2}\d+)" | Out-Null
|
||||
$packageVersion = $Matches.Version
|
||||
|
||||
return $packageVersion
|
||||
}
|
||||
152
images/macos/scripts/helpers/Tests.Helpers.psm1
Normal file
152
images/macos/scripts/helpers/Tests.Helpers.psm1
Normal file
@@ -0,0 +1,152 @@
|
||||
Import-Module "$PSScriptRoot/Common.Helpers.psm1"
|
||||
|
||||
# Validates that tool is installed and in PATH
|
||||
function Validate-ToolExist($tool) {
|
||||
Get-Command $tool -ErrorAction SilentlyContinue | Should -BeTrue
|
||||
}
|
||||
|
||||
function Validate-ArrayWithoutDuplicates {
|
||||
param (
|
||||
[AllowEmptyCollection()]
|
||||
[Parameter(Mandatory = $true)]
|
||||
[array] $Items,
|
||||
[string] $Because
|
||||
)
|
||||
$uniqueList = @()
|
||||
$Items | ForEach-Object {
|
||||
$uniqueList | Should -Not -Contain $_ -Because $Because
|
||||
$uniqueList += $_
|
||||
}
|
||||
}
|
||||
|
||||
function Validate-Url {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $Url
|
||||
)
|
||||
|
||||
$result = $true
|
||||
try {
|
||||
$requestResult = Invoke-WebRequest $Url -DisableKeepAlive -UseBasicParsing -Method Head
|
||||
$result = ($requestResult.StatusCode -eq 200)
|
||||
} catch {
|
||||
$result = $false
|
||||
}
|
||||
|
||||
$result | Should -BeTrue -Because "'$Url' should be available, but it is not"
|
||||
}
|
||||
|
||||
function Validate-IdenticalFileContent {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[string] $File1,
|
||||
[Parameter(Mandatory)]
|
||||
[string] $File2
|
||||
)
|
||||
|
||||
$File1 | Should -Exist -Because "The content of '$File1' should be identical with content of '$File2' but '$File1' doesn't exist"
|
||||
$File2 | Should -Exist -Because "The content of '$File1' should be identical with content of '$File2' but '$File2' doesn't exist"
|
||||
|
||||
$content1 = Get-Content -Raw $File1
|
||||
$content2 = Get-Content -Raw $File2
|
||||
$content1 | Should -Be $content2 -Because "The content of '$File1' should be identical with content of '$File2' but they are different"
|
||||
}
|
||||
|
||||
function ShouldReturnZeroExitCode {
|
||||
Param(
|
||||
[String] $ActualValue,
|
||||
[switch] $Negate,
|
||||
[string] $Because # This parameter is unused by we need it to match Pester asserts signature
|
||||
)
|
||||
|
||||
$result = Get-CommandResult $ActualValue
|
||||
|
||||
[bool]$succeeded = $result.ExitCode -eq 0
|
||||
if ($Negate) { $succeeded = -not $succeeded }
|
||||
|
||||
if (-not $succeeded)
|
||||
{
|
||||
$commandOutputIndent = " " * 4
|
||||
$commandOutput = ($result.Output | ForEach-Object { "${commandOutputIndent}${_}" }) -join "`n"
|
||||
$failureMessage = "Command '${ActualValue}' has finished with exit code ${actualExitCode}`n${commandOutput}"
|
||||
}
|
||||
|
||||
return [PSCustomObject] @{
|
||||
Succeeded = $succeeded
|
||||
FailureMessage = $failureMessage
|
||||
}
|
||||
}
|
||||
|
||||
function ShouldMatchCommandOutput {
|
||||
Param(
|
||||
[String] $ActualValue,
|
||||
[String] $RegularExpression,
|
||||
[switch] $Negate
|
||||
)
|
||||
|
||||
$output = (Get-CommandResult $ActualValue).Output | Out-String
|
||||
[bool] $succeeded = $output -cmatch $RegularExpression
|
||||
|
||||
if ($Negate) {
|
||||
$succeeded = -not $succeeded
|
||||
}
|
||||
|
||||
$failureMessage = ''
|
||||
|
||||
if (-not $succeeded) {
|
||||
if ($Negate) {
|
||||
$failureMessage = "Expected regular expression '$RegularExpression' for '$ActualValue' command to not match '$output', but it did match."
|
||||
}
|
||||
else {
|
||||
$failureMessage = "Expected regular expression '$RegularExpression' for '$ActualValue' command to match '$output', but it did not match."
|
||||
}
|
||||
}
|
||||
|
||||
return [PSCustomObject] @{
|
||||
Succeeded = $succeeded
|
||||
FailureMessage = $failureMessage
|
||||
}
|
||||
}
|
||||
|
||||
If (Get-Command -Name Add-ShouldOperator -ErrorAction SilentlyContinue) {
|
||||
Add-ShouldOperator -Name ReturnZeroExitCode -InternalName ShouldReturnZeroExitCode -Test ${function:ShouldReturnZeroExitCode}
|
||||
Add-ShouldOperator -Name MatchCommandOutput -InternalName ShouldMatchCommandOutput -Test ${function:ShouldMatchCommandOutput}
|
||||
}
|
||||
|
||||
function Invoke-PesterTests {
|
||||
Param(
|
||||
[Parameter(Mandatory)][string] $TestFile,
|
||||
[string] $TestName
|
||||
)
|
||||
|
||||
$testPath = "$HOME/image-generation/tests/${TestFile}.Tests.ps1"
|
||||
if (-not (Test-Path $testPath)) {
|
||||
throw "Unable to find test file '$TestFile' on '$testPath'."
|
||||
}
|
||||
|
||||
# Check that Pester module is imported
|
||||
if (!(Get-Module "Pester")) {
|
||||
Import-Module Pester
|
||||
}
|
||||
|
||||
$configuration = [PesterConfiguration] @{
|
||||
Run = @{ Path = $testPath; PassThru = $true }
|
||||
Output = @{ Verbosity = "Detailed"; RenderMode = "Plaintext" }
|
||||
}
|
||||
if ($TestName) {
|
||||
$configuration.Filter.FullName = $TestName
|
||||
}
|
||||
|
||||
# Switch ErrorActionPreference to make sure that tests will fail on silent errors too
|
||||
$backupErrorActionPreference = $ErrorActionPreference
|
||||
$ErrorActionPreference = "Stop"
|
||||
$results = Invoke-Pester -Configuration $configuration
|
||||
$ErrorActionPreference = $backupErrorActionPreference
|
||||
|
||||
# Fail in case if no tests are run
|
||||
if (-not ($results -and ($results.FailedCount -eq 0) -and ($results.PassedCount -gt 0))) {
|
||||
$results
|
||||
throw "Test run has failed"
|
||||
}
|
||||
}
|
||||
308
images/macos/scripts/helpers/Xcode.Helpers.psm1
Normal file
308
images/macos/scripts/helpers/Xcode.Helpers.psm1
Normal file
@@ -0,0 +1,308 @@
|
||||
function Get-XcodeRootPath {
|
||||
Param (
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Version
|
||||
)
|
||||
|
||||
return "/Applications/Xcode_$Version.app"
|
||||
}
|
||||
|
||||
function Get-DefaultXcodeRootPath {
|
||||
return (Get-Item -Path "/Applications/Xcode.app").Target
|
||||
}
|
||||
|
||||
function Get-XcodeToolPath {
|
||||
param (
|
||||
[Parameter(ParameterSetName = 'Version')]
|
||||
[string] $Version,
|
||||
[Parameter(ParameterSetName = 'Path')]
|
||||
[string] $XcodeRootPath,
|
||||
[string] $ToolName
|
||||
)
|
||||
|
||||
if ($PSCmdlet.ParameterSetName -eq "Version") {
|
||||
$XcodeRootPath = Get-XcodeRootPath $Version
|
||||
}
|
||||
|
||||
return Join-Path $XcodeRootPath "Contents/Developer/usr/bin" $ToolName
|
||||
}
|
||||
|
||||
function Get-XcodeVersionInfo {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$XcodeRootPath
|
||||
)
|
||||
|
||||
$xcodebuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild"
|
||||
[string]$output = Invoke-Expression "$xcodebuildPath -version"
|
||||
$versionOutputParts = $output.Split(" ")
|
||||
return @{
|
||||
Version = [System.Version]::Parse($versionOutputParts[1])
|
||||
Build = $versionOutputParts[4]
|
||||
}
|
||||
}
|
||||
|
||||
function Switch-Xcode {
|
||||
param (
|
||||
[Parameter(ParameterSetName = 'Version')]
|
||||
[string] $Version,
|
||||
[Parameter(ParameterSetName = 'Path')]
|
||||
[string] $XcodeRootPath
|
||||
)
|
||||
|
||||
if ($PSCmdlet.ParameterSetName -eq "Version") {
|
||||
$XcodeRootPath = Get-XcodeRootPath $Version
|
||||
}
|
||||
|
||||
Write-Verbose "Switching Xcode to '${XcodeRootPath}'"
|
||||
Invoke-Expression "sudo xcode-select --switch ${XcodeRootPath}"
|
||||
}
|
||||
|
||||
function Test-XcodeStableRelease {
|
||||
param (
|
||||
[Parameter(ParameterSetName = 'Version')]
|
||||
[string] $Version,
|
||||
[Parameter(ParameterSetName = 'Path')]
|
||||
[string] $XcodeRootPath
|
||||
)
|
||||
|
||||
if ($PSCmdlet.ParameterSetName -eq "Version") {
|
||||
$XcodeRootPath = Get-XcodeRootPath $Version
|
||||
}
|
||||
|
||||
$licenseInfoPlistPath = Join-Path $XcodeRootPath "Contents" "Resources" "LicenseInfo.plist"
|
||||
$releaseType = & defaults read $licenseInfoPlistPath "licenseType"
|
||||
return -not ($releaseType -match "beta")
|
||||
}
|
||||
|
||||
function Get-XcodeSimulatorsInfo {
|
||||
param(
|
||||
[string] $Filter
|
||||
)
|
||||
|
||||
[string]$rawSimulatorsInfo = Invoke-Expression "xcrun simctl list --json"
|
||||
$jsonSimulatorsInfo = $rawSimulatorsInfo | ConvertFrom-Json
|
||||
|
||||
if ($Filter) {
|
||||
return $jsonSimulatorsInfo | Select-Object -ExpandProperty $Filter
|
||||
}
|
||||
|
||||
return $jsonSimulatorsInfo
|
||||
}
|
||||
|
||||
function Get-XcodeDevicesList {
|
||||
$result = @()
|
||||
|
||||
$runtimes = Get-XcodeSimulatorsInfo -Filter "devices"
|
||||
$runtimes.PSObject.Properties | ForEach-Object {
|
||||
$runtimeName = $_.Name
|
||||
$devices = $_.Value
|
||||
$devices | Where-Object {
|
||||
$availability = $_.availability
|
||||
$isAvailable = $_.isAvailable
|
||||
return (($availability -eq "(available)") -or ($isAvailable -eq "YES") -or ($isAvailable -eq $true))
|
||||
} | ForEach-Object {
|
||||
$deviceName = $_.name
|
||||
$result += "$runtimeName $deviceName"
|
||||
}
|
||||
}
|
||||
return $result
|
||||
}
|
||||
|
||||
function Get-XcodePairsList {
|
||||
$result = @()
|
||||
|
||||
$runtimes = Get-XcodeSimulatorsInfo -Filter "pairs"
|
||||
$runtimes.PSObject.Properties | Where-Object {
|
||||
return $_.Value.state -match "active"
|
||||
} | ForEach-Object {
|
||||
$watchName = $_.Value.watch.name
|
||||
$phoneName = $_.Value.phone.name
|
||||
$result += "$watchName $phoneName"
|
||||
}
|
||||
return $result
|
||||
}
|
||||
|
||||
#Helper function for execution of xcversion due to: https://github.com/fastlane/fastlane/issues/18161
|
||||
function Invoke-XCVersion {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Arguments,
|
||||
[Parameter()]
|
||||
[int] $RetryAttempts = 7,
|
||||
[Parameter()]
|
||||
[int] $PauseDurationSecs = 1
|
||||
)
|
||||
|
||||
$Command = "xcversion $Arguments"
|
||||
Write-Host "Execute [$Command]"
|
||||
for ($Attempt=1; $Attempt -le $RetryAttempts; $Attempt++) {
|
||||
Write-Host "Current attempt: [$Attempt]"
|
||||
$result = Get-CommandResult -Command $Command -Multiline
|
||||
Write-Host "Exit code: [$($result.ExitCode)]"
|
||||
Write-Host "Output message: "
|
||||
$result.Output | ForEach-Object { Write-Host $_ }
|
||||
if ($result.ExitCode -ne 0) {
|
||||
Start-Sleep -Seconds $PauseDurationSecs
|
||||
} else {
|
||||
return $result.Output
|
||||
}
|
||||
}
|
||||
if ($result.ExitCode -ne 0) {
|
||||
throw "Command [$Command] has finished with non-zero exit code."
|
||||
}
|
||||
}
|
||||
|
||||
function Get-BrokenXcodeSimulatorsList {
|
||||
return @(
|
||||
# tvOS Simulators
|
||||
@{
|
||||
SimulatorName = "Apple TV 4K (at 1080p) (2nd generation)"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.tvOS-15-0";
|
||||
XcodeVersion = "13.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple TV 4K (at 1080p) (2nd generation)"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.tvOS-15-2";
|
||||
XcodeVersion = "13.2.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple TV 4K (at 1080p) (2nd generation)"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.tvOS-15-4";
|
||||
XcodeVersion = "13.4.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple TV 4K (at 1080p) (2nd generation)"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.tvOS-16-0";
|
||||
XcodeVersion = "14.2"
|
||||
},
|
||||
# watchOS-8-0 Simulators
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 5 - 40mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-40mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-0";
|
||||
XcodeVersion = "13.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 5 - 44mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-44mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-0";
|
||||
XcodeVersion = "13.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 6 - 40mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-40mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-0";
|
||||
XcodeVersion = "13.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 6 - 44mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-44mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-0";
|
||||
XcodeVersion = "13.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 7 - 41mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-41mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-0";
|
||||
XcodeVersion = "13.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 7 - 45mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-45mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-0";
|
||||
XcodeVersion = "13.1"
|
||||
},
|
||||
# watchOS-8-3 Simulators
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 5 - 40mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-40mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-3";
|
||||
XcodeVersion = "13.2.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 5 - 44mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-44mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-3";
|
||||
XcodeVersion = "13.2.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 6 - 40mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-40mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-3";
|
||||
XcodeVersion = "13.2.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 6 - 44mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-44mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-3";
|
||||
XcodeVersion = "13.2.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 7 - 41mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-41mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-3";
|
||||
XcodeVersion = "13.2.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 7 - 45mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-45mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-3";
|
||||
XcodeVersion = "13.2.1"
|
||||
},
|
||||
# watchOS-8-5 Simulators
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 5 - 40mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-40mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-5";
|
||||
XcodeVersion = "13.4.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 5 - 44mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-44mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-5";
|
||||
XcodeVersion = "13.4.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 6 - 40mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-40mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-5";
|
||||
XcodeVersion = "13.4.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 6 - 44mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-44mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-5";
|
||||
XcodeVersion = "13.4.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 7 - 41mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-41mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-5";
|
||||
XcodeVersion = "13.4.1"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch Series 7 - 45mm"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-45mm";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-8-5";
|
||||
XcodeVersion = "13.4.1"
|
||||
},
|
||||
# watchOS-9-0 Simulators
|
||||
@{
|
||||
SimulatorName = "Apple Watch SE (40mm) (2nd generation)"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-40mm-2nd-generation";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-9-0";
|
||||
XcodeVersion = "14.2"
|
||||
},
|
||||
@{
|
||||
SimulatorName = "Apple Watch SE (44mm) (2nd generation)"
|
||||
DeviceId = "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-44mm-2nd-generation";
|
||||
RuntimeId = "com.apple.CoreSimulator.SimRuntime.watchOS-9-0";
|
||||
XcodeVersion = "14.2"
|
||||
}
|
||||
)
|
||||
}
|
||||
249
images/macos/scripts/helpers/Xcode.Installer.psm1
Normal file
249
images/macos/scripts/helpers/Xcode.Installer.psm1
Normal file
@@ -0,0 +1,249 @@
|
||||
Import-Module "$PSScriptRoot/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/Xcode.Helpers.psm1"
|
||||
|
||||
function Install-XcodeVersion {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$LinkTo
|
||||
)
|
||||
|
||||
$xcodeDownloadDirectory = "$env:HOME/Library/Caches/XcodeInstall"
|
||||
$xcodeTargetPath = Get-XcodeRootPath -Version $LinkTo
|
||||
$xcodeXipDirectory = Invoke-DownloadXcodeArchive -DownloadDirectory $xcodeDownloadDirectory -Version $Version
|
||||
Expand-XcodeXipArchive -DownloadDirectory $xcodeXipDirectory.FullName -TargetPath $xcodeTargetPath
|
||||
|
||||
Remove-Item -Path $xcodeXipDirectory -Force -Recurse
|
||||
}
|
||||
|
||||
function Invoke-DownloadXcodeArchive {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$DownloadDirectory,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
Write-Host "Downloading Xcode $Version"
|
||||
|
||||
$tempXipDirectory = New-Item -Path $DownloadDirectory -Name "Xcode$Version" -ItemType "Directory"
|
||||
|
||||
$xcodeFileName = 'Xcode-{0}.xip' -f $Version
|
||||
$xcodeUri = '{0}{1}?{2}'-f ${env:XCODE_INSTALL_STORAGE_URL}, $xcodeFileName, ${env:XCODE_INSTALL_SAS}
|
||||
|
||||
Start-DownloadWithRetry -Url $xcodeUri -DownloadPath $tempXipDirectory.FullName -Name $xcodeFileName
|
||||
return $tempXipDirectory
|
||||
|
||||
}
|
||||
|
||||
function Resolve-ExactXcodeVersion {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
# if toolset string contains spaces, consider it as a full name of Xcode
|
||||
if ($Version -match "\s") {
|
||||
return $Version
|
||||
}
|
||||
|
||||
$semverVersion = [SemVer]::Parse($Version)
|
||||
$availableVersions = Get-AvailableXcodeVersions
|
||||
$satisfiedVersions = $availableVersions | Where-Object { $semverVersion -eq $_.stableSemver }
|
||||
return $satisfiedVersions | Select-Object -Last 1 -ExpandProperty rawVersion
|
||||
}
|
||||
|
||||
function Get-AvailableXcodeVersions {
|
||||
$rawVersionsList = Invoke-XCVersion -Arguments "list" | ForEach-Object { $_.Trim() } | Where-Object { $_ -match "^\d" }
|
||||
$availableVersions = $rawVersionsList | ForEach-Object {
|
||||
$partStable,$partMajor = $_.Split(" ", 2)
|
||||
$semver = $stableSemver = [SemVer]::Parse($partStable)
|
||||
if ($partMajor) {
|
||||
# Convert 'beta 3' -> 'beta.3', 'Release Candidate' -> 'releasecandidate', 'GM Seed 2' -> 'gmseed.2'
|
||||
$normalizedLabel = $partMajor.toLower() -replace " (\d)", '.$1' -replace " ([a-z])", '$1'
|
||||
$semver = [SemVer]::new($stableSemver.Major, $stableSemver.Minor, $stableSemver.Patch, $normalizedLabel)
|
||||
}
|
||||
|
||||
return [PSCustomObject]@{
|
||||
semver = $semver
|
||||
rawVersion = $_
|
||||
stableSemver = $stableSemver
|
||||
}
|
||||
}
|
||||
|
||||
return $availableVersions | Sort-Object -Property semver
|
||||
}
|
||||
|
||||
function Expand-XcodeXipArchive {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$DownloadDirectory,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$TargetPath
|
||||
)
|
||||
|
||||
$xcodeXipPath = Get-ChildItem -Path $DownloadDirectory -Filter "Xcode-*.xip" | Select-Object -First 1
|
||||
|
||||
Write-Host "Extracting Xcode from '$xcodeXipPath'"
|
||||
Push-Location $DownloadDirectory
|
||||
if(Test-CommandExists 'unxip') {
|
||||
Invoke-ValidateCommand "unxip $xcodeXipPath"
|
||||
} else {
|
||||
Invoke-ValidateCommand "xip -x $xcodeXipPath"
|
||||
}
|
||||
Pop-Location
|
||||
|
||||
if (Test-Path "$DownloadDirectory/Xcode-beta.app") {
|
||||
Write-Host "Renaming Xcode-beta.app to Xcode.app"
|
||||
Rename-Item -Path "$DownloadDirectory/Xcode-beta.app" -NewName "Xcode.app"
|
||||
}
|
||||
|
||||
if (-not (Test-Path "$DownloadDirectory/Xcode.app")) {
|
||||
throw "XIP archive '$xcodeXipPath' doesn't contain 'Xcode.app'"
|
||||
}
|
||||
|
||||
Write-Host "Moving '$DownloadDirectory/Xcode.app' to '$TargetPath'"
|
||||
Move-Item -Path "$DownloadDirectory/Xcode.app" -Destination $TargetPath
|
||||
}
|
||||
|
||||
function Confirm-XcodeIntegrity {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
$XcodeRootPath = Get-XcodeRootPath -Version $Version
|
||||
if (Test-XcodeStableRelease -XcodeRootPath $XcodeRootPath) {
|
||||
Write-Host "Validating Xcode integrity for '$XcodeRootPath'..."
|
||||
Invoke-ValidateCommand "spctl --assess --raw $XcodeRootPath"
|
||||
}
|
||||
}
|
||||
|
||||
function Approve-XcodeLicense {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
$XcodeRootPath = Get-XcodeRootPath -Version $Version
|
||||
Write-Host "Approving Xcode license for '$XcodeRootPath'..."
|
||||
$xcodeBuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild"
|
||||
|
||||
if ($os.IsVentura -or $os.IsSonoma) {
|
||||
Invoke-ValidateCommand -Command "sudo $xcodeBuildPath -license accept" -Timeout 15
|
||||
} else {
|
||||
Invoke-ValidateCommand -Command "sudo $xcodeBuildPath -license accept"
|
||||
}
|
||||
}
|
||||
|
||||
function Install-XcodeAdditionalPackages {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
Write-Host "Installing additional packages for Xcode $Version..."
|
||||
$xcodeRootPath = Get-XcodeRootPath -Version $Version
|
||||
$packages = Get-ChildItem -Path "$xcodeRootPath/Contents/Resources/Packages" -Filter "*.pkg" -File
|
||||
$packages | ForEach-Object {
|
||||
Invoke-ValidateCommand "sudo installer -pkg $($_.FullName) -target / -allowUntrusted"
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-XcodeRunFirstLaunch {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
if ($Version.StartsWith("8") -or $Version.StartsWith("9")) {
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Running 'runFirstLaunch' for Xcode $Version..."
|
||||
$xcodeRootPath = Get-XcodeToolPath -Version $Version -ToolName "xcodebuild"
|
||||
Invoke-ValidateCommand "sudo $xcodeRootPath -runFirstLaunch"
|
||||
}
|
||||
|
||||
function Install-AdditionalSimulatorRuntimes {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
Write-Host "Installing Simulator Runtimes for Xcode $Version ..."
|
||||
$xcodebuildPath = Get-XcodeToolPath -Version $Version -ToolName "xcodebuild"
|
||||
Invoke-ValidateCommand "$xcodebuildPath -downloadAllPlatforms" | Out-Null
|
||||
}
|
||||
|
||||
function Build-XcodeSymlinks {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version,
|
||||
[string[]]$Symlinks
|
||||
)
|
||||
|
||||
$sourcePath = Get-XcodeRootPath -Version $Version
|
||||
$Symlinks | Where-Object { $_ } | ForEach-Object {
|
||||
$targetPath = Get-XcodeRootPath -Version $_
|
||||
Write-Host "Creating symlink: '$targetPath' -> '$sourcePath'"
|
||||
New-Item -Path $targetPath -ItemType SymbolicLink -Value $sourcePath | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
function Rebuild-XcodeLaunchServicesDb {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
$xcodePath = Get-XcodeRootPath -Version $Version
|
||||
$lsregister = '/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister'
|
||||
Get-ChildItem -Recurse -Filter "*.app" $xcodePath | Foreach-Object { & $lsregister -f $_.FullName}
|
||||
}
|
||||
|
||||
function Build-ProvisionatorSymlink {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
$sourcePath = Get-XcodeRootPath -Version $Version
|
||||
$versionInfo = Get-XcodeVersionInfo -XcodeRootPath $sourcePath
|
||||
|
||||
$targetVersion = [SemVer]::Parse($versionInfo.Version).ToString()
|
||||
$targetPath = Get-XcodeRootPath -Version $targetVersion
|
||||
if ($sourcePath -ne $targetPath) {
|
||||
Write-Host "Creating symlink: '$targetPath' -> '$sourcePath'"
|
||||
New-Item -Path $targetPath -ItemType SymbolicLink -Value $sourcePath | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
function Set-XcodeDeveloperDirEnvironmentVariables {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string[]]$XcodeList
|
||||
)
|
||||
|
||||
$exactVersionsList = $XcodeList | Where-Object { Test-XcodeStableRelease -Version $_ } | ForEach-Object {
|
||||
$xcodeRootPath = Get-XcodeRootPath -Version $_
|
||||
$xcodeVersionInfo = Get-XcodeVersionInfo -XcodeRootPath $xcodeRootPath
|
||||
return @{
|
||||
RootPath = $xcodeRootPath
|
||||
Version = [SemVer]::Parse($xcodeVersionInfo.Version)
|
||||
}
|
||||
} | Sort-Object -Property Version -Descending
|
||||
|
||||
$majorVersions = $exactVersionsList.Version.Major | Select-Object -Unique
|
||||
$majorVersions | ForEach-Object {
|
||||
$majorVersion = $_
|
||||
$latestXcodeVersion = $exactVersionsList | Where-Object { $_.Version.Major -eq $majorVersion } | Select-Object -First 1
|
||||
$variableName = "XCODE_${_}_DEVELOPER_DIR"
|
||||
$variableValue = "$($latestXcodeVersion.RootPath)/Contents/Developer"
|
||||
Write-Host "Set ${variableName}=${variableValue}"
|
||||
"export ${variableName}=${variableValue}" | Out-File "$env:HOME/.bashrc" -Append
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
# This AppleScript confirms developers in security preferences via macOS UI.
|
||||
# It uses after VirtualBox installation to add 'Oracle Inc' as identified developer.
|
||||
# Steps:
|
||||
# - Close security preferences pop-up (it can be open after VirtualBox installation)
|
||||
# - Open System Preferences -> Security & Privacy -> General
|
||||
# - Unlock security preferences with user password (button 'Click the lock to make changes')
|
||||
# - Click 'Allow' or 'Details…' button to confirm developers
|
||||
# - Click 'Not now' button on restarting pop-up
|
||||
# - Close System Preferences
|
||||
|
||||
on run argv
|
||||
set userpassword to item 1 of argv
|
||||
set secpane to "Security & Privacy"
|
||||
|
||||
activate application "System Preferences"
|
||||
delay 5
|
||||
|
||||
tell application "System Events"
|
||||
tell process "System Preferences"
|
||||
set frontmost to true
|
||||
delay 2
|
||||
click menu item secpane of menu "View" of menu bar 1
|
||||
delay 5
|
||||
click button 1 of window 1
|
||||
delay 5
|
||||
keystroke userpassword
|
||||
delay 5
|
||||
keystroke return
|
||||
delay 5
|
||||
click radio button "General" of tab group 1 of window 1
|
||||
delay 5
|
||||
if exists of UI element "Details…" of tab group 1 of window 1 then
|
||||
click button "Details…" of tab group 1 of window 1
|
||||
delay 5
|
||||
keystroke return
|
||||
delay 5
|
||||
keystroke return
|
||||
delay 5
|
||||
end if
|
||||
if exists of UI element "Allow" of tab group 1 of window 1 then
|
||||
click button "Allow" of tab group 1 of window 1
|
||||
delay 5
|
||||
keystroke return
|
||||
delay 5
|
||||
end if
|
||||
click button 5 of window 1
|
||||
end tell
|
||||
end tell
|
||||
end run
|
||||
5
images/macos/scripts/helpers/invoke-tests.sh
Normal file
5
images/macos/scripts/helpers/invoke-tests.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source $HOME/.bashrc
|
||||
pwsh -Command "Import-Module '$HOME/image-generation/helpers/Tests.Helpers.psm1' -DisableNameChecking
|
||||
Invoke-PesterTests -TestFile \"$1\" -TestName \"$2\""
|
||||
242
images/macos/scripts/helpers/utils.sh
Normal file
242
images/macos/scripts/helpers/utils.sh
Normal file
@@ -0,0 +1,242 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
download_with_retries() {
|
||||
# Due to restrictions of bash functions, positional arguments are used here.
|
||||
# In case if you using latest argument NAME, you should also set value to all previous parameters.
|
||||
# Example: download_with_retries $ANDROID_SDK_URL "." "android_sdk.zip"
|
||||
local URL="$1"
|
||||
local DEST="${2:-.}"
|
||||
local NAME="${3:-${URL##*/}}"
|
||||
local COMPRESSED="$4"
|
||||
|
||||
if [[ $COMPRESSED == "compressed" ]]; then
|
||||
local COMMAND="curl $URL -4 -sL --compressed -o '$DEST/$NAME' -w '%{http_code}'"
|
||||
else
|
||||
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--))
|
||||
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
|
||||
else
|
||||
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
|
||||
done
|
||||
|
||||
echo "Could not download $URL"
|
||||
return 1
|
||||
}
|
||||
|
||||
is_Arm64() {
|
||||
[ "$(arch)" = "arm64" ]
|
||||
}
|
||||
|
||||
is_Sonoma() {
|
||||
[ "$OSTYPE" = "darwin23" ]
|
||||
}
|
||||
|
||||
is_SonomaArm64() {
|
||||
is_Sonoma && is_Arm64
|
||||
}
|
||||
|
||||
is_SonomaX64() {
|
||||
is_Sonoma && ! is_Arm64
|
||||
}
|
||||
|
||||
is_Ventura() {
|
||||
[ "$OSTYPE" = "darwin22" ]
|
||||
}
|
||||
|
||||
is_VenturaArm64() {
|
||||
is_Ventura && is_Arm64
|
||||
}
|
||||
|
||||
is_VenturaX64() {
|
||||
is_Ventura && ! is_Arm64
|
||||
}
|
||||
|
||||
is_Monterey() {
|
||||
[ "$OSTYPE" = "darwin21" ]
|
||||
}
|
||||
|
||||
is_BigSur() {
|
||||
[ "$OSTYPE" = "darwin20" ]
|
||||
}
|
||||
|
||||
is_Veertu() {
|
||||
[ -d "/Library/Application Support/Veertu" ]
|
||||
}
|
||||
|
||||
get_toolset_path() {
|
||||
echo "$HOME/image-generation/toolset.json"
|
||||
}
|
||||
|
||||
get_toolset_value() {
|
||||
local toolset_path=$(get_toolset_path)
|
||||
local query=$1
|
||||
echo "$(jq -r "$query" $toolset_path)"
|
||||
}
|
||||
|
||||
verlte() {
|
||||
sortedVersion=$(echo -e "$1\n$2" | sort -V | head -n1)
|
||||
[ "$1" = "$sortedVersion" ]
|
||||
}
|
||||
|
||||
brew_cask_install_ignoring_sha256() {
|
||||
local TOOL_NAME=$1
|
||||
|
||||
CASK_DIR="$(brew --repo homebrew/cask)/Casks"
|
||||
chmod a+w "$CASK_DIR/$TOOL_NAME.rb"
|
||||
SHA=$(grep "sha256" "$CASK_DIR/$TOOL_NAME.rb" | awk '{print $2}')
|
||||
sed -i '' "s/$SHA/:no_check/" "$CASK_DIR/$TOOL_NAME.rb"
|
||||
brew install --cask $TOOL_NAME
|
||||
pushd $CASK_DIR
|
||||
git checkout HEAD -- "$TOOL_NAME.rb"
|
||||
popd
|
||||
}
|
||||
|
||||
get_brew_os_keyword() {
|
||||
if is_BigSur; then
|
||||
echo "big_sur"
|
||||
elif is_Monterey; then
|
||||
echo "monterey"
|
||||
elif is_Ventura; then
|
||||
echo "ventura"
|
||||
elif is_Sonoma; then
|
||||
echo "sonoma"
|
||||
else
|
||||
echo "null"
|
||||
fi
|
||||
}
|
||||
|
||||
# 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
|
||||
brew_smart_install() {
|
||||
local tool_name=$1
|
||||
|
||||
echo "Downloading $tool_name..."
|
||||
|
||||
# get deps & cache em
|
||||
|
||||
failed=true
|
||||
for i in {1..10}; do
|
||||
brew deps $tool_name > /tmp/$tool_name && failed=false || sleep 60
|
||||
[ "$failed" = false ] && break
|
||||
done
|
||||
|
||||
if [ "$failed" = true ]; then
|
||||
echo "Failed: brew deps $tool_name"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
for dep in $(cat /tmp/$tool_name) $tool_name; do
|
||||
|
||||
failed=true
|
||||
for i in {1..10}; do
|
||||
brew --cache $dep >/dev/null && failed=false || sleep 60
|
||||
[ "$failed" = false ] && break
|
||||
done
|
||||
|
||||
if [ "$failed" = true ]; then
|
||||
echo "Failed: brew --cache $dep"
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
|
||||
failed=true
|
||||
for i in {1..10}; do
|
||||
brew install $tool_name && failed=false || sleep 60
|
||||
[ "$failed" = false ] && break
|
||||
done
|
||||
|
||||
if [ "$failed" = true ]; then
|
||||
echo "Failed: brew install $tool_name"
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
configure_system_tccdb () {
|
||||
local values=$1
|
||||
|
||||
local dbPath="/Library/Application Support/com.apple.TCC/TCC.db"
|
||||
local sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
|
||||
sudo sqlite3 "$dbPath" "$sqlQuery"
|
||||
}
|
||||
|
||||
configure_user_tccdb () {
|
||||
local values=$1
|
||||
|
||||
local dbPath="$HOME/Library/Application Support/com.apple.TCC/TCC.db"
|
||||
local sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
|
||||
sqlite3 "$dbPath" "$sqlQuery"
|
||||
}
|
||||
|
||||
get_github_package_download_url() {
|
||||
local REPO_ORG=$1
|
||||
local FILTER=$2
|
||||
local VERSION=$3
|
||||
local API_PAT=$4
|
||||
local SEARCH_IN_COUNT="100"
|
||||
|
||||
[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
|
||||
|
||||
failed=true
|
||||
for i in {1..10}; do
|
||||
curl "${authString[@]}" -fsSL "https://api.github.com/repos/${REPO_ORG}/releases?per_page=${SEARCH_IN_COUNT}" >/tmp/get_github_package_download_url.json && failed=false || sleep 60
|
||||
[ "$failed" = false ] && break
|
||||
done
|
||||
|
||||
if [ "$failed" = true ]; then
|
||||
echo "Failed: get_github_package_download_url"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
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)
|
||||
else
|
||||
tagName=$(echo $json | jq -r '.[] | select(.prerelease==false).tag_name' | sort --unique --version-sort | egrep -v ".*-[a-z]" | egrep "\w*${VERSION}" | tail -1)
|
||||
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"
|
||||
exit 1
|
||||
fi
|
||||
echo $downloadUrl
|
||||
}
|
||||
|
||||
# Close all finder windows because they can interfere with UI tests
|
||||
close_finder_window() {
|
||||
osascript -e 'tell application "Finder" to close windows'
|
||||
}
|
||||
|
||||
get_arch() {
|
||||
arch=$(arch)
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
echo "arm64"
|
||||
else
|
||||
echo "x64"
|
||||
fi
|
||||
}
|
||||
239
images/macos/scripts/helpers/xamarin-utils.sh
Normal file
239
images/macos/scripts/helpers/xamarin-utils.sh
Normal file
@@ -0,0 +1,239 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
# Xamarin can clean their SDKs while updating to newer versions,
|
||||
# so we should be able to detect it during image generation
|
||||
downloadAndInstallPKG() {
|
||||
local PKG_URL=$1
|
||||
local PKG_NAME=${PKG_URL##*/}
|
||||
|
||||
download_with_retries $PKG_URL
|
||||
|
||||
echo "Installing $PKG_NAME..."
|
||||
sudo installer -pkg "$TMPMOUNT/$PKG_NAME" -target /
|
||||
}
|
||||
|
||||
buildVSMacDownloadUrl() {
|
||||
echo "https://dl.xamarin.com/VsMac/VisualStudioForMac-${1}.dmg"
|
||||
}
|
||||
|
||||
buildMonoDownloadUrl() {
|
||||
echo "https://dl.xamarin.com/MonoFrameworkMDK/Macx86/MonoFramework-MDK-${1}.macos10.xamarin.universal.pkg"
|
||||
}
|
||||
|
||||
buildXamariniIOSDownloadUrl() {
|
||||
echo "https://dl.xamarin.com/MonoTouch/Mac/xamarin.ios-${1}.pkg"
|
||||
}
|
||||
|
||||
buildXamarinMacDownloadUrl() {
|
||||
echo "https://dl.xamarin.com/XamarinforMac/Mac/xamarin.mac-${1}.pkg"
|
||||
}
|
||||
|
||||
buildXamarinAndroidDownloadUrl() {
|
||||
echo "https://dl.xamarin.com/MonoforAndroid/Mac/xamarin.android-${1}.pkg"
|
||||
}
|
||||
|
||||
installMono() {
|
||||
local VERSION=$1
|
||||
|
||||
echo "Installing Mono ${VERSION}..."
|
||||
local MONO_FOLDER_NAME=$(echo $VERSION | cut -d. -f 1,2,3)
|
||||
local SHORT_VERSION=$(echo $VERSION | cut -d. -f 1,2)
|
||||
local PKG_URL=$(buildMonoDownloadUrl $VERSION)
|
||||
downloadAndInstallPKG $PKG_URL
|
||||
|
||||
echo "Installing nunit3-console for Mono "$VERSION
|
||||
installNunitConsole $MONO_FOLDER_NAME
|
||||
|
||||
echo "Creating short symlink '${SHORT_VERSION}'"
|
||||
sudo ln -s ${MONO_VERSIONS_PATH}/${MONO_FOLDER_NAME} ${MONO_VERSIONS_PATH}/${SHORT_VERSION}
|
||||
|
||||
echo "Move to backup folder"
|
||||
sudo mv -v $MONO_VERSIONS_PATH/* $TMPMOUNT_FRAMEWORKS/mono/
|
||||
}
|
||||
|
||||
installXamarinIOS() {
|
||||
local VERSION=$1
|
||||
|
||||
echo "Installing Xamarin.iOS ${VERSION}..."
|
||||
local SHORT_VERSION=$(echo $VERSION | cut -d. -f 1,2)
|
||||
local PKG_URL=$(buildXamariniIOSDownloadUrl $VERSION)
|
||||
downloadAndInstallPKG $PKG_URL
|
||||
|
||||
echo "Creating short symlink '${SHORT_VERSION}'"
|
||||
sudo ln -s ${IOS_VERSIONS_PATH}/${VERSION} ${IOS_VERSIONS_PATH}/${SHORT_VERSION}
|
||||
|
||||
echo "Move to backup folder"
|
||||
sudo mv -v $IOS_VERSIONS_PATH/* $TMPMOUNT_FRAMEWORKS/ios/
|
||||
}
|
||||
|
||||
installXamarinMac() {
|
||||
local VERSION=$1
|
||||
|
||||
echo "Installing Xamarin.Mac ${VERSION}..."
|
||||
local SHORT_VERSION=$(echo $VERSION | cut -d. -f 1,2)
|
||||
local PKG_URL=$(buildXamarinMacDownloadUrl $VERSION)
|
||||
downloadAndInstallPKG $PKG_URL
|
||||
|
||||
echo "Creating short symlink '${SHORT_VERSION}'"
|
||||
sudo ln -s ${MAC_VERSIONS_PATH}/${VERSION} ${MAC_VERSIONS_PATH}/${SHORT_VERSION}
|
||||
|
||||
echo "Move to backup folder"
|
||||
sudo mv -v $MAC_VERSIONS_PATH/* $TMPMOUNT_FRAMEWORKS/mac/
|
||||
}
|
||||
|
||||
installXamarinAndroid() {
|
||||
local VERSION=$1
|
||||
|
||||
echo "Installing Xamarin.Android ${VERSION}..."
|
||||
local SHORT_VERSION=$(echo $VERSION | cut -d. -f 1,2)
|
||||
local PKG_URL=$(buildXamarinAndroidDownloadUrl $VERSION)
|
||||
downloadAndInstallPKG $PKG_URL
|
||||
|
||||
if [ "$VERSION" == "9.4.1.0" ]; then
|
||||
# Fix symlinks for broken Xamarin.Android
|
||||
fixXamarinAndroidSymlinksInLibDir $VERSION
|
||||
fi
|
||||
|
||||
echo "Creating short symlink '${SHORT_VERSION}'"
|
||||
sudo ln -s ${ANDROID_VERSIONS_PATH}/${VERSION} ${ANDROID_VERSIONS_PATH}/${SHORT_VERSION}
|
||||
|
||||
echo "Move to backup folder"
|
||||
sudo mv -v $ANDROID_VERSIONS_PATH/* $TMPMOUNT_FRAMEWORKS/android/
|
||||
}
|
||||
|
||||
createBundle() {
|
||||
local SYMLINK=$1
|
||||
local MONO_SDK=$2
|
||||
local IOS_SDK=$3
|
||||
local MAC_SDK=$4
|
||||
local ANDROID_SDK=$5
|
||||
|
||||
echo "Creating bundle '$SYMLINK' (Mono $MONO_SDK; iOS $IOS_SDK; Mac $MAC_SDK; Android $ANDROID_SDK"
|
||||
deleteSymlink ${SYMLINK}
|
||||
sudo ln -s ${MONO_VERSIONS_PATH}/${MONO_SDK} ${MONO_VERSIONS_PATH}/${SYMLINK}
|
||||
sudo ln -s ${IOS_VERSIONS_PATH}/${IOS_SDK} ${IOS_VERSIONS_PATH}/${SYMLINK}
|
||||
sudo ln -s ${MAC_VERSIONS_PATH}/${MAC_SDK} ${MAC_VERSIONS_PATH}/${SYMLINK}
|
||||
sudo ln -s ${ANDROID_VERSIONS_PATH}/${ANDROID_SDK} ${ANDROID_VERSIONS_PATH}/${SYMLINK}
|
||||
}
|
||||
|
||||
createBundleLink() {
|
||||
local SOURCE=$1
|
||||
local TARGET=$2
|
||||
echo "Creating bundle symlink '$SOURCE' -> '$TARGET'"
|
||||
deleteSymlink ${TARGET}
|
||||
sudo ln -s ${MONO_VERSIONS_PATH}/$SOURCE ${MONO_VERSIONS_PATH}/$TARGET
|
||||
sudo ln -s ${IOS_VERSIONS_PATH}/$SOURCE ${IOS_VERSIONS_PATH}/$TARGET
|
||||
sudo ln -s ${MAC_VERSIONS_PATH}/$SOURCE ${MAC_VERSIONS_PATH}/$TARGET
|
||||
sudo ln -s ${ANDROID_VERSIONS_PATH}/$SOURCE ${ANDROID_VERSIONS_PATH}/$TARGET
|
||||
}
|
||||
|
||||
# https://github.com/xamarin/xamarin-android/issues/3457
|
||||
# Recreate missing symlinks in lib for new Xamarin.Android package
|
||||
# Symlink path /Library/Frameworks/Xamarin.Android.framework/Libraries
|
||||
# xbuild -> xamarin.android/xbuild
|
||||
# xbuild-frameworks -> xamarin.android/xbuild-frameworks
|
||||
fixXamarinAndroidSymlinksInLibDir() {
|
||||
local XAMARIN_ANDROID_VERSION=$1
|
||||
local XAMARIN_ANDROID_LIB_PATH="${ANDROID_VERSIONS_PATH}/${XAMARIN_ANDROID_VERSION}/lib"
|
||||
|
||||
if [ -d "${XAMARIN_ANDROID_LIB_PATH}" ]; then
|
||||
pushd "${XAMARIN_ANDROID_LIB_PATH}" > /dev/null
|
||||
|
||||
local XAMARIN_ANDROID_XBUILD_DIR="${XAMARIN_ANDROID_LIB_PATH}/xbuild"
|
||||
if [ ! -d "${XAMARIN_ANDROID_XBUILD_DIR}" ]; then
|
||||
echo "${XAMARIN_ANDROID_XBUILD_DIR}"
|
||||
sudo ln -sf xamarin.android/xbuild xbuild
|
||||
fi
|
||||
|
||||
local XAMARIN_ANDROID_XBUILD_FRAMEWORKS_DIR="${XAMARIN_ANDROID_LIB_PATH}/xbuild-frameworks"
|
||||
if [ ! -d "${XAMARIN_ANDROID_XBUILD_FRAMEWORKS_DIR}" ]; then
|
||||
echo "${XAMARIN_ANDROID_XBUILD_FRAMEWORKS_DIR}"
|
||||
sudo ln -sf xamarin.android/xbuild-frameworks xbuild-frameworks
|
||||
fi
|
||||
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
installNunitConsole() {
|
||||
local MONO_VERSION=$1
|
||||
|
||||
cat <<EOF > ${TMPMOUNT}/${NUNIT3_CONSOLE_BIN}
|
||||
#!/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 ${TMPMOUNT}/${NUNIT3_CONSOLE_BIN}
|
||||
sudo mv ${TMPMOUNT}/${NUNIT3_CONSOLE_BIN} ${MONO_VERSIONS_PATH}/${MONO_VERSION}/Commands/${NUNIT3_CONSOLE_BIN}
|
||||
}
|
||||
|
||||
downloadNUnitConsole() {
|
||||
echo "Downloading NUnit 3..."
|
||||
local NUNIT3_LOCATION='https://github.com/nunit/nunit-console/releases/download/3.6.1/NUnit.Console-3.6.1.zip'
|
||||
local NUNIT_PATH="/Library/Developer/nunit"
|
||||
NUNIT3_PATH="$NUNIT_PATH/3.6.1"
|
||||
|
||||
pushd $TMPMOUNT
|
||||
|
||||
sudo mkdir -p $NUNIT3_PATH
|
||||
download_with_retries $NUNIT3_LOCATION "." "nunit3.zip"
|
||||
|
||||
echo "Installing NUnit 3..."
|
||||
sudo unzip nunit3.zip -d $NUNIT3_PATH
|
||||
NUNIT3_CONSOLE_BIN=nunit3-console
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
installNuget() {
|
||||
local MONO_VERSION=$1
|
||||
local NUGET_VERSION=$2
|
||||
local NUGET_URL="https://dist.nuget.org/win-x86-commandline/v${NUGET_VERSION}/nuget.exe"
|
||||
echo "Installing nuget $NUGET_VERSION for Mono $MONO_VERSION"
|
||||
cd ${MONO_VERSIONS_PATH}/${MONO_VERSION}/lib/mono/nuget
|
||||
sudo mv nuget.exe nuget_old.exe
|
||||
|
||||
pushd $TMPMOUNT
|
||||
download_with_retries $NUGET_URL "." "nuget.exe"
|
||||
sudo chmod a+x nuget.exe
|
||||
sudo mv nuget.exe ${MONO_VERSIONS_PATH}/${MONO_VERSION}/lib/mono/nuget
|
||||
popd
|
||||
}
|
||||
|
||||
createUWPShim() {
|
||||
echo "Creating UWP Shim to hack UWP build failure..."
|
||||
cat <<EOF > ${TMPMOUNT}/Microsoft.Windows.UI.Xaml.CSharp.Targets
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name = "Build"/>
|
||||
<Target Name = "Rebuild"/>
|
||||
</Project>
|
||||
EOF
|
||||
|
||||
local UWPTARGET_PATH=/Library/Frameworks/Mono.framework/External/xbuild/Microsoft/WindowsXaml
|
||||
|
||||
sudo mkdir -p $UWPTARGET_PATH/v11.0/
|
||||
sudo cp ${TMPMOUNT}/Microsoft.Windows.UI.Xaml.CSharp.Targets $UWPTARGET_PATH/v11.0/
|
||||
sudo mkdir -p $UWPTARGET_PATH/v12.0/
|
||||
sudo cp ${TMPMOUNT}/Microsoft.Windows.UI.Xaml.CSharp.Targets $UWPTARGET_PATH/v12.0/
|
||||
sudo mkdir -p $UWPTARGET_PATH/v14.0/
|
||||
sudo cp ${TMPMOUNT}/Microsoft.Windows.UI.Xaml.CSharp.Targets $UWPTARGET_PATH/v14.0/
|
||||
sudo mkdir -p $UWPTARGET_PATH/v15.0/
|
||||
sudo cp ${TMPMOUNT}/Microsoft.Windows.UI.Xaml.CSharp.Targets $UWPTARGET_PATH/v15.0/
|
||||
sudo mkdir -p $UWPTARGET_PATH/v16.0/
|
||||
sudo cp ${TMPMOUNT}/Microsoft.Windows.UI.Xaml.CSharp.Targets $UWPTARGET_PATH/v16.0/
|
||||
}
|
||||
|
||||
createBackupFolders() {
|
||||
mkdir -p $TMPMOUNT_FRAMEWORKS/mono
|
||||
mkdir -p $TMPMOUNT_FRAMEWORKS/ios
|
||||
mkdir -p $TMPMOUNT_FRAMEWORKS/mac
|
||||
mkdir -p $TMPMOUNT_FRAMEWORKS/android
|
||||
}
|
||||
|
||||
deleteSymlink() {
|
||||
sudo rm -f ${MONO_VERSIONS_PATH}/${1}
|
||||
sudo rm -f ${IOS_VERSIONS_PATH}/${1}
|
||||
sudo rm -f ${MAC_VERSIONS_PATH}/${1}
|
||||
sudo rm -f ${ANDROID_VERSIONS_PATH}/${1}
|
||||
}
|
||||
15
images/macos/scripts/tests/ActionArchiveCache.Tests.ps1
Normal file
15
images/macos/scripts/tests/ActionArchiveCache.Tests.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
Describe "ActionArchiveCache" {
|
||||
Context "Action archive cache directory not empty" {
|
||||
It "$HOME/actionarchivecache not empty" {
|
||||
(Get-ChildItem -Path "$env:HOME/actionarchivecache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
|
||||
Context "Action tarball not empty" {
|
||||
$testCases = Get-ChildItem -Path "$env:HOME/actionarchivecache/*.tar.gz" -Recurse | ForEach-Object { @{ ActionTarball = $_.FullName } }
|
||||
It "<ActionTarball>" -TestCases $testCases {
|
||||
param ([string] $ActionTarball)
|
||||
(Get-Item "$ActionTarball").Length | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
}
|
||||
82
images/macos/scripts/tests/Android.Tests.ps1
Normal file
82
images/macos/scripts/tests/Android.Tests.ps1
Normal file
@@ -0,0 +1,82 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
|
||||
Import-Module "$PSScriptRoot/../software-report/SoftwareReport.Android.psm1" -DisableNameChecking
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "Android" {
|
||||
$androidSdkManagerPackages = Get-AndroidPackages
|
||||
[int]$platformMinVersion = Get-ToolsetValue "android.platform_min_version"
|
||||
[version]$buildToolsMinVersion = Get-ToolsetValue "android.build_tools_min_version"
|
||||
[array]$ndkVersions = Get-ToolsetValue "android.ndk.versions"
|
||||
$ndkFullVersions = $ndkVersions | ForEach-Object { Get-ChildItem "$env:ANDROID_HOME/ndk/${_}.*" -Name | Select-Object -Last 1 } | ForEach-Object { "ndk/${_}" }
|
||||
# Platforms starting with a letter are the preview versions, which is not installed on the image
|
||||
$platformVersionsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("platforms;") }) -replace 'platforms;android-', '' | Where-Object { $_ -match "^\d" } | Sort-Object -Unique
|
||||
$platformsInstalled = $platformVersionsList | Where-Object { [int]($_.Split("-")[0]) -ge $platformMinVersion } | ForEach-Object { "platforms/android-${_}" }
|
||||
|
||||
$buildToolsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("build-tools;") }) -replace 'build-tools;', ''
|
||||
$buildTools = $buildToolsList | Where-Object { $_ -match "\d+(\.\d+){2,}$" } | Where-Object { [version]$_ -ge $buildToolsMinVersion } | Sort-Object -Unique |
|
||||
ForEach-Object { "build-tools/${_}" }
|
||||
|
||||
$androidPackages = @(
|
||||
"tools",
|
||||
"platform-tools",
|
||||
"cmake",
|
||||
$platformsInstalled,
|
||||
$buildTools,
|
||||
$ndkFullVersions,
|
||||
(Get-ToolsetValue "android.extra-list" | ForEach-Object { "extras/${_}" }),
|
||||
(Get-ToolsetValue "android.addon-list" | ForEach-Object { "add-ons/${_}" }),
|
||||
(Get-ToolsetValue "android.additional-tools")
|
||||
) | ForEach-Object { $_ }
|
||||
|
||||
# Remove empty strings from array to avoid possible issues
|
||||
$androidPackages = $androidPackages | Where-Object { $_ }
|
||||
|
||||
BeforeAll {
|
||||
$ANDROID_SDK_DIR = Join-Path $env:HOME "Library" "Android" "sdk"
|
||||
|
||||
function Validate-AndroidPackage {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$PackageName
|
||||
)
|
||||
|
||||
# Convert 'm2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta1' ->
|
||||
# 'm2repository/com/android/support/constraint/constraint-layout-solver/1.0.0-beta1'
|
||||
$PackageName = $PackageName.Replace(";", "/")
|
||||
$targetPath = Join-Path $ANDROID_SDK_DIR $PackageName
|
||||
$targetPath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "SDKManagers" {
|
||||
$testCases = @(
|
||||
@{
|
||||
PackageName = "Command-line tools"
|
||||
Sdkmanager = "$env:ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
|
||||
}
|
||||
)
|
||||
if ($os.IsBigSur -or $os.IsMonterey) {
|
||||
$testCases += @(
|
||||
@{
|
||||
PackageName = "SDK tools"
|
||||
Sdkmanager = "$env:ANDROID_HOME/tools/bin/sdkmanager"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
It "Sdkmanager from <PackageName> is available" -TestCases $testCases {
|
||||
"$Sdkmanager --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Context "Packages" {
|
||||
$testCases = $androidPackages | ForEach-Object { @{ PackageName = $_ } }
|
||||
|
||||
It "<PackageName>" -TestCases $testCases {
|
||||
param ([string] $PackageName)
|
||||
Validate-AndroidPackage $PackageName
|
||||
}
|
||||
}
|
||||
}
|
||||
197
images/macos/scripts/tests/BasicTools.Tests.ps1
Normal file
197
images/macos/scripts/tests/BasicTools.Tests.ps1
Normal file
@@ -0,0 +1,197 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "Azure CLI" {
|
||||
It "Azure CLI" {
|
||||
"az -v" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Azure DevOps CLI" {
|
||||
It "az devops" {
|
||||
"az devops -h" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Carthage" {
|
||||
It "Carthage" {
|
||||
"carthage version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "cmake" {
|
||||
It "cmake" {
|
||||
"cmake --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Subversion" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "Subversion" {
|
||||
"svn --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "SwiftFormat" {
|
||||
It "SwiftFormat" {
|
||||
"swiftformat --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "GnuPG" {
|
||||
It "GnuPG" {
|
||||
"gpg --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "zstd" {
|
||||
It "zstd" {
|
||||
"zstd --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Packer" {
|
||||
It "Packer" {
|
||||
"packer --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Perl" {
|
||||
It "Perl" {
|
||||
"perl -e 'print substr($^V,1)'" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Helm" -Skip:($os.IsMonterey -or $os.IsVentura -or $os.IsSonoma) {
|
||||
It "Helm" {
|
||||
"helm version --short" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Github CLI" {
|
||||
It "GitHub CLI" {
|
||||
"gh --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "7-Zip" {
|
||||
It "7-Zip" {
|
||||
"7z i" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Apache Ant" {
|
||||
It "Apache Ant" {
|
||||
"ant -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Aria2" {
|
||||
It "Aria2" {
|
||||
"aria2c --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "GNU Tar" {
|
||||
It "GNU Tar" {
|
||||
"gtar --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "bazel" {
|
||||
It "bazel" {
|
||||
"bazel --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Aliyun CLI" -Skip:($os.IsMonterey -or $os.IsVentura -or $os.IsSonoma) {
|
||||
It "Aliyun CLI" {
|
||||
"aliyun --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Julia" {
|
||||
It "Julia" {
|
||||
"julia --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "jq" {
|
||||
It "jq" {
|
||||
"jq --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "curl" {
|
||||
It "curl" {
|
||||
"curl --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "wget" {
|
||||
It "wget" {
|
||||
"wget --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "vagrant" -Skip:($os.IsBigSur -or $os.IsVentura -or $os.IsSonoma) {
|
||||
It "vagrant" {
|
||||
"vagrant --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "virtualbox" -Skip:($os.IsBigSur -or $os.IsVentura -or $os.IsSonoma) {
|
||||
It "virtualbox" {
|
||||
"vboxmanage -v" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "R" {
|
||||
It "R" {
|
||||
"R --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Homebrew" {
|
||||
It "Homebrew" {
|
||||
"brew --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Kotlin" {
|
||||
$kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlinc-jvm", "kotlin-dce-js")
|
||||
|
||||
It "<toolName> is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) {
|
||||
"$toolName -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "sbt" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "sbt" {
|
||||
"sbt -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "yq" {
|
||||
It "yq" {
|
||||
"yq --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "imagemagick" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "imagemagick" {
|
||||
"magick -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
75
images/macos/scripts/tests/Browsers.Tests.ps1
Normal file
75
images/macos/scripts/tests/Browsers.Tests.ps1
Normal file
@@ -0,0 +1,75 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "Chrome" {
|
||||
BeforeAll {
|
||||
$chromeLocation = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
||||
$chromeForTestingLocation = "/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
|
||||
}
|
||||
|
||||
It "Chrome" {
|
||||
$chromeLocation | Should -Exist
|
||||
"'$chromeLocation' --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Chrome for Testing" {
|
||||
$chromeForTestingLocation | Should -Exist
|
||||
"'$chromeForTestingLocation' --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Chrome Driver" {
|
||||
"chromedriver --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Chrome for Testing and Chrome Driver major versions are the same" {
|
||||
$chromeMajor = (& $chromeForTestingLocation --version).Trim("Google Chrome for Testing ").Split(".")[0]
|
||||
$chromeDriverMajor = (chromedriver --version).Trim("ChromeDriver ").Split(".")[0]
|
||||
$chromeMajor | Should -BeExactly $chromeDriverMajor
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Selenium server" {
|
||||
It "Selenium server" {
|
||||
$os = Get-OSVersion
|
||||
if ($os.IsArm64) {
|
||||
$cellarPath = "/opt/homebrew/Cellar"
|
||||
} else {
|
||||
$cellarPath = "/usr/local/Cellar"
|
||||
}
|
||||
(Get-ChildItem -Path "$cellarPath/selenium-server*/*").Name | Should -BeLike "4.*"
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Edge" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
|
||||
It "Microsoft Edge" {
|
||||
$edgeLocation = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
|
||||
$edgeLocation | Should -Exist
|
||||
"'$edgeLocation' --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Microsoft Edge Driver" {
|
||||
"msedgedriver --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Firefox" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
|
||||
It "Firefox" {
|
||||
$firefoxLocation = "/Applications/Firefox.app/Contents/MacOS/firefox"
|
||||
$firefoxLocation | Should -Exist
|
||||
"'$firefoxLocation' --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
It "Geckodriver" {
|
||||
"geckodriver --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Safari" {
|
||||
It "'Allow Remote Automation' option is activated" {
|
||||
$plistPath = "$env:HOME/Library/WebDriver/com.apple.Safari.plist"
|
||||
$command = "/usr/libexec/PlistBuddy -c 'print AllowRemoteAutomation' $plistPath"
|
||||
$plistPath | Should -Exist
|
||||
$commandResult = Get-CommandResult $command
|
||||
$commandResult.ExitCode | Should -Be 0
|
||||
$commandResult.Output | Should -Be "true"
|
||||
}
|
||||
}
|
||||
148
images/macos/scripts/tests/Common.Tests.ps1
Normal file
148
images/macos/scripts/tests/Common.Tests.ps1
Normal file
@@ -0,0 +1,148 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe ".NET" {
|
||||
It ".NET" {
|
||||
"dotnet --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "GCC" {
|
||||
$testCases = Get-ToolsetValue -KeyPath gcc.versions | ForEach-Object { @{Version = $_ } }
|
||||
|
||||
It "GCC <Version>" -TestCases $testCases {
|
||||
param (
|
||||
[string] $Version
|
||||
)
|
||||
|
||||
"gcc-$Version --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Gfortran <Version>" -TestCases $testCases {
|
||||
param (
|
||||
[string] $Version
|
||||
)
|
||||
|
||||
"gfortran-$Version --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Gfortran is not found in the default path" {
|
||||
"$(which gfortran)" | Should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Describe "vcpkg" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
|
||||
It "vcpkg" {
|
||||
"vcpkg version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "AWS" {
|
||||
It "AWS CLI" {
|
||||
"aws --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
It "AWS SAM CLI" {
|
||||
"sam --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "AWS Session Manager CLI" {
|
||||
"session-manager-plugin --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "AzCopy" {
|
||||
It "AzCopy" {
|
||||
"azcopy --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Miniconda" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "Conda" {
|
||||
Get-EnvironmentVariable "CONDA" | Should -Not -BeNullOrEmpty
|
||||
$condaBinPath = Join-Path $env:CONDA "bin" "conda"
|
||||
"$condaBinPath --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Stack" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "Stack" {
|
||||
"stack --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "CocoaPods" {
|
||||
It "CocoaPods" {
|
||||
"pod --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "VSMac" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
|
||||
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
|
||||
|
||||
$testCases = $vsMacVersions | ForEach-Object {
|
||||
$vsPath = "/Applications/Visual Studio $_.app"
|
||||
if ($_ -eq $defaultVSMacVersion) {
|
||||
$vsPath = "/Applications/Visual Studio.app"
|
||||
}
|
||||
|
||||
@{ vsversion = $_ ; vspath = $vsPath }
|
||||
}
|
||||
|
||||
It "Visual Studio <vsversion> for Mac is installed" -TestCases $testCases {
|
||||
$vstoolPath = Join-Path $vsPath "Contents/MacOS/vstool"
|
||||
$vsPath | Should -Exist
|
||||
$vstoolPath | Should -Exist
|
||||
}
|
||||
|
||||
It "Visual Studio $defaultVSMacVersion for Mac is default" {
|
||||
$vsPath = "/Applications/Visual Studio.app"
|
||||
$vstoolPath = Join-Path $vsPath "Contents/MacOS/vstool"
|
||||
$vsPath | Should -Exist
|
||||
$vstoolPath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Swig" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "Swig" {
|
||||
"swig -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Bicep" {
|
||||
It "Bicep" {
|
||||
"bicep --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Go" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "Go" {
|
||||
"go version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "VirtualBox" -Skip:($os.IsBigSur -or $os.IsVentura -or $os.IsSonoma) {
|
||||
It "Check kext kernel modules" {
|
||||
kextstat | Out-String | Should -Match "org.virtualbox.kext"
|
||||
}
|
||||
}
|
||||
|
||||
Describe "CodeQL Bundle" {
|
||||
It "Is installed" {
|
||||
$CodeQLVersionWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
|
||||
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionWildcard | Select-Object -First 1 -Expand FullName
|
||||
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql"
|
||||
"$CodeQLPath version --quiet" | Should -ReturnZeroExitCode
|
||||
|
||||
$CodeQLPacksPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "qlpacks"
|
||||
$CodeQLPacksPath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Colima" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "Colima" {
|
||||
"colima version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
23
images/macos/scripts/tests/Databases.Tests.ps1
Normal file
23
images/macos/scripts/tests/Databases.Tests.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "MongoDB" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "<ToolName>" -TestCases @(
|
||||
@{ ToolName = "mongo" }
|
||||
@{ ToolName = "mongod" }
|
||||
) {
|
||||
$toolsetVersion = Get-ToolsetValue 'mongodb.version'
|
||||
(&$ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*"
|
||||
}
|
||||
}
|
||||
|
||||
Describe "PostgreSQL" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
It "PostgreSQL version should correspond to the version in the toolset" {
|
||||
$toolsetVersion = Get-ToolsetValue 'postgresql.version'
|
||||
# Client version
|
||||
(psql --version).split()[-2] | Should -BeLike "$toolsetVersion*"
|
||||
# Server version
|
||||
(pg_config --version).split()[-2] | Should -BeLike "$toolsetVersion*"
|
||||
}
|
||||
}
|
||||
10
images/macos/scripts/tests/Git.Tests.ps1
Normal file
10
images/macos/scripts/tests/Git.Tests.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
$os = Get-OSVersion
|
||||
Describe "Git" {
|
||||
It "git is installed" {
|
||||
"git --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
It "git lfs is installed" {
|
||||
"git lfs version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
29
images/macos/scripts/tests/Haskell.Tests.ps1
Normal file
29
images/macos/scripts/tests/Haskell.Tests.ps1
Normal file
@@ -0,0 +1,29 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "Haskell" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
Context "GHCup" {
|
||||
It "GHCup" {
|
||||
"ghcup --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
Context "GHC" {
|
||||
It "GHC" {
|
||||
"ghc --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
Context "Cabal" {
|
||||
It "Cabal" {
|
||||
"cabal --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
Context "Stack" {
|
||||
It "Stack" {
|
||||
"stack --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Stack hook is not installed" {
|
||||
"$HOME/.stack/hooks/ghc-install.sh" | Should -Not -Exist
|
||||
}
|
||||
}
|
||||
}
|
||||
83
images/macos/scripts/tests/Java.Tests.ps1
Normal file
83
images/macos/scripts/tests/Java.Tests.ps1
Normal file
@@ -0,0 +1,83 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
|
||||
|
||||
$os = Get-OSVersion
|
||||
$arch = Get-Architecture
|
||||
|
||||
function Get-NativeVersionFormat {
|
||||
param($Version)
|
||||
if ($Version -in "8") {
|
||||
return "1.${Version}"
|
||||
}
|
||||
return $Version
|
||||
}
|
||||
|
||||
Describe "Java" {
|
||||
BeforeAll {
|
||||
function Validate-JavaVersion {
|
||||
param($JavaCommand, $ExpectedVersion)
|
||||
|
||||
$commandResult = Get-CommandResult $JavaCommand
|
||||
$commandResult.ExitCode | Should -Be 0
|
||||
$matchResult = $commandResult.Output | Select-String '^openjdk version \"([\d\._]+)\"'
|
||||
$matchResult.Matches.Success | Should -BeTrue
|
||||
$version = $matchResult.Matches.Groups[1].Value
|
||||
$version | Should -BeLike "${ExpectedVersion}*"
|
||||
}
|
||||
}
|
||||
|
||||
$toolsetJava = Get-ToolsetValue "java"
|
||||
$defaultVersion = $toolsetJava.$arch.default
|
||||
$jdkVersions = $toolsetJava.$arch.versions
|
||||
|
||||
if ($os.IsArm64) {
|
||||
$testCases = $jdkVersions | ForEach-Object { @{ Title = $_; Version = (Get-NativeVersionFormat $_); EnvVariable = "JAVA_HOME_${_}_arm64" } }
|
||||
} else {
|
||||
$testCases = $jdkVersions | ForEach-Object { @{ Title = $_; Version = (Get-NativeVersionFormat $_); EnvVariable = "JAVA_HOME_${_}_X64" } }
|
||||
}
|
||||
$testCases += @{ Title = "Default"; Version = (Get-NativeVersionFormat $defaultVersion); EnvVariable = "JAVA_HOME" }
|
||||
|
||||
$testCases | ForEach-Object {
|
||||
Context $_.Title {
|
||||
It "Version is found by 'java_home'" -TestCases $_ {
|
||||
"/usr/libexec/java_home -v${Version}" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Java <Version>" -TestCases $_ {
|
||||
$envVariablePath = Get-EnvironmentVariable $EnvVariable
|
||||
$javaBinPath = Join-Path $envVariablePath "/bin/java"
|
||||
Validate-JavaVersion -JavaCommand "$javaBinPath -version" -ExpectedVersion $Version
|
||||
}
|
||||
|
||||
if ($_.Title -eq "Default") {
|
||||
It "Version is default" -TestCases $_ {
|
||||
Validate-JavaVersion -JavaCommand "java -version" -ExpectedVersion $Version
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "Maven" {
|
||||
Describe "Maven" {
|
||||
It "Maven" {
|
||||
"mvn --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "Gradle" {
|
||||
Describe "Gradle" {
|
||||
It "Gradle is installed" {
|
||||
"gradle --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Gradle is installed to /usr/local/bin" -Skip:($os.IsArm64) {
|
||||
(Get-Command "gradle").Path | Should -BeExactly "/usr/local/bin/gradle"
|
||||
}
|
||||
|
||||
It "Gradle is installed to /opt/homebrew/bin/gradle" -Skip:(-not $os.IsArm64) {
|
||||
(Get-Command "gradle").Path | Should -BeExactly "/opt/homebrew/bin/gradle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
images/macos/scripts/tests/LLVM.Tests.ps1
Normal file
10
images/macos/scripts/tests/LLVM.Tests.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
Describe "Clang/LLVM" {
|
||||
BeforeAll {
|
||||
$toolsetVersion = Get-ToolsetValue 'llvm.version'
|
||||
}
|
||||
|
||||
It "Clang/LLVM <toolsetVersion> is installed and version is correct" {
|
||||
$clangVersion = & "$(brew --prefix llvm@$toolsetVersion)/bin/clang" --version
|
||||
$clangVersion[0] | Should -BeLike "*${toolsetVersion}*"
|
||||
}
|
||||
}
|
||||
9
images/macos/scripts/tests/Linters.Tests.ps1
Normal file
9
images/macos/scripts/tests/Linters.Tests.ps1
Normal file
@@ -0,0 +1,9 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "SwiftLint" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
|
||||
It "SwiftLint" {
|
||||
"swiftlint version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
56
images/macos/scripts/tests/Node.Tests.ps1
Normal file
56
images/macos/scripts/tests/Node.Tests.ps1
Normal file
@@ -0,0 +1,56 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
|
||||
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "Node.js" {
|
||||
It "Node.js is installed" {
|
||||
"node --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Node.js version should correspond to the version in the toolset" {
|
||||
node --version | Should -BeLike "v$(Get-ToolsetValue 'node.default')*"
|
||||
}
|
||||
|
||||
It "NPM is installed" {
|
||||
"npm --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Yarn is installed" {
|
||||
"yarn --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "nvm" -Skip:($os.IsVentura -or $os.IsSonoma) {
|
||||
BeforeAll {
|
||||
$nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh"
|
||||
$nvmInitCommand = ". $nvmPath > /dev/null 2>&1 || true"
|
||||
}
|
||||
|
||||
It "nvm is installed" {
|
||||
$nvmPath | Should -Exist
|
||||
"$nvmInitCommand && nvm --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
Context "nvm versions" {
|
||||
[array]$nvmVersions = Get-ToolsetValue 'node.nvm_versions'
|
||||
$testCases = $nvmVersions | ForEach-Object { @{NvmVersion = $_} }
|
||||
|
||||
It "<NvmVersion>" -TestCases $testCases {
|
||||
param (
|
||||
[string] $NvmVersion
|
||||
)
|
||||
|
||||
"$nvmInitCommand && nvm ls $($NvmVersion)" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Global NPM Packages" {
|
||||
$globalNpmPackages = Get-ToolsetValue "npm.global_packages"
|
||||
$globalNpmPackagesWithTests = $globalNpmPackages | Where-Object { $_.test } | ForEach-Object { @{ Name = $_.name; Test = $_.test } }
|
||||
|
||||
It "<Name>" -TestCases $globalNpmPackagesWithTests {
|
||||
$Test | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
23
images/macos/scripts/tests/OpenSSL.Tests.ps1
Normal file
23
images/macos/scripts/tests/OpenSSL.Tests.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
|
||||
Describe "OpenSSL" {
|
||||
Context "OpenSSL Version" {
|
||||
It "OpenSSL is available" {
|
||||
"openssl version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Context "OpenSSL 1.1 Path Check" {
|
||||
It "OpenSSL 1.1 path exists" {
|
||||
$openSSLpath = brew --prefix openssl@1.1
|
||||
$openSSLpath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "OpenSSL 1.1 is default" {
|
||||
It "Default OpenSSL version is 1.1" {
|
||||
$commandResult = Get-CommandResult "openssl version"
|
||||
$commandResult.Output | Should -Match "OpenSSL 1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
21
images/macos/scripts/tests/PHP.Tests.ps1
Normal file
21
images/macos/scripts/tests/PHP.Tests.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
||||
$os = Get-OSVersion
|
||||
|
||||
Describe "PHP" {
|
||||
Context "PHP" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
|
||||
It "PHP Path" {
|
||||
Get-WhichTool "php" | Should -Not -BeLike "/usr/bin/php*"
|
||||
}
|
||||
It "PHP version" {
|
||||
$phpVersionToolset = Get-ToolsetValue 'php.version'
|
||||
$phpInstalledVersion = php --version | Out-String | Select-String "${phpVersionToolset}"
|
||||
$phpInstalledVersion | Should -BeLike "PHP ${phpVersionToolset}*"
|
||||
}
|
||||
}
|
||||
|
||||
Context "Composer" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
|
||||
It "Composer" {
|
||||
"composer --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user