Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstaller for package on Mac OS X

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?

like image 590
villintehaspam Avatar asked Mar 15 '11 13:03

villintehaspam


People also ask

Can I remove pkg files from Mac?

The answer is yes. You can delete the . pkg/. dmg/.

Do I need an uninstaller for Mac?

If you're looking to speed up your Mac by uninstalling yesteryear's app and its associated junk files, you need a dedicated uninstaller.

What is the best free uninstaller for Mac?

If you are looking for a free uninstaller application for Mac, you can choose AppDelete. It is one of the best free app uninstallers for Mac as it lets you uninstall the programs for no charge. One can also choose to use CleanMyMac, another best app uninstaller for Mac to remove two applications in the free version.


5 Answers

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.

like image 55
Rob Napier Avatar answered Oct 04 '22 23:10

Rob Napier


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

like image 43
user1259710 Avatar answered Oct 05 '22 00:10

user1259710


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.

like image 36
Steg Avatar answered Oct 04 '22 22:10

Steg


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
like image 26
petert Avatar answered Oct 04 '22 22:10

petert


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

like image 23
buildmaestro Avatar answered Oct 04 '22 22:10

buildmaestro