mirror of
https://github.com/actions/runner-images.git
synced 2025-12-16 06:40:32 +00:00
[macOS] Fix the issue with brew install (#2354)
* Update azure-cli installation * Update curl installation * Update git-lfs installation * Add utils * Update gnupg installation * Add brew_install function * Revert jq installation * Add condition for the aws-sam-cli * Add return to function, revert aws-sam-cli changes, rename brew_install function * Fix typo Co-authored-by: MaksimZhukov <v-mazhuk@microsoft.com>
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/invoke-tests.sh
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "install soundflower"
|
||||
brew install --cask soundflower
|
||||
|
||||
echo "install switchaudio-osx"
|
||||
brew install switchaudio-osx
|
||||
brew_smart_install "switchaudio-osx"
|
||||
|
||||
echo "install sox"
|
||||
brew install sox
|
||||
brew_smart_install "sox"
|
||||
|
||||
echo "set Soundflower (2ch) as input/output device"
|
||||
SwitchAudioSource -s "Soundflower (2ch)" -t input
|
||||
|
||||
@@ -9,7 +9,7 @@ echo "Installing Chrome Driver"
|
||||
brew install --cask chromedriver
|
||||
|
||||
echo "Installing Selenium"
|
||||
brew install selenium-server-standalone
|
||||
brew_smart_install "selenium-server-standalone"
|
||||
|
||||
CHROMEWEBDRIVER_DIR=$(readlink $(which chromedriver) | xargs dirname)
|
||||
echo "export CHROMEWEBDRIVER=$CHROMEWEBDRIVER_DIR" >> "${HOME}/.bashrc"
|
||||
|
||||
@@ -5,7 +5,7 @@ source ~/utils/invoke-tests.sh
|
||||
common_packages=$(get_toolset_value '.brew.common_packages[]')
|
||||
for package in $common_packages; do
|
||||
echo "Installing $package..."
|
||||
brew install $package
|
||||
brew_smart_install "$package"
|
||||
done
|
||||
|
||||
cask_packages=$(get_toolset_value '.brew.cask_packages[]')
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/invoke-tests.sh
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "Installing Firefox..."
|
||||
brew install --cask firefox
|
||||
|
||||
echo "Installing Geckodriver..."
|
||||
brew install geckodriver
|
||||
brew_smart_install "geckodriver"
|
||||
|
||||
echo "Add GECKOWEBDRIVER to bashrc..."
|
||||
echo "export GECKOWEBDRIVER=$(brew --prefix geckodriver)/bin" >> "${HOME}/.bashrc"
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
source ~/utils/invoke-tests.sh
|
||||
|
||||
echo "Installing GCC@8 using homebrew..."
|
||||
brew install gcc@8
|
||||
brew_smart_install "gcc@8"
|
||||
|
||||
echo "Installing GCC@9 using homebrew..."
|
||||
brew install gcc@9
|
||||
brew_smart_install "gcc@9"
|
||||
|
||||
# https://github.com/actions/virtual-environments/issues/1280
|
||||
echo "Installing GCC@10 using homebrew..."
|
||||
brew install gcc@10
|
||||
brew_smart_install "gcc@10"
|
||||
rm $(which gfortran)
|
||||
|
||||
invoke_tests "Common" "GCC"
|
||||
@@ -1,18 +1,21 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/invoke-tests.sh
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing Git...
|
||||
brew install git
|
||||
brew_smart_install "git"
|
||||
|
||||
echo Installing Git LFS
|
||||
brew install git-lfs
|
||||
brew_smart_install "git-lfs"
|
||||
|
||||
# Update global git config
|
||||
git lfs install
|
||||
# Update system git config
|
||||
sudo git lfs install --system
|
||||
|
||||
echo Installing Hub
|
||||
brew install hub
|
||||
brew_smart_install "hub"
|
||||
|
||||
echo Disable all the Git help messages...
|
||||
git config --global advice.pushUpdateRejected false
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo "Installing Homebrew..."
|
||||
HOMEBREW_INSTALL_URL="https://raw.githubusercontent.com/Homebrew/install/master/install.sh"
|
||||
/bin/bash -c "$(curl -fsSL ${HOMEBREW_INSTALL_URL})"
|
||||
@@ -12,10 +14,10 @@ echo "Installing jq..."
|
||||
brew install jq
|
||||
|
||||
echo "Installing curl..."
|
||||
brew install curl
|
||||
brew_smart_install "curl"
|
||||
|
||||
echo "Installing wget..."
|
||||
brew install wget
|
||||
brew_smart_install "wget"
|
||||
|
||||
# init brew bundle feature
|
||||
brew tap Homebrew/bundle
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
source ~/utils/invoke-tests.sh
|
||||
|
||||
# MongoDB object-value database
|
||||
@@ -8,6 +9,6 @@ source ~/utils/invoke-tests.sh
|
||||
echo "Installing mongodb..."
|
||||
|
||||
brew tap mongodb/brew
|
||||
brew install mongodb-community
|
||||
brew_smart_install "mongodb-community"
|
||||
|
||||
invoke_tests "Common" "Mongo"
|
||||
@@ -27,7 +27,7 @@ if is_Less_Catalina; then
|
||||
npm install -g appcenter-cli@^1.0.0
|
||||
else
|
||||
# Install Node.JS 12 for macOS >= 10.15
|
||||
brew install node@14
|
||||
brew_smart_install "node@14"
|
||||
brew link node@14 --force
|
||||
|
||||
for module in ${node_modules[@]}; do
|
||||
|
||||
@@ -46,9 +46,9 @@ done
|
||||
createEnvironmentVariable "JAVA_HOME" $JAVA_DEFAULT
|
||||
|
||||
echo Installing Maven...
|
||||
brew install maven
|
||||
brew_smart_install "maven"
|
||||
|
||||
echo Installing Gradle ...
|
||||
brew install gradle
|
||||
brew_smart_install "gradle"
|
||||
|
||||
invoke_tests "Java"
|
||||
@@ -3,10 +3,10 @@ source ~/utils/utils.sh
|
||||
source ~/utils/invoke-tests.sh
|
||||
|
||||
echo "Install latest openssl"
|
||||
brew install openssl
|
||||
brew_smart_install "openssl"
|
||||
|
||||
echo "Install openssl@1.1"
|
||||
brew install openssl@1.1
|
||||
brew_smart_install "openssl@1.1"
|
||||
|
||||
# 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
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing PHP
|
||||
brew install php
|
||||
brew_smart_install "php"
|
||||
|
||||
echo Installing composer
|
||||
brew install composer
|
||||
brew_smart_install "composer"
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
#Install latest version of postgresql
|
||||
brew install postgres
|
||||
brew_smart_install "postgres"
|
||||
|
||||
#Service postgresql should be started before use.
|
||||
brew services start postgresql
|
||||
|
||||
@@ -4,7 +4,7 @@ source ~/utils/utils.sh
|
||||
source ~/utils/invoke-tests.sh
|
||||
|
||||
echo Installing Azure CLI...
|
||||
brew install azure-cli
|
||||
brew_smart_install "azure-cli"
|
||||
|
||||
echo Installing PowerShell...
|
||||
brew install --cask powershell
|
||||
|
||||
@@ -16,13 +16,13 @@ bash -c "/Applications/Python\ 2.7/Install\ Certificates.command"
|
||||
# Explicitly overwrite symlinks created by Python2 such as /usr/local/bin/2to3 since they conflict with symlinks from Python3
|
||||
# https://github.com/actions/virtual-environments/issues/2322
|
||||
echo "Brew Installing Python 3"
|
||||
brew install python@3.9 || brew link --overwrite python@3.9
|
||||
brew_smart_install "python@3.9" || brew link --overwrite python@3.9
|
||||
|
||||
echo "Installing pipx"
|
||||
export PIPX_BIN_DIR=/usr/local/opt/pipx_bin
|
||||
export PIPX_HOME=/usr/local/opt/pipx
|
||||
|
||||
brew install pipx
|
||||
brew_smart_install "pipx"
|
||||
|
||||
echo "export PIPX_BIN_DIR=${PIPX_BIN_DIR}" >> "${HOME}/.bashrc"
|
||||
echo "export PIPX_HOME=${PIPX_HOME}" >> "${HOME}/.bashrc"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing Ruby...
|
||||
brew install ruby
|
||||
brew_smart_install "ruby"
|
||||
|
||||
#if High Sierra - skip installation from toolset
|
||||
if is_HighSierra; then
|
||||
|
||||
@@ -14,7 +14,7 @@ gem install cocoapods
|
||||
if is_Less_BigSur; then
|
||||
# fix nomad-cli installation
|
||||
if is_HighSierra; then
|
||||
brew install libxml2
|
||||
brew_smart_install "libxml2"
|
||||
gem install nokogiri -v 1.6.8.1 -- --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
source ~/utils/utils.sh
|
||||
|
||||
echo Installing Rustup...
|
||||
brew install rustup-init
|
||||
brew_smart_install "rustup-init"
|
||||
|
||||
echo Installing Rust language...
|
||||
rustup-init -y --no-modify-path --default-toolchain=stable --profile=minimal
|
||||
|
||||
@@ -109,3 +109,62 @@ brew_cask_install_ignoring_sha256() {
|
||||
git checkout HEAD -- "$TOOL_NAME.rb"
|
||||
popd
|
||||
}
|
||||
|
||||
get_brew_os_keyword() {
|
||||
if is_HighSierra; then
|
||||
echo "high_sierra"
|
||||
elif is_Mojave; then
|
||||
echo "mojave"
|
||||
elif is_Catalina; then
|
||||
echo "catalina"
|
||||
elif is_BigSur; then
|
||||
echo "big_sur"
|
||||
else
|
||||
echo "null"
|
||||
fi
|
||||
}
|
||||
|
||||
should_build_from_source() {
|
||||
local tool_name=$1
|
||||
local os_name=$2
|
||||
local tool_info=$(brew info --json=v1 $tool_name)
|
||||
local bottle_disabled=$(echo "$tool_info" | jq ".[0].bottle_disabled")
|
||||
|
||||
# No need to build from source if a bottle is disabled
|
||||
# Use the simple 'brew install' command to download a package
|
||||
if $bottle_disabled; then
|
||||
echo "false"
|
||||
return
|
||||
fi
|
||||
|
||||
local tool_bottle=$(echo "$tool_info" | jq ".[0].bottle.stable.files.$os_name")
|
||||
if [[ "$tool_bottle" == "null" ]]; then
|
||||
echo "true"
|
||||
return
|
||||
else
|
||||
echo "false"
|
||||
return
|
||||
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
|
||||
|
||||
local os_name=$(get_brew_os_keyword)
|
||||
if [[ "$os_name" == "null" ]]; then
|
||||
echo "$OSTYPE is unknown operating system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local build_from_source=$(should_build_from_source "$tool_name" "$os_name")
|
||||
if $build_from_source; then
|
||||
echo "Bottle of the $tool_name for the $os_name was not found. Building $tool_name from source..."
|
||||
brew install --build-from-source $tool_name
|
||||
else
|
||||
echo "Downloading $tool_name..."
|
||||
brew install $tool_name
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user