Mac OS X Installer Packages

Mac OS X ships with Installer.app, an application to install packages files with the extension .pkg.

Viewing currently installed packages
You can view currently installed packages by simply looking in the folder /Library/Receipts

ls /Library/Receipts

This directory contains all installed packages, though the content of the actual package is gone, the .pkg files here just contain the metadata. So do not drag them out of this directory, or you will confused them for the original installer files!

Package file format
.pkg (or .mpkg) are not actual plain files, but file bundles. You can show the contents by selecting "show contents" from a context-sensitive menu (right-click menu) in the Finder, or using cd (change directory) in the terminal.

Most notably, each package contains these files: Contents/Archive.bom Contents/Archive.pax.gz Contents/Info.plist Contents/Resources/

You can list the files installed by the package using:

lsbom Contents/Archive.bom

Note that older packages used a different naming convention for the .bom and .pax.gz files: those files were named after the package name. E.g. mypackage.bom for the mypackage.pkg package.

You can extract a single file from the pax archive file (filepattern is optional):

cd destinationdir pax -f sourcedir/File.pkg/Contents/Archive.pax.gz -z -r filepattern

Uninstalling packages
Since you can list files installed by a packages, you can also remove those files. There are two applications which automate this for you:
 * DesInstaller
 * OS X Package Manager (OSXPM)

The disadvantage of this method is that it does not remove:
 * Preference files
 * Caches
 * Any other files that were installed by the application itself, like files in ~/Library/Application Support

Installing packages
Typically, installation is done using the GUI Installer.app

This can also be done manually: sudo installer -pkg MyPackage.pkg -target /

Note that the target is usually /, but not always. For example, for Garageband loops it is /Library/Audio and for Garageband instrument library it is /Library/Application Support/Garageband.

The advantage of the above methods is that is places information on the installed files in /Library/Receipts/

Alternatively, you can do the extracting of files yourself:

cd / # the destination of the package contents sudo pax -z -p e -r -f /path/to/MyPackage.pkg/Contents/Archive.pax.gz sudo cp -r /path/to/MyPackage.pkg /Library/Receipts/ sudo rm /Library/Receipts/MyPackage.pkg/Contents/Archive.pax.gz

Last, if the destination was not /, you may want to add the destination path to /Library/Receipts/MyPackage.pkg/Contents/Info.plist:

IFPkgRelocatedPath /Library/Application Support/DestinationPath

Multipackage Files
.mpkg files contain multiple .pkg files. Sometimes a multipackage file installs all contained packages, sometimes it makes a selection, based on the hardware or software configuration. This selection is made using scripts inside the mpkg file.

Typically, the individual packages files are stored in Contents/Installer

Installer can list information on each package in a multipackage: installer -pkginfo -pkg mypackage.mpkg

Checking permissions
Since Mac OS X keeps the metadata of the .pkg files in /Library/Receipts, you can verify if the file permission are still valid. You can do this with the "DiskUtility.app" application.

In addition, you can also do this from the command line:

sudo diskutil verifyPermissions / sudo diskutil repairPermissions /