From e3396c6572cdacc8adcbb4cddd9e650c2c39a19a Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 27 May 2021 20:12:50 +0530 Subject: [PATCH] Force overwrite updated dependencies on macOS --- src/scripts/darwin.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 689ee17c..c827a8d8 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -113,11 +113,17 @@ link_libraries() { sudo mkdir -p "$formula_prefix"/lib for lib in "$formula_prefix"/lib/*.dylib; do lib_name=$(basename "$lib") - sudo cp -a "$lib" "$brew_prefix/lib/old_$lib_name" 2>/dev/null || true - sudo ln -sf "$brew_prefix"/lib/old_"$lib_name" "$brew_prefix/lib/$lib_name" + sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true 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() { dependency=$1 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. update_dependencies() { if ! [ -e /tmp/update_dependencies ] && [ "${runner:?}" != "self-hosted" ] && [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then + patch_brew while read -r dependency; do update_dependencies_helper "$dependency" & to_wait+=($!)