With the number of complex files in a package, creating a package can seem intimidating at first. The Apple utility PackageMaker simplifies the process by letting you create packages using a setup assistant, add components to a distribution project, or manually create a package or metapackage project. Tip Many of the following features are unique to very recent versions of PackageMaker, so be sure you're using the most recent distribution of the Xcode Developer Tools. Package Setup Assistant uses a familiar interface for package creation. It is intended to allow for quick and easy package creation with intelligent defaults. If you need different custom settings, simply open the package or metapackage in PackageMaker. To open Package Setup Assistant, select File > New and click Assist Me. The assistant will walk you through the packagecreation process in the following steps:
Creating a Distribution ProjectDistribution projects can be created for systems that run Mac OS X v10.4 and higher (as well as Mac OS X Server v10.4 and higher). Although a distribution project is similar to a metapackage, it provides more flexibility in customizing the Installer interface. This flexibility is provided by a distribution script, which is XML combined with JavaScript. To create a minimal, functional distribution project, do the following:
The following figure shows a distribution project window with various authentication and postinstall actions already selected. Determining Package File StructureThe first step in manually creating a package project with PackageMaker is to create a folder hierarchy containing the files to be installed. This arrangement should represent the folder hierarchy of the system that will receive the installed files. Begin by creating a folder that represents the root folder of where your files will be installed, as shown in the following figure. In most cases, your destination root folder will correspond to the root folder (/) of the target file system, but this may not always be the case. If, for example, you were creating a package just to install fonts, the root folder could represent /Library/Fonts. The folder structure for the installer is incredibly important. Folders that do not exist will be created, while folders that do exist can have the existing items replaced by the ones in the package.
Once you have the destination root folder, you populate it with files that you want installed by your package. The files are placed within a folder structure that matches where they will be placed on the target computer, relative to the destination root. Any folders that are in the destination root layout but are not on the target computer will be created automatically when the package is installed. Only use copies of the files with which you want to populate the folder hierarchy, because PackageMaker will alter the files during the packagecreation process. Note Use caution when naming the folders used in your folder structure. A typo here will create a new folder with the incorrect name, resulting in an installation that may not behave correctly, but also is often very difficult to diagnose later. Note Take note of folders that are symbolic links or aliases to other folders. Your folder structure should reflect the actual locations of the files, not use paths that include aliases. For example, files that are found in /etc/ actually live in /private/etc/. Creating a Package Manually in PackageMakerAfter you have created the folder hierarchy containing the files to be installed and included the resources, run the PackageMaker utility to convert the folder hierarchy into a package, using the Single Package Project option. The PackageMaker window has five panes:
Note As you're creating your source folder hierarchy, most files will take your user name as their new owner. Be sure to click File Permissions and change the ownership back to root for most files. Otherwise, a normal user account will become the owner of the new files on the target computer. The File Permissions window contains a button to apply recommended permissions to all of the files. Although these permissions are usually sufficient, you'll want to examine the new permissions assigned to each file before continuing. The Contents pane also allows you to add file filters and locator definitions (used to locate and identify previously installed software). Generally you will want to compress the archive,so your resulting package will be smaller. In most cases, you'll want to remove the .DS_Store files, but do not discard the resource forks. Including .DS_Store files or discarding resource forks can lead to problems with the appearance and operation of your installed files on the target computer.
After you fill in the required information in PackageMaker, choose File > Save to save the configuration, and then choose Project > Build to create the package. Note A symbolic link to the command line version of PackageMaker also exists in /Developer/Tools. It is primarily useful if you want to automate the creation of a package or to create a snapshot, which creates a package based on changes to a specific directory. You can find more information by navigating to the /Developer/Tools directory and typing man packagemaker. More Info The Help > Online Documentation menu option in PackageMaker provides many details about each of the options in each pane. Setting Configuration OptionsThe Configuration pane lists the options on the package. You can specify whether a restart and/or authorization is required. Also, you can set flags that affect the installation. Here are the various options available in the Configuration pane:
Taking Advantage of Third-Party UtilitiesNumerous third-party utilities exist to make package creation easier. There are utilities that cover every aspect of package creation. logGenlogGen is a command-line utility that you can easily use to display files that were modified on your system. For example, you can compare file checksum values before and after an install so that you'll know what files need to be included in your package. More information is available at the LSA Mac OS X Software site (www.lsa.umich.edu/lsait/admin/mac/software/index.asp. Iceberg and ComposerThese applications provide alternatives to Apple's PackageMaker. Although they simplify many tasks of package creation, you'll want to carefully evaluate which of the three applications is the best fit for your project. Composer, from JAMF Software, can be found at www.jamfsoftware.com/products/composer, and Iceberg is available from White Box at http://s.sudre.free.fr/Software/Iceberg.html. The Iceberg application looks similar to PackageMaker and allows for many of the same options, plus a few more. PacifistPacifist, from CharlesSoft (www.charlessoft.com), provides a friendly graphical package inspector. This handy tool provides a quick Finderlike view of the files contained in the payload of a package. That's useful when building packages because it provides a quick way to visually inspect the results of your package building, but it can also be used to extract individual files from a package without installing the entire package. The following figure shows a package and all its contents in a Pacifist window displayed in a Finderlike interface. |