Skip to content

Commit

Permalink
fix: Clean up all previous finch version installation registries in p…
Browse files Browse the repository at this point in the history
…ostinstall and uninstall (#688)

Issue #, if available:
#687
Old finch installation registry remains if uninstall script not
explicitly called, the mac will treat a new installation with upgrade
info message.

*Description of changes:*
Added a full clean up step in the postinstall script to remove all old
registries except the current installed version. Also make the uninstall
script not only remove the current but also remove all historical
registry record.

*Testing done:*
Tested with cloud build:
https://github.com/runfinch/finch/actions/runs/6791189430
Also validated locally with pkg installation:
```
// Before install the fixed pkg, it print all finch registries
% pkgutil --pkgs | grep '^org\.Finch'
org.Finch.v0.8.0
org.Finch.pkg-tool
org.Finch.v0.7.0
org.Finch.v0.6.2
org.Finch.main
org.Finch.0.6.0
org.Finch.0.4.1
org.Finch.0.4.0

// After install the fixed pkg, it only has the current registry
% pkgutil --pkgs | grep '^org\.Finch'
org.Finch.fix-unregistry

// After execute uninstall, all the registries are removed
% pkgutil --pkgs | grep '^org\.Finch'
% // empty
```


- [X] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Signed-off-by: Kevin Li <[email protected]>
  • Loading branch information
KevinLiAWS authored Nov 8, 2023
1 parent 00ba174 commit 9afc0b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion installer-builder/darwin/Resources/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ if [ "$(readlink '/usr/local/bin/finch')" = "/Applications/Finch/bin/finch" ]; t
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" > /dev/null 2>&1
done

if [ $? -eq 0 ]
then
echo "[2/3] [DONE] Successfully deleted application informations"
Expand Down
7 changes: 7 additions & 0 deletions installer-builder/darwin/scripts/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -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."

0 comments on commit 9afc0b9

Please sign in to comment.