Force overwrite updated dependencies on macOS

This commit is contained in:
Shivam Mathur 2021-05-27 20:12:50 +05:30
parent 3beda962f3
commit e3396c6572
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -113,11 +113,17 @@ link_libraries() {
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
lib_name=$(basename "$lib") lib_name=$(basename "$lib")
sudo cp -a "$lib" "$brew_prefix/lib/old_$lib_name" 2>/dev/null || true sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true
sudo ln -sf "$brew_prefix"/lib/old_"$lib_name" "$brew_prefix/lib/$lib_name"
done done
} }
# Patch brew to overwrite packages
patch_brew() {
sudo sed -i '' "s/ keg.link(verbose: verbose?)/ keg.link(verbose: verbose?, overwrite: true)/" "$brew_repo"/Library/Homebrew/formula_installer.rb
# shellcheck disable=SC2064
trap "git -C $brew_repo stash >/dev/null 2>&1" exit
}
update_dependencies_helper() { update_dependencies_helper() {
dependency=$1 dependency=$1
get -q -n "$tap_dir/homebrew/homebrew-core/Formula/$dependency.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$dependency.rb" get -q -n "$tap_dir/homebrew/homebrew-core/Formula/$dependency.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$dependency.rb"
@ -127,6 +133,7 @@ update_dependencies_helper() {
# Function to update dependencies. # Function to update dependencies.
update_dependencies() { update_dependencies() {
if ! [ -e /tmp/update_dependencies ] && [ "${runner:?}" != "self-hosted" ] && [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then if ! [ -e /tmp/update_dependencies ] && [ "${runner:?}" != "self-hosted" ] && [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
patch_brew
while read -r dependency; do while read -r dependency; do
update_dependencies_helper "$dependency" & update_dependencies_helper "$dependency" &
to_wait+=($!) to_wait+=($!)