Skip to content

Commit

Permalink
Refactor updating dependencies on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Apr 9, 2022
1 parent 0e506b3 commit ffd019e
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/scripts/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ link_libraries() {
formula_prefix="$(brew --prefix "$formula")"
sudo mkdir -p "$formula_prefix"/lib
for lib in "$formula_prefix"/lib/*.dylib; do
[ -f "$lib" ] || break
lib_name=$(basename "$lib")
sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true
done
Expand All @@ -256,18 +255,25 @@ patch_brew() {
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
update_dependencies() {
if [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
patch_brew
while read -r formula; do
(
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 "$formula"
) &
to_wait+=( $! )
done < "$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
wait "${to_wait[@]}"
if ! [ -e /tmp/update_dependencies ]; then
if [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
patch_brew
while read -r dependency; do
update_dependencies_helper "$dependency" &
to_wait+=($!)
done <"$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
wait "${to_wait[@]}"
fi
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
fi
}

Expand Down

0 comments on commit ffd019e

Please sign in to comment.