mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Fix dependencies on pre-installed PHP on macOS
This commit is contained in:
parent
1f97ce0215
commit
3beda962f3
@ -71,6 +71,7 @@ add_brew_extension() {
|
|||||||
add_brew_tap shivammathur/homebrew-php
|
add_brew_tap shivammathur/homebrew-php
|
||||||
add_brew_tap shivammathur/homebrew-extensions
|
add_brew_tap shivammathur/homebrew-extensions
|
||||||
sudo mv "$tap_dir"/shivammathur/homebrew-extensions/.github/deps/"$formula"/* "$tap_dir/homebrew/homebrew-core/Formula/" 2>/dev/null || true
|
sudo mv "$tap_dir"/shivammathur/homebrew-extensions/.github/deps/"$formula"/* "$tap_dir/homebrew/homebrew-core/Formula/" 2>/dev/null || true
|
||||||
|
update_dependencies >/dev/null 2>&1
|
||||||
brew install -f "$formula@$version" >/dev/null 2>&1
|
brew install -f "$formula@$version" >/dev/null 2>&1
|
||||||
sudo cp "$brew_prefix/opt/$formula@$version/$extension.so" "$ext_dir"
|
sudo cp "$brew_prefix/opt/$formula@$version/$extension.so" "$ext_dir"
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
@ -118,19 +119,31 @@ link_libraries() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_dependencies_helper() {
|
update_dependencies_helper() {
|
||||||
formula=$1
|
dependency=$1
|
||||||
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/$dependency.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$dependency.rb"
|
||||||
link_libraries "$formula"
|
link_libraries "$dependency"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to update dependencies.
|
# Function to update dependencies.
|
||||||
update_dependencies() {
|
update_dependencies() {
|
||||||
if [ "${runner:?}" != "self-hosted" ] && [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
|
if ! [ -e /tmp/update_dependencies ] && [ "${runner:?}" != "self-hosted" ] && [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
|
||||||
while read -r formula; do
|
while read -r dependency; do
|
||||||
update_dependencies_helper "$formula" &
|
update_dependencies_helper "$dependency" &
|
||||||
to_wait+=($!)
|
to_wait+=($!)
|
||||||
done <"$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
done <"$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
||||||
wait "${to_wait[@]}"
|
wait "${to_wait[@]}"
|
||||||
|
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to fix dependencies on install php version
|
||||||
|
fix_dependencies() {
|
||||||
|
broken_deps_paths=$(php -v 2>&1 | grep -Eo '/opt/[a-zA-Z0-9@\.]+')
|
||||||
|
if [ "x$broken_deps_paths" != "x" ]; then
|
||||||
|
update_dependencies
|
||||||
|
IFS=" " read -r -a formulae <<< "$(echo "$broken_deps_paths" | tr '\n' ' ' | sed 's|/opt/||g' 2>&1)$php_formula"
|
||||||
|
brew reinstall "${formulae[@]}"
|
||||||
|
brew link --force --overwrite "$php_formula" || true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +161,6 @@ get_brewed_php() {
|
|||||||
add_php() {
|
add_php() {
|
||||||
action=$1
|
action=$1
|
||||||
existing_version=$2
|
existing_version=$2
|
||||||
php_formula=shivammathur/php/php@"$version"
|
|
||||||
add_brew_tap shivammathur/homebrew-php
|
add_brew_tap shivammathur/homebrew-php
|
||||||
update_dependencies
|
update_dependencies
|
||||||
if [ "$existing_version" != "false" ]; then
|
if [ "$existing_version" != "false" ]; then
|
||||||
@ -174,6 +186,7 @@ setup_php() {
|
|||||||
status="Updated to"
|
status="Updated to"
|
||||||
else
|
else
|
||||||
status="Found"
|
status="Found"
|
||||||
|
fix_dependencies >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
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:?}"
|
||||||
@ -193,6 +206,7 @@ setup_php() {
|
|||||||
# Variables
|
# Variables
|
||||||
version=$1
|
version=$1
|
||||||
dist=$2
|
dist=$2
|
||||||
|
php_formula=shivammathur/php/php@"$version"
|
||||||
brew_prefix="$(brew --prefix)"
|
brew_prefix="$(brew --prefix)"
|
||||||
brew_repo="$(brew --repository)"
|
brew_repo="$(brew --repository)"
|
||||||
tap_dir="$brew_repo"/Library/Taps
|
tap_dir="$brew_repo"/Library/Taps
|
||||||
|
Loading…
Reference in New Issue
Block a user