@@ -221,6 +221,27 @@ uninstall_freebsd_pkgs() {
221221 fi
222222}
223223
224+ # uninstall_macos_pkgs: Remove macOS build-dependency packages matching a
225+ # pattern. There's no system package manager suitable for our iterative
226+ # build/install-locally workflow on macOS, so pkg-build-macos/pkg-install-macos
227+ # track installed files themselves in a flat-file registry (see
228+ # deps-packaging/pkg-install-macos) instead of using a real package database.
229+ # Args:
230+ # $1 - Package name pattern (regex)
231+ uninstall_macos_pkgs () {
232+ REGISTRY=" $BASEDIR /.cfbuild-macos-db"
233+ [ -d " $REGISTRY " ] || return 0
234+ for filelist in " $REGISTRY " /* .filelist; do
235+ [ -e " $filelist " ] || continue
236+ name=$( basename " $filelist " .filelist)
237+ echo " $name " | grep_q " ^$1 \$ " || continue
238+ while IFS= read -r f; do
239+ rm -f " /$f "
240+ done < " $filelist "
241+ rm -f " $filelist "
242+ done
243+ }
244+
224245# uninstall_cfbuild: Remove all cfbuild packages (runtime and devel)
225246# Uses the appropriate uninstall function based on $DEP_PACKAGING
226247uninstall_cfbuild () {
@@ -230,6 +251,7 @@ uninstall_cfbuild() {
230251 solaris) uninstall_solaris_pkgs ' cfbuild-.*' ;;
231252 freebsd) uninstall_freebsd_pkgs ' cfbuild-.*' ;;
232253 hpux) uninstall_hpux_pkgs ' cfbuild-.*' ;;
254+ macos) uninstall_macos_pkgs ' cfbuild-.*' ;;
233255 * )
234256 log_error " Unknown packaging system: $DEP_PACKAGING "
235257 exit 1
@@ -243,6 +265,7 @@ uninstall_cfbuild_devel() {
243265 case " $DEP_PACKAGING " in
244266 rpm) uninstall_rpms ' cfbuild-.*-devel' ;;
245267 deb) uninstall_debs ' cfbuild-.*-devel' ;;
268+ macos) uninstall_macos_pkgs ' cfbuild-.*-devel' ;;
246269 solaris) uninstall_solaris_pkgs ' cfbuild-.*-devel' ;;
247270 freebsd) uninstall_freebsd_pkgs ' cfbuild-.*-devel' ;;
248271 hpux) uninstall_hpux_pkgs ' cfbuild-.*-devel' ;;
@@ -651,6 +674,7 @@ func_sha256() {
651674 case " $UNAME_S " in
652675 SunOS) digest -a sha256 " $@ " ;;
653676 AIX) openssl dgst -sha256 " $@ " | cut -d ' ' -f 2 ;;
677+ Darwin) shasum -a 256 " $@ " | cut -d ' ' -f 1 ;;
654678 * ) fatal " Can't find command for computing SHA-256" ;;
655679 esac
656680 fi
@@ -700,8 +724,11 @@ retry_wrapper() {
700724 else
701725 err_ret=$?
702726 # in case say dpkg locks are held by automatic updates or something
727+ # -P is a GNU grep extension (missing on e.g. macOS' BSD grep), and
728+ # this is diagnostic-only, so use portable -E and never let it trip
729+ # "set -e" when nothing matches.
703730 # shellcheck disable=SC2009
704- ps -efl | grep -P ' (apt|dpkg|yum|dnf|zypper|rpm|pkg)'
731+ ps -ef | grep -E ' (apt|dpkg|yum|dnf|zypper|rpm|pkg)' || true
705732 maxtries=$(( maxtries - 1 ))
706733 echo " * FAILURE $err_ret "
707734 echo " * Sleeping for: $pause seconds"
0 commit comments