mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Refactor updating dependencies on macOS
This commit is contained in:
parent
0e506b34ac
commit
ffd019edc6
@ -242,7 +242,6 @@ link_libraries() {
|
|||||||
formula_prefix="$(brew --prefix "$formula")"
|
formula_prefix="$(brew --prefix "$formula")"
|
||||||
sudo mkdir -p "$formula_prefix"/lib
|
sudo mkdir -p "$formula_prefix"/lib
|
||||||
for lib in "$formula_prefix"/lib/*.dylib; do
|
for lib in "$formula_prefix"/lib/*.dylib; do
|
||||||
[ -f "$lib" ] || break
|
|
||||||
lib_name=$(basename "$lib")
|
lib_name=$(basename "$lib")
|
||||||
sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true
|
sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true
|
||||||
done
|
done
|
||||||
@ -256,19 +255,26 @@ patch_brew() {
|
|||||||
trap "sudo sed -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit
|
trap "sudo sed -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Helper function to update the dependencies.
|
||||||
|
update_dependencies_helper() {
|
||||||
|
dependency=$1
|
||||||
|
curl -o "$tap_dir/homebrew/homebrew-core/Formula/$formula.rb" "${curl_opts[@]}" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb"
|
||||||
|
link_libraries "$dependency"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to update dependencies
|
# Function to update dependencies
|
||||||
update_dependencies() {
|
update_dependencies() {
|
||||||
|
if ! [ -e /tmp/update_dependencies ]; then
|
||||||
if [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
|
if [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
|
||||||
patch_brew
|
patch_brew
|
||||||
while read -r formula; do
|
while read -r dependency; do
|
||||||
(
|
update_dependencies_helper "$dependency" &
|
||||||
curl -o "$tap_dir/homebrew/homebrew-core/Formula/$formula.rb" "${curl_opts[@]}" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb"
|
to_wait+=($!)
|
||||||
link_libraries "$formula"
|
done <"$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
||||||
) &
|
|
||||||
to_wait+=( $! )
|
|
||||||
done < "$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
|
||||||
wait "${to_wait[@]}"
|
wait "${to_wait[@]}"
|
||||||
fi
|
fi
|
||||||
|
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to get PHP version if it is already installed using Homebrew.
|
# Function to get PHP version if it is already installed using Homebrew.
|
||||||
|
Loading…
Reference in New Issue
Block a user