2020-10-23 17:59:08 +03:00
#!/bin/bash -e -o pipefail
2023-11-28 02:25:03 +01:00
################################################################################
## File: install-common-utils.sh
## Desc: Install utils listed in toolset file
################################################################################
2020-09-10 14:34:08 +03:00
source ~/utils/utils.sh
2020-09-21 09:46:17 +03:00
2021-09-24 13:56:16 +03:00
# Monterey needs future review:
2021-11-11 11:23:05 +03:00
# 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.
2020-12-23 22:14:13 +07:00
common_packages = $( get_toolset_value '.brew.common_packages[]' )
for package in $common_packages ; do
echo " Installing $package ... "
2024-03-13 14:27:57 +01:00
if is_Monterey && [ [ $package = = "xcbeautify" ] ] ; then
# Pin the version on Monterey as 2.0.x requires Xcode >=15.0 which is not available on OS12
xcbeautify_path = $( download_with_retry "https://raw.githubusercontent.com/Homebrew/homebrew-core/d3653e83f9c029a3fddb828ac804b07ac32f7b3b/Formula/x/xcbeautify.rb" )
brew install " $xcbeautify_path "
else
brew_smart_install " $package "
fi
2020-09-10 14:34:08 +03:00
done
2020-12-23 22:14:13 +07:00
cask_packages = $( get_toolset_value '.brew.cask_packages[]' )
for package in $cask_packages ; do
echo " Installing $package ... "
2023-11-09 11:29:07 +01:00
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.
2023-11-30 13:39:32 +01:00
virtualbox_cask_path = $( download_with_retry "https://raw.githubusercontent.com/Homebrew/homebrew-cask/aa3c55951fc9d687acce43e5c0338f42c1ddff7b/Casks/virtualbox.rb" )
2024-01-09 14:47:31 +01:00
brew install $virtualbox_cask_path
2023-11-06 11:53:10 +01:00
else
2024-01-09 14:47:31 +01:00
brew install --cask $package
2023-11-06 11:53:10 +01:00
fi
2020-09-10 14:34:08 +03:00
done
2022-09-28 19:06:08 +02:00
# 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
2022-05-24 23:48:57 +04:00
# System Preferences -> Security & Privacy -> General -> Unlock -> Allow -> Not now
if is_Monterey; then
2024-08-09 11:25:15 +02:00
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
2023-03-02 11:21:19 +01:00
2024-08-09 11:25:15 +02:00
if [ [ $retry -eq 0 ] ] ; then
echo "Executing AppleScript failed. No retries left"
exit 1
fi
2023-10-27 09:32:43 +02:00
2024-08-09 11:25:15 +02:00
echo "Executing AppleScript failed. Sleeping for 10 seconds and retrying"
sleep 10
done
2022-05-24 23:48:57 +04:00
fi
2022-09-28 19:06:08 +02:00
# Validate "Parallels International GmbH" kext
if is_Monterey; then
2022-09-29 21:58:02 +02:00
echo "Closing System Preferences window if it is still opened"
killall "System Preferences" || true
echo "Checking parallels kexts"
2022-09-28 19:06:08 +02:00
dbName = "/var/db/SystemPolicyConfiguration/KextPolicy"
dbQuery = "SELECT * FROM kext_policy WHERE bundle_id LIKE 'com.parallels.kext.%';"
kext = $( sudo sqlite3 $dbName " $dbQuery " )
2024-01-09 14:47:31 +01:00
if [ [ -z $kext ] ] ; then
2022-09-28 19:06:08 +02:00
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' )
2024-01-09 14:47:31 +01:00
if [ [ -z $url ] ] ; then
2022-09-28 19:06:08 +02:00
echo "Unable to parse url for Parallels Desktop cask"
exit 1
fi
2024-01-09 14:47:31 +01:00
echo " export PARALLELS_DMG_URL= $url " >> ${ HOME } /.bashrc
2022-09-28 19:06:08 +02:00
fi
2024-08-09 11:25:15 +02:00
# Install Azure DevOps extension for Azure Command Line Interface
az extension add -n azure-devops
2022-02-11 12:53:36 +03:00
2021-01-29 16:37:48 +07:00
# Invoke tests for all basic tools
invoke_tests "BasicTools"