Chapter 15. Creating and Installing Packages
In Chapters 13 and 14, we discussed installing packages with Fink and DarwinPorts, respectively. This chapter shows how to create packages using tools provided with Mac OS X Tiger, as well as with Fink and DarwinPorts.
The following packaging options are supported on Mac OS X by default:
Found in /Developer/Applications/Utilities, PackageMaker can be used to create packages (.pkg), which are bundles consisting of all the items that the Mac OS X Installer (/Applications/Utilities) needs to perform an installation. PackageMaker can also create metapackages (.mpkg), which can be used to install multiple packages at the same time, and distributions, which specify an entire customized installation process involving one or more packages.
When a metapackage is installed, a "receipt" is placed in the /Library/Receipts folder. These receipts are named with a .pkg extension and appear in the Finder as packages, even though they are not. You cannot use these files to install or update software. Instead, they are used to maintain a record of which packages have been installed on your system. This is how, for example, System Update knows not to install a package (or to update a package) that you've already installed.
gnutar and gzip
The Unix tape archive tool gnutar is used to bundle the directories and resources for distribution. (The tar command is provided as a hard link to gnutar.) GNU Zip (gzip) is used to compress the tar archives to make file sizes as small as possible. Using these tools is generally the simplest way to copy a collection of files from one machine to another.
Mac OS X Tiger supports archiving files and directories in the .zip format directly from the Finder by Control-clicking on a file or directory and selecting "Create Archive of ..." from the contextual menu.
One of the easiest ways to distribute an application is to use the Disk Utility (/Applications/Utilities) to create a disk image. You can use the Disk Utility to create a double-clickable archive, which mounts as a disk image on the user's computer. From there, the user can choose to mount the disk image each time the application is run, copy the application to the hard drive (usually to /Applications), or burn the image to a CD. Disk Utility has a command-line counterpart, hdiutil, which we'll cover in the later section, "Creating a Disk Image from the Command Line."
Each of these tools are discussed separately in the following sections.