Inside the Mac OS X .pkg format
In relation to my recent article on rolling your own Mac OS X CD, it seems that for those who are interested, an overview of the Mac OS X .pkg format might be useful
The information I present here is mostly based on reverse engineering. As a result, there are probably huge gaping holes in the information I outline. If anyone has corrections and additional information, then please advise me. I have discovered Apple does provide some information on packages, but they don't detail some of the files commonly found only in Apple packages.
Most third party developers are recommended to not use the package format, unless the facilities it offers are necessary. Instead the drag and drop application bundle from a mounted disk image is the recommended install option.
Firstly, there are two types of packages, these are denoted by the suffix: .pkg - this is a standalone package, secondly: .mpkg - this is a meta-package, it can contain many .pkg files
Metapackages should only be used if you have more complex requirements, for example:
- You want to let the user have the option to chose to only install some of the items.
- One portion of your installation requires a fixed location but the rest can be installed anywhere.
Secondly, I cannot recommend highly enough a package called Pacifist. Although it is still being developed, this application allows you to examine the contents of the archive portion a package. (the .bom and pax.gz or pax)
Outline of a standard package
- GenericPackage.pkg
- Contents
- Resources
BundleVersions.plist
GestaltTool
InstallationCheck
package_version
software_version
VolumeCheck
preflight
postflight
GenericPackage.bom
GenericPackage.pre_install
GenericPackage.post_install
GenericPackage.pre_update
GenericPackage.post_update
GenericPackage.pax.gz
GenericPackage.sizes
- Language.lproj
- GenericPackage.info
VolumeCheck.strings
InstallationCheck.strings
License.rtf
ReadMe.rtf
Welcome.rtf
A normal package contains the following key files:
- The Bill of Materials (.bom) is a binary file which describes the contents of the package.
- The information file (.info) contains information about the package, for example name, description and what restrictions need to be applied.
- The archive file (.pax) a complete archive of the files which will be installed. It will has the suffix .pax.gz if it is compressed.
- The size calculation file (.sizes) is a text file containing the sizes (compressed and uncompressed) of the unarchived software, which the installer uses (usually incorrectly) to calculate required space on the installation volume.
- Other files included in the /Contents/Resources are optional files which are used by the Installer during the installation but that aren't installed on your disk. They include Read Me files, license agreements, and pre-install and post-install scripts.
- The installation check file (InstallationCheck) is a unix script, which can be written in any unix scripting language, most commonly perl or a basic shell script. This is run when the installer is parsing the installation package(s). It's function is to ensure that the actively running System meets the requirements for the package being installed. There is usually a corresponding file with a .strings suffix, this is used as the source for any error messages generated by this script. If this script reports any errors at all the entire installation will be prevented
- The volume check file (VolumeCheck) is a unix script, which can be written in any unix scripting language, most commonly perl or a basic shell script. This is run when the user selects a destination volume for installation of the components of the package(s). It's function is to ensure that the chosen volume meets the requirements for the package being installed. There is usually a corresponding file with a .strings suffix, this is used as the source for any error messages generated by this script. If this script reports any errors at all the installation of this package will be prevented
A metapackage is a bundle which installs multiple packages. Note: a metapackage doesn't have to contain the other packages: it just needs to know their names and locations. Often the packages are in the same directory as their metapackage. This allows a user to install a subpackage separately by double clicking it separately. A standard metapackage contains:
- The list (.list) is a text file with the names of all the packages in the metapackage.
- The information file (.info) contains the information about the overal meta package, for example name, description and what restrictions need to be applied.
- Other files included in the /Contents/Resources are optional files which are used during the installation but that aren't installed on your disk. They include Read Me files, license agreements, and pre-install and post-install scripts.
Although a package appears as a single entity from a Desktop Finder window, you can use a variety of methods to inspect the contents of a package, the simplest of which being the show package contents option from the finder's contextual menu. Access to the package contents can also be obtained via the Terminal utility.

SHouldnt that be GenericPackage.pre_upgrade -- not update.
Is there any command line instructions that can form metapackages?
Jacky:
In response to your question
There is some good information about packages at the following address:
http://www.osxgnu.org/info/
Look at the links on the right.
I have a Makefile that creates a .mpkg. You have to create the Description.plist, Info.plist, and $(PACKAGE_NAME).info files beforehand. Just get them out of an existing .mpkg as a template. They are relatively self-explanatory.
darwin_mpkg: darwin_mpkg_readme darwin_mpkg_welcome
test -d installroot/Packages || mkdir -p installroot/Packages
test -d "installroot/$(PACKAGE_NAME).mpkg/Contents/Resources" \
|| mkdir -p "installroot/$(PACKAGE_NAME).mpkg/Contents/Resources"
# pd
cd ../pd/src && ./configure && make darwin_pkg
sudo cp -R ../pd/pd-*.pkg installroot/Packages
# pd-externals
cd ../externals/build/darwin && make darwin_pkg
sudo cp -R ../externals/build/darwin/pd-externals*.pkg installroot/Packages
# zexy
cd ../externals/zexy/src && make -f makefile.darwin darwin_pkg
sudo cp -R ../externals/zexy/src/pd-zexy*.pkg installroot/Packages
# cyclone
cd ../externals/miXed/cyclone && make darwin_pkg
sudo cp -R ../externals/miXed/cyclone/pd-cyclone*.pkg installroot/Packages
# pd-abstractions
cd ../abstractions/ && make darwin_pkg
sudo cp -R ../abstractions/pd-abstractions*.pkg installroot/Packages
# pd-doc
cd ../doc/ && make darwin_pkg
sudo cp -R ../doc/pd-doc*.pkg installroot/Packages
# pd-noncvs
cd noncvs && make darwin_pkg
sudo cp -R noncvs/pd-noncvs*.pkg installroot/Packages
# pddp
cd ../doc/pddp && make darwin_pkg
sudo cp -R ../doc/pddp/pd-pddp*.pkg installroot/Packages
# unauthorized
cd ../externals/unauthorized && make darwin_pkg
sudo cp -R ../externals/unauthorized/pd-unauthorized*.pkg installroot/Packages
# generate pd.list
cd installroot/Packages && /bin/ls -1d *.pkg \
| sed -e 's/\(.*\)/\1\:Selected/' \
> "../$(PACKAGE_NAME).mpkg/Contents/Resources/$(PACKAGE_NAME).list"
# generate .info file
sed -e 's/PACKAGE_PREFIX/$(PACKAGE_PREFIX)/' pd.info \
| sed -e 's/PACKAGE_VERSION/$(PACKAGE_VERSION)/' \
| sed -e 's/PD_VERSION/$(PD_VERSION)/' \
> "installroot/$(PACKAGE_NAME).mpkg/Contents/Resources/$(INFO_FILE)"
# generate Description.plist
sed -e 's/PACKAGE_PREFIX/$(PACKAGE_PREFIX)/' Description.plist \
| sed -e 's/PACKAGE_VERSION/$(PACKAGE_VERSION)/' \
| sed -e 's/PD_VERSION/$(PD_VERSION)/' \
> "installroot/$(PACKAGE_NAME).mpkg/Contents/Resources/Description.plist"
# generate Info.plist
sed -e 's/PACKAGE_PREFIX/$(PACKAGE_PREFIX)/' Info.plist \
| sed -e 's/PACKAGE_VERSION/$(PACKAGE_VERSION)/' \
| sed -e 's/PD_VERSION/$(PD_VERSION)/' \
> "installroot/$(PACKAGE_NAME).mpkg/Contents/Info.plist"
# install files
install -m644 ../pd/LICENSE.txt "installroot/PD LICENSE.txt"
install -m644 ../externals/creb/COPYING "installroot/GNU GPL.txt"
install -m644 $(README_FILE) $(WELCOME_FILE) logo.jpg pd-32.png pd-16.png \
"installroot/$(PACKAGE_NAME).mpkg/Contents/Resources/"
sudo chmod -R u+w installroot
sudo chmod -R a+r installroot
sudo chmod -R go-w installroot
sudo chgrp -R staff installroot
i was looking into my files and found a document that says Paxerrors.strings (document) and i want to know if its ok to delete it, or woyld it screw up my operating system? please email me at the above E-mail address, with any replies
Thank you , John