Skip to content

Commit e67ff94

Browse files
committed
Fix caching couchbase on macOS [skip ci]
1 parent 4e89813 commit e67ff94

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/scripts/extensions/couchbase.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,20 @@ add_couchbase() {
7979
add_extension_log "couchbase" "Installed and enabled"
8080
fi
8181
else
82-
if [ -e "${ext_dir:?}"/libcouchbase_php_core.dylib ]; then
83-
sudo cp "${ext_dir:?}"/libcouchbase_php_core.dylib "${brew_prefix:?}"/lib
82+
if [ -e "${ext_dir:?}/couchbase.so" ]; then
83+
couchbase_rpath="$(otool -l "${ext_dir:?}/couchbase.so" 2>/dev/null | awk '$1 == "path" && $2 ~ /\/couchbase@'"${version:?}"'\// {print $2; exit}')"
84+
couchbase_rpath="${couchbase_rpath/@loader_path/${ext_dir:?}}"
85+
otool -L "${ext_dir:?}/couchbase.so" 2>/dev/null |
86+
awk -v rpath="$couchbase_rpath" '/libcouchbase_php.*\.dylib/ {if ($1 ~ /^@rpath\// && rpath != "") {sub(/^@rpath/, rpath, $1)}; print $1}' |
87+
while read -r dylib; do
88+
dylib="${dylib/@loader_path/${ext_dir:?}}"
89+
[ -e "${ext_dir:?}/$(basename "$dylib")" ] || continue
90+
sudo mkdir -p "$(dirname "$dylib")"
91+
sudo cp "${ext_dir:?}/$(basename "$dylib")" "$dylib"
92+
done
8493
fi
8594
add_brew_extension couchbase extension
95+
find "${brew_prefix:?}/lib" "${brew_prefix:?}/opt/couchbase@${version:?}" "${brew_prefix:?}/Cellar/couchbase@${version:?}" \
96+
-name 'libcouchbase_php*.dylib' -exec sudo cp {} "${ext_dir:?}" \; >/dev/null 2>&1
8697
fi
8798
}

0 commit comments

Comments
 (0)