mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-26 13:23:05 +07:00
Improve darwin.sh
This commit is contained in:
parent
41797e3af9
commit
62c7ba2bee
@ -2,7 +2,6 @@
|
|||||||
export tick="✓"
|
export tick="✓"
|
||||||
export cross="✗"
|
export cross="✗"
|
||||||
export curl_opts=(-sL)
|
export curl_opts=(-sL)
|
||||||
export nightly_versions="8.[0-1]"
|
|
||||||
export old_versions="5.[3-5]"
|
export old_versions="5.[3-5]"
|
||||||
export tool_path_dir="/usr/local/bin"
|
export tool_path_dir="/usr/local/bin"
|
||||||
export composer_bin="$HOME/.composer/vendor/bin"
|
export composer_bin="$HOME/.composer/vendor/bin"
|
||||||
|
@ -39,6 +39,14 @@ add_pecl_extension() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to add a brew tap.
|
||||||
|
add_brew_tap() {
|
||||||
|
tap=$1
|
||||||
|
if ! [ -d "$tap_dir/$tap" ]; then
|
||||||
|
brew tap --shallow "$tap" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to install a php extension from shivammathur/extensions tap.
|
# Function to install a php extension from shivammathur/extensions tap.
|
||||||
add_brew_extension() {
|
add_brew_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
@ -47,13 +55,10 @@ add_brew_extension() {
|
|||||||
if check_extension "$extension"; then
|
if check_extension "$extension"; then
|
||||||
add_log "${tick:?}" "$extension" "Enabled"
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
else
|
else
|
||||||
if ! brew tap | grep -q shivammathur/extensions; then
|
add_brew_tap shivammathur/homebrew-extensions
|
||||||
brew tap --shallow shivammathur/extensions >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
tap_dir="$(brew --prefix)/Homebrew/Library/Taps"
|
|
||||||
sudo mv "$tap_dir"/shivammathur/homebrew-extensions/.github/deps/"$extension"/* "$tap_dir/homebrew/homebrew-core/Formula/" 2>/dev/null || true
|
sudo mv "$tap_dir"/shivammathur/homebrew-extensions/.github/deps/"$extension"/* "$tap_dir/homebrew/homebrew-core/Formula/" 2>/dev/null || true
|
||||||
brew install "$extension@$version" >/dev/null 2>&1
|
brew install "$extension@$version" >/dev/null 2>&1
|
||||||
sudo cp "$(brew --prefix)/opt/$extension@$version/$extension.so" "$ext_dir"
|
sudo cp "$brew_prefix/opt/$extension@$version/$extension.so" "$ext_dir"
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -88,7 +93,6 @@ add_pecl() {
|
|||||||
# Function to update dependencies.
|
# Function to update dependencies.
|
||||||
update_dependencies() {
|
update_dependencies() {
|
||||||
if [[ "$version" =~ ${nightly_versions:?} ]] && [ "${runner:?}" != "self-hosted" ]; then
|
if [[ "$version" =~ ${nightly_versions:?} ]] && [ "${runner:?}" != "self-hosted" ]; then
|
||||||
tap_dir="$(brew --prefix)/Homebrew/Library/Taps"
|
|
||||||
while read -r formula; do
|
while read -r formula; do
|
||||||
get -q -n "$tap_dir/homebrew/homebrew-core/Formula/$formula.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb" &
|
get -q -n "$tap_dir/homebrew/homebrew-core/Formula/$formula.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb" &
|
||||||
to_wait+=($!)
|
to_wait+=($!)
|
||||||
@ -100,16 +104,14 @@ update_dependencies() {
|
|||||||
# Function to setup PHP 5.6 and newer using Homebrew.
|
# Function to setup PHP 5.6 and newer using Homebrew.
|
||||||
add_php() {
|
add_php() {
|
||||||
action=$1
|
action=$1
|
||||||
if ! brew tap | grep -q shivammathur/php; then
|
add_brew_tap shivammathur/homebrew-php
|
||||||
brew tap --shallow shivammathur/php
|
|
||||||
fi
|
|
||||||
update_dependencies
|
update_dependencies
|
||||||
if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then
|
if ! [[ "$(find "$(brew --cellar)"/php/ -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]] && [ "$action" != "upgrade" ]; then
|
||||||
brew unlink php@"$version"
|
brew unlink shivammathur/php/php@"$version"
|
||||||
else
|
else
|
||||||
brew "$action" shivammathur/php/php@"$version"
|
brew upgrade "shivammathur/php/php@$version" 2>/dev/null || brew install "shivammathur/php/php@$version"
|
||||||
fi
|
fi
|
||||||
brew link --force --overwrite php@"$version"
|
brew link --force --overwrite shivammathur/php/php@"$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to Setup PHP
|
# Function to Setup PHP
|
||||||
@ -131,6 +133,7 @@ setup_php() {
|
|||||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
sudo chmod 777 "$ini_file" "${tool_path_dir:?}"
|
sudo chmod 777 "$ini_file" "${tool_path_dir:?}"
|
||||||
echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
|
echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
|
||||||
|
[[ "$version" =~ ${jit_versions:?} ]] && echo -e "opcache.enable=1\nopcache.jit_buffer_size=256M\nopcache.jit=1235" >>"$ini_file"
|
||||||
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
||||||
@ -143,6 +146,10 @@ setup_php() {
|
|||||||
# Variables
|
# Variables
|
||||||
version=$1
|
version=$1
|
||||||
dist=$2
|
dist=$2
|
||||||
|
nightly_versions="8.1"
|
||||||
|
jit_versions="8.[0-1]"
|
||||||
|
brew_prefix="$(brew --prefix)"
|
||||||
|
tap_dir="$brew_prefix"/Homebrew/Library/Taps
|
||||||
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||||
export HOMEBREW_NO_AUTO_UPDATE=1
|
export HOMEBREW_NO_AUTO_UPDATE=1
|
||||||
|
|
||||||
|
@ -274,6 +274,7 @@ setup_php() {
|
|||||||
# Variables
|
# Variables
|
||||||
version=$1
|
version=$1
|
||||||
dist=$2
|
dist=$2
|
||||||
|
nightly_versions="8.[0-1]"
|
||||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
apt_install="sudo $debconf_fix apt-fast install -y"
|
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||||
apt_remove="sudo $debconf_fix apt-fast remove -y"
|
apt_remove="sudo $debconf_fix apt-fast remove -y"
|
||||||
|
Loading…
Reference in New Issue
Block a user