mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Improve brew support on Linux
This commit is contained in:
parent
edff21f0a6
commit
71b0e09dbc
@ -1,12 +1,3 @@
|
||||
# Function to setup environment for self-hosted runners.
|
||||
self_hosted_helper() {
|
||||
if ! command -v brew >/dev/null; then
|
||||
step_log "Setup Brew"
|
||||
get -q -e "/tmp/install.sh" "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" && /tmp/install.sh >/dev/null 2>&1
|
||||
add_log "${tick:?}" "Brew" "Installed Homebrew"
|
||||
fi
|
||||
}
|
||||
|
||||
# Disable dependency extensions
|
||||
disable_dependency_extensions() {
|
||||
local extension=$1
|
||||
|
@ -1,26 +1,3 @@
|
||||
# Function to configure brew constants.
|
||||
configure_brew() {
|
||||
brew_path="$(command -v brew)"
|
||||
brew_path_dir="$(dirname "$brew_path")"
|
||||
brew_prefix="$brew_path_dir"/..
|
||||
brew_repo="$brew_path_dir/$(dirname "$(readlink "$brew_path")")"/..
|
||||
tap_dir="$brew_repo"/Library/Taps
|
||||
core_repo="$tap_dir"/homebrew/homebrew-core
|
||||
|
||||
export HOMEBREW_CHANGE_ARCH_TO_ARM=1
|
||||
export HOMEBREW_DEVELOPER=1
|
||||
export HOMEBREW_NO_AUTO_UPDATE=1
|
||||
export HOMEBREW_NO_ENV_HINTS=1
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
||||
export brew_path
|
||||
export brew_path_dir
|
||||
export brew_prefix
|
||||
export brew_repo
|
||||
export tap_dir
|
||||
export core_repo
|
||||
}
|
||||
|
||||
# Function to fetch a brew tap.
|
||||
fetch_brew_tap() {
|
||||
tap=$1
|
||||
@ -47,9 +24,44 @@ add_brew_tap() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to get brew prefix.
|
||||
get_brew_prefix() {
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
echo /home/linuxbrew/.linuxbrew
|
||||
else
|
||||
if [ "$(uname -m)" = "arm64" ]; then
|
||||
echo /opt/homebrew
|
||||
else
|
||||
echo /usr/local
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to add brew's bin directories to the PATH.
|
||||
add_brew_bins_to_path() {
|
||||
local brew_prefix=${1:-$(get_brew_prefix)}
|
||||
add_path "$brew_prefix"/bin
|
||||
add_path "$brew_prefix"/sbin
|
||||
}
|
||||
|
||||
# Function to add brew.
|
||||
add_brew() {
|
||||
brew_prefix="$(get_brew_prefix)"
|
||||
if ! [ -d "$brew_prefix"/bin ]; then
|
||||
step_log "Setup Brew"
|
||||
get -s "" "/tmp/install.sh" "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" | bash -s >/dev/null 2>&1
|
||||
add_log "${tick:?}" "Brew" "Installed Homebrew"
|
||||
fi
|
||||
add_brew_bins_to_path "$brew_prefix"
|
||||
}
|
||||
|
||||
# Function to configure brew constants.
|
||||
configure_brew() {
|
||||
brew_path="$(command -v brew)"
|
||||
if [ -z "$brew_path" ]; then
|
||||
add_brew
|
||||
brew_path="$(command -v brew)"
|
||||
fi
|
||||
brew_path_dir="$(dirname "$brew_path")"
|
||||
brew_prefix="$brew_path_dir"/..
|
||||
brew_repo="$brew_path_dir/$(dirname "$(readlink "$brew_path")")"/..
|
||||
|
Loading…
Reference in New Issue
Block a user