Mac OS X keeps track of applications installed via the .pkg native installer in the /Library/Receipts folder.

.pkgs appear as files in the Finder but in reality are bundles. Apple nicely conceals information on installed files in the .bom (“bill-of-materials”) proprietary binary files. But also ships a lsbom command that reads them (and a mkbom to create them).

So, supposing you want to uninstall a .pkg-distributed file (say… cmake) you have to:

check that it ships only files and simbolic links

lsbom Archive.bom | less

list the files you are going to delete (checking there is no system file!)

lsbom Archive.bom -f -l -s Archive.bom | less

delete them by hand or with the following command as administrator

lsbom -f -l -s -pf Archive.bom | (cd /; xargs -n 1 rm)

Er, you know in advance that if something goes wrong with the command above you wipe out your entire system, don’t you?

Thanks to ths Macworld post.