diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 09a04263a..d4ae57b6e 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -63,6 +63,7 @@ add_brew_extension() { update_dependencies >/dev/null 2>&1 disable_dependency_extensions "$extension" >/dev/null 2>&1 (brew install -f "$ext_tap/$formula@$version" >/dev/null 2>&1 && copy_brew_extensions "$formula") || pecl_install "$extension" >/dev/null 2>&1 + restore_libraries >/dev/null 2>&1 add_extension_log "$extension" "Installed and enabled" fi } @@ -98,13 +99,21 @@ add_pecl() { link_libraries() { formula=$1 formula_prefix="$(brew --prefix "$formula")" - sudo mkdir -p "$formula_prefix"/lib + sudo mkdir -p "$formula_prefix"/lib /tmp/brew_libs for lib in "$formula_prefix"/lib/*.dylib; do lib_name=$(basename "$lib") sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true + [ -L "$lib" ] || sudo cp -a "$lib" /tmp/brew_libs/"$lib_name" 2>/dev/null || true done } +# Function to restore all libraries of a formula. +restore_libraries() { + sudo mkdir -p "$brew_prefix/lib" + sudo cp -a /tmp/brew_libs/* "$brew_prefix/lib" 2>/dev/null || true + sudo rm -rf /tmp/brew_libs >/dev/null 2>&1 +} + # Link opcache extension to extensions directory. link_opcache() { opcache_ini="$brew_prefix"/etc/php/"$version"/conf.d/ext-opcache.ini