Question

As a service to my users I would like to provide an uninstall script to completely remove all traces of my application on Mac OS X. The application is installed using a package rather than just being dragged into the Applications folder because it is a daemon-type app that also requires to run a script at installation to be launched.

My thinking is to include a file called uninstall.sh and place it into /Library/Application Support/com.<mycompany>.<myapplication>/ and refer to this from the application documentation. The purpose is basically to stop the daemon if running, unload and delete the corresponding plist as well as remove any application files. Does this sound reasonable or are there better methods to accomplish this?

Also I am wondering if it is good practice to also remove traces of the package using pkgutil --forget - if I don't do this, the next time the package is installed it shows up as being upgraded instead of installed. Any recommendations or pointers to best-practice information?

Is there no standard way of doing this on OS X?

Was it helpful?

Solution

There is no standard way of doing this on OS X. Yes, shocking, I know. Apple consistently warns everyone away from package installers (among other things by providing insufficient documentation for them). They then exclusively use package installers for their own standalone apps.... go figure.

Yes, you should include pkgutil --forget.

If your customers are comfortable with this kind of script, then your approach sounds fine. If they want a "double-click-on-it" then you should probably put the uninstaller in /Applications, but avoid that if you can.

If you have a GUI, Status Item, or Preference Panel, then it's nice to put a "Uninstall" button or menu item there rather than requiring them to go mess around with Terminal.

BTW, if you go looking for the Software Delivery Guide, it's been moved for a year or so now, while they "update" it.

OTHER TIPS

the inability to remove packages has bugged me for years, so i've written a tool to uninstall packages:

http://www.corecode.at/uninstallpkg/index.html

its a bit better than the shell scripts to do it floating around because it makes sure never to remove any files that are used by any other installed packages

I have a similar application and came across the same issue. The approach I took was one that I have seen other applications use. Rather than simply distributing the .pkg installer, wrap it up in a .dmg file. The uninstall script can be included with the .pkg in the .dmg.

The uninstall script is then renamed to "uninstall.tool". The .tool extension allows users to run the script by double clicking, rather than having to run it from the command line.

The way I solved this was to use Automator, create an application document and then add dialog and script actions. Finally save your Automator application document and you end up with a simple GUI application to run the uninstall.

Often the uninstall action requires administrator privileges - I solved this in Automator by running a shell script action that generates another shell script that can then by run in an applescript action as follows:

on run {input, parameters}
    do shell script "/tmp/uninstaller.sh" with administrator privileges
    return input
end run

Slightly unconventional, but aren't these all. I have Homebrew and cask installed. I was able to uninstall a .pkg with the following:

 brew cask uninstall --force <pkg_name>

ex. brew cask uninstall --force dockertools

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top