Uninstall programs on Mac OS installed from .pkg packages
Mac OS and installers
Everyone who transplanted to Mac OS was pleasantly surprised that in many cases installing programs on this OS comes down to the simple “Drag the program into the“ Applications “folder,” and that’s all. Then just click on it and it starts. I got a lot of pleasure from such a simple, friendly and understandable approach. I clearly understood: where I put the program, there I will delete it and it will simply disappear. Lepota, and only. Probably many have heard about such a glorious approach in makoshi. But alas (or fortunately) there is nothing ideal, and programs can sometimes be installed on a poppy, in the full sense of the word.
I was a little disappointed at the time, but until recently it somehow did not cause any problems, because I used normal software, which usually supplied uninstall scripts for .pkg packages. But now I decided to install the FontForge font editing program, which was originally developed under the linux ideology and this instantly brought a mess: FontForge.pkg began methodically spreading itself into all kinds of folders instead of simply locating it in "/Applications/FontForge.app" . To make matters even more complicated, FontForge did not have any uninstaller. When the time came to remove FontForge, I asked a perfectly reasonable question: how can I uninstall a program installed from .pkg humanly, which does not offer a complete uninstaller? I would have agreed to clean everything with my hands, but I simply did not know where pkg scattered files on the disk.
Searching the manuals, I found a more or less decent way. To do this, you have to go to the console level to uninstall this and similarly installed programs. This is done using the lsbom console utility.
It so happened that the bulk of the data on already installed packages, starting with Mac OS 10.6, lies in the "/ var / db / receipts /" folder as .bom (bill of materials) files. Some of the packages (with bom files inside) are in the old location "/ Library / Receipts /" - this is the main place for previous versions of mac os. Since bom files could be in packages in mac os versions up to 10.6, it looked (and looks) like this:
Starting from 10.6, bom files can basically be found like this:
As you might have guessed, a bom file contains data about what was written to the file system when installing a specific package.
Finally, the actual uninstallation package instructions with comments:
# Удаляем все файлы пакета:
# lsbom -fls выводит список файлов и символических ссылок созданных пакетом
# cd / - переходит в корень, т.к. все файлы в списке начинаются с "."
# затем список файлов через xargs передаётся в rm, который запускается от имени root
lsbom -fls /var/db/receipts/AppName.bom | (cd /; sudo xargs rm)
# Удаляем все пустые папки аналогичным подходом.
lsbom -dls /var/db/receipts/AppName.bom | (cd /; sudo xargs rmdir -p)
# Удаляем файлы оставшиеся от установщика
sudo rm AppName.bom AppName.plist
You have to be very careful with these commands as they are, firstly, executed as root, and secondly, in the root of the file system. Before uninstalling the installed package like this, it is better to make sure that lsbom does not accidentally indicate any path in the list of files that, being removed from the root, will delete the system files. Also, do not try to remove system packages from Apple - you will have problems with the update and God knows what.
Of course, I know about the third-party utility PackageAssistant, which allows you to manage packages in the system, but the last update for it dates back to 2008. An analysis of its sources by me only confirms that it is not suitable for Mac OS 10.6, since it processes bom files of only packages lying in "/ Library / Receipts", and this, as I have already said, is applicable only up to 10.6.
PS : In general, this is all a matter of good faith for programmers whose responsibility lies with the development of the installer (especially considering the fact that Apple does not provide regular gui tools for working with installed packages). Under the other systems, there are also enough irresponsible programs, after which the system can be cleaned from junk for days. No system is safe from this.
UPD : As prompted in kamenty, you can also use another console utility (it is also not a 100% panacea, but you can try both ways):
pkgutil --unlink PkgName
UPD2 : Ported to Mac OS X