From 521fb7bc689dddb802d00456537915e576c1a2d1 Mon Sep 17 00:00:00 2001 From: Kevin Li Date: Tue, 7 Nov 2023 14:41:41 -0800 Subject: [PATCH] Clean up all old registries in postinstall and uninstall Signed-off-by: Kevin Li --- installer-builder/darwin/Resources/uninstall.sh | 7 ++++++- installer-builder/darwin/scripts/postinstall | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/installer-builder/darwin/Resources/uninstall.sh b/installer-builder/darwin/Resources/uninstall.sh index 4e86369ea..5026cd3b7 100755 --- a/installer-builder/darwin/Resources/uninstall.sh +++ b/installer-builder/darwin/Resources/uninstall.sh @@ -24,7 +24,12 @@ if [ "$$(readlink "/usr/local/bin/finch")" = "/Applications/Finch/bin/finch" ]; echo "[1/3] [DONE] Successfully deleted shortcut links" #forget from pkgutil -pkgutil --forget "org.Finch.__VERSION__" > /dev/null 2>&1 +echo "Remove historical pkgutil packages..." +pkgutil --pkgs | grep '^org\.Finch\.' | while read -r pkg; do + echo "Forgetting package $pkg" + sudo pkgutil --forget "$pkg" +done + if [ $? -eq 0 ] then echo "[2/3] [DONE] Successfully deleted application informations" diff --git a/installer-builder/darwin/scripts/postinstall b/installer-builder/darwin/scripts/postinstall index a0ce9e26b..a9dc98e74 100755 --- a/installer-builder/darwin/scripts/postinstall +++ b/installer-builder/darwin/scripts/postinstall @@ -25,4 +25,11 @@ sudo rm -rf "/opt/finch/" sudo rm -rf "/private/var/run/finch-lima" sudo rm -rf "/private/etc/sudoers.d/finch-lima" +# Forget previous pkgutil packages starting with org.Finch except for the current version +echo "Remove historical pkgutil packages..." +pkgutil --pkgs | grep '^org\.Finch\.' | grep -v '^org\.Finch\.__VERSION__' | while read -r pkg; do + echo "Forgetting package $pkg" + sudo pkgutil --forget "$pkg" +done + echo "Post installation process finished."