On Jun 5, 2009, at 11:45 PM, Andrew Merenbach wrote: On Jun 5, 2009, at 9:20 PM, Patrick Gallagher wrote: On Sun, May 17, 2009 at 11:26 PM, Andrew Merenbach <email@hidden> wrote: Thanks for your response. Looks like I didn't miss anything, then, save for some of those discussions you mention (I recall seeing some a long while ago, but ironically I had thought I'd recalled seeing someone mention more recent versions of PackageMaker being used for making uninstallers--guess I was wrong!!!). I suppose, then, that I'll have to include a Perl script with my distributions for uninstallation, à la Apple's Developer Tools. LANRev's Installease can make an uninstaller by looking at the contents of an existing package. It basically just compiles a list of the files and lists them in a postflight script that gets added to a payload-less package.
Interesting! Thanks for digging that up. That's the sort of system about whose existence I was wondering. From the replies that I received, however, it sounds as though such methods are not in widespread use on the Mac side. I was never a fan of the need for uninstallers on Windows, but after receiving e-mails from users asking me how to get rid of files that my programs have installed, I realize that it'd be a little less cruel to give them a double-clickable item than to make them go into Terminal and type commands, or even to run a shell script.
Microsoft essentially forces programmers to write an uninstaller as part of their software installer, to make installation an "atomic operation."
Other Unix systems provide uninstallation as part of their "package management" systems, which are intended to allow for software to rely on other software that might not be present -- all the "dependencies" are satisfied as part of installation.
For Apple Mac OS 9 and before, "software remove" functionality was added to installers by adding one bit to each file/resource being installed, a "delete during remove" bit. (Those installers also could have "action atoms" that were general-purpose code, and those atoms were supposed to have appropriate "remove" code attached.)
Unfortunately, Apple has provided nothing in this area for Mac OS X.
There are third-party uninstallers which attempt to provide the same kind of functionality that the previous authors suggest: when you want to delete an app, you ask pkgutil or lsbom to provide you with a list of items to be deleted. I even saw one utility that monitored things being thrown into the trash to do this.
I would NOT suggest blindly doing such a thing for the following three reasons: 1) Apps often create preferences and other detritus. You might be able to find some of these files by their application ID (com.MyCompany.MyGreatProgram in /Users/*/Library/Preferences/), but that might not be enough.
2) Some apps might install shared components, or worse, system resources (fonts, particularly, are probably best never deleted). So deleting all the items in the installer's receipt record might cause trouble.
3) Apps are (theoretically) moveable.
Therefore the best solution at this time is to have the programmer write a remover script. These scripts can usually be just a few lines, since you don't have to delete every file individually -- you can just rm -rf entire bundles. Put the script inside some kind of double-clickable item.
You can then embed this remover inside your app, and have a menu item quit your app and /usr/bin/open the remover script. The script knows it's inside the app, so it can easily delete the app.
You are welcome to package this inside an installer script, if you wish, with the removal being done during a postflight script. This will ensure that the script has root privileges if it needs to, and that it does not run while some other installer is doing something. (Since installer scripts have to have SOME payload, install a file into /tmp.) |