mirror of
https://github.com/actions/runner-images.git
synced 2026-01-09 03:57:44 +08:00
[macOS] Separate xcode command line tools installation & Xcode 12.1 for Big Sur (#1815)
* add retry logic, remove separate macOS11 installation * move to separate file
This commit is contained in:
@@ -1,23 +1,19 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
echo "Installing Homebrew..."
|
||||
|
||||
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})"
|
||||
|
||||
echo Disabling Homebrew analytics...
|
||||
echo "Disabling Homebrew analytics..."
|
||||
brew analytics off
|
||||
|
||||
echo Installing the last version of curl
|
||||
echo "Installing the latest curl..."
|
||||
brew install curl
|
||||
|
||||
echo Installing wget...
|
||||
echo "Installing wget..."
|
||||
brew install wget
|
||||
|
||||
echo Installing jq
|
||||
echo "Installing jq..."
|
||||
brew install jq
|
||||
|
||||
# init brew bundle feature
|
||||
|
||||
43
images/macos/provision/core/xcode-clt.sh
Normal file
43
images/macos/provision/core/xcode-clt.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
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
|
||||
clt_label_command="/usr/sbin/softwareupdate -l |
|
||||
grep -B 1 -E 'Command Line Tools' |
|
||||
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
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Homebrew doesn't support installation of command line tools on MacOS 11.0
|
||||
# https://github.com/Homebrew/install/blob/master/install.sh#L191
|
||||
# Copy-paste script from brew installation process
|
||||
# https://github.com/Homebrew/install/blob/master/install.sh#L530
|
||||
# This temporary file prompts the 'softwareupdate' utility to list the Command Line Tools
|
||||
|
||||
clt_placeholder="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"
|
||||
touch $clt_placeholder
|
||||
clt_label=`/usr/sbin/softwareupdate -l |
|
||||
grep -B 1 -E 'Command Line Tools beta 5' |
|
||||
awk -F'*' '/^ *\\*/ {print \$2}' |
|
||||
sed -e 's/^ *Label: //' -e 's/^ *//' |
|
||||
sort -V |
|
||||
tail -n1`
|
||||
/usr/sbin/softwareupdate -i "$clt_label"
|
||||
rm -f $clt_placeholder
|
||||
sudo xcode-select --switch "/Library/Developer/CommandLineTools/"
|
||||
@@ -128,6 +128,7 @@
|
||||
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
|
||||
"pause_before": "30s",
|
||||
"scripts": [
|
||||
"./provision/core/xcode-clt.sh",
|
||||
"./provision/core/homebrew.sh",
|
||||
"./provision/core/dotnet.sh",
|
||||
"./provision/core/python.sh",
|
||||
|
||||
@@ -128,6 +128,7 @@
|
||||
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
|
||||
"pause_before": "30s",
|
||||
"scripts": [
|
||||
"./provision/core/xcode-clt.sh",
|
||||
"./provision/core/homebrew.sh",
|
||||
"./provision/core/dotnet.sh",
|
||||
"./provision/core/python.sh",
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
|
||||
"pause_before": "30s",
|
||||
"scripts": [
|
||||
"./provision/core/xcode-clt.sh",
|
||||
"./provision/core/homebrew.sh",
|
||||
"./provision/core/dotnet.sh",
|
||||
"./provision/core/python.sh",
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
|
||||
"pause_before": "30s",
|
||||
"scripts": [
|
||||
"./provision/core/xcode-ctl.sh",
|
||||
"./provision/core/xcode-clt.sh",
|
||||
"./provision/core/homebrew.sh",
|
||||
"./provision/core/dotnet.sh",
|
||||
"./provision/core/python.sh",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"xcode": {
|
||||
"default": "11.7",
|
||||
"versions": [
|
||||
"12.2_beta", "11.7"
|
||||
"12.2_beta", "12.1_GM_seed", "11.7"
|
||||
]
|
||||
},
|
||||
"xamarin": {
|
||||
|
||||
Reference in New Issue
Block a user