In the resources folder I have background.png, Welcome.rtf and License.rtf and in the scripts folder I have preflight, postflight and various support files for those scripts. The resulting .pkg appears to be fully functional except that the installer does not display my background, welcome or license.
Edit: I have also tried to use pkgutil to expand, edit Distribution, and reflatten a flat package. This gets the icons and readme in the installer, but the installer is then unable to unpack the payload. Same if I reflatten with Flat Package Editor. I have also tried to create an expanded package without PackageMaker (which works, except on 10.8), but when I try to flatten that with pkgutil the result is a corrupted package again.
Check out the Luggage - it's a Makefile helper file that lets you create OS X packages with sane Makefiles. Disclaimer: I am the original author for it, though there are a lot of other people's contributions in it now.
In today's article, we will look at the new flat package format. First, we learn how this format compares with earlier bundle-style formats. Then we examine the structure of a typical flat package. Finally, we look at three useful tools with which to manage the package.
The article assumes that readers know how to use PackageMaker 3.0, as well as the Terminal utility. If this is your first time using PackageMaker 3.0, refer to my introductory article Packaging For Leopard for the necessary basics.
When PackageMaker starts a new project, it displays its sheet dialog Install Project (Figure 1). Use this dialog to supply some basic information about your project. For instance, in the Organization field, enter a unique ID for the package. Convention dictates that you use your product or company's URL as the ID string. Make sure to enter the string using reverse-domain syntax. If your product URL is www.foobar.com/foo, then type the string as com.foobar.foo.
You can always change the format by choosing Install Properties from the Project menu, and then choosing a different OS target from the pop-up menu. Doing so, however, may corrupt your project file. A safer approach is to keep a separate project file for each OS target.
Assume you have chosen 10.3 as the minimum OS target. Also, assume your installer project has only one payload. If you choose Build from the Project menu, PackageMaker stores your payload inside a payload package, also known as a component package. This package is the simplest of four possible packages.
Figure 2 shows the structure of a typical payload package. As you can see from the diagram, the package is, in essence, a bundle. Its root directory, Contents, contains four items, which are listed as follows.
- An XML file containing the default settings for the entire package. To view its contents, use the Property List Editor tool. You can also view the file with a text editor, if you are familiar with XML.
Assume again that your minimum OS target is 10.3. But this time, you have more than one payload in your installer project. Or you have customized the install panels using PackageMaker's Interface Editor. Or you used external scripts to customize the install session. When you choose Build from the Project menu, PackageMaker builds the installer package as a meta-package (Figure 3).
In a meta-package, each payload is stored as a payload package in Contents/Packages/. Any files used to localize the install panel go into the correct lproj bundle in Contents/Resoures/. External scripts that customize the install session also go into Contents/Resources/.
But the meta-package does not let you customize the Conclusion panel nor the payload choices. It does not support scripts written in Installer JavaScript. And it cannot display just the Easy Install or Custom Install panels -- it has to display both panels.
Now assume you have 10.4 as your minimum target. In this case, when you choose Build from the Project menu, PackageMaker builds your installer package as a distribution package (Figure 4). At first, its structure appears similar to that of the meta-package. A distribution package, however, has several advantages over a meta-package.
First, it lets you use embedded text to customize each install panel. It also lets you customize all install panels, as well as the payload choices. Next, it supports scripts written in the new Installer JavaScript dialect. Plus, it can assume one of three install modes: Easy, Custom, or both. Finally, it keeps all its scripts, settings, and some localized text in a single XML file, distribution.dist. But it still keeps localized files inside an lproj bundle in Contents/Resources/.
Finally, assume you selected 10.5 as your minimum OS target. (In Snow Leopard's PackageMaker v3.04, "10.5" remains the highest target OS). Now, when you choose Build from the Project menu, PackageMaker builds the package as a flat file, not as a bundle. As a result, you can no longer view the package's contents from the Finder using the Show Package Contents menu.
The flat package uses a structure different from the previous three formats (Figure 5). First, it does away with the Contents directory, and certain files like Info.plist and PkgInfo. Second, it keeps its main items like payloads and resources at the root level. Third, it renames the distribution.dist file as simply Distribution. It still, however, uses lproj bundles to store any localized files.
The flat package also uses a more compact format for its payloads. Each payload package now has three files, instead of the bevy of items from older formats (see Figure 4). The Bom file takes the place of Archive.bom. The Payload file replaces Archive.pax.gz, using gzipped cpio as an archive format. The PackageInfo file, on the other hand, is an XML rendition of PkgInfo.
Finally, the flat package stores its install scripts differently. A pre- or post-install action, for instance, becomes an action payload (Figure 6). Its payload name consists of the main package name and the action type.
On the other hand, pre- and post-install scripts for each payload combine into a single Scripts file, which is then stored in each payload package (Figure 7). This Scripts file uses specialized tags to identify and separate each script. I have, of course, covered pre- and post-install actions and scripts in a previous MacTech article.
Since the flat package is a single file, it is much easier to distribute over the network. Bundle packages, on the other hand, needs to be "repackaged" in another form like a disk image or a zip archive. But the flat package is supported only on OS X 10.5 or newer. It harder to customize after being built, and it does not support installer plug-ins.
PackageMaker 3.0 comes with three tools that you can use to work with flat packages. One tool, the Flat Package Editor, lets you view the package's contents, as well as make some simple changes. Obviously, you cannot use this tool to open one of the three bundle packages. Doing so will only result in an error.
There are two ways to start the editor. The first way is to choose Launch Flat Package Editor... from the Edit menu of PackageMaker. After the editor launches, choose Open from its File menu, and use the Open File dialog to select the flat package. Click the Open button to open the selected package.
The second way is to select the flat package with a Control-click. Then choose Flat Package Editor from the Open With contextual sub-menu. Both approaches will display the package contents as a hierarchical list (Figure 8). Bundles and directories inside the package appear with a triangle widget next to their icons. Clicking the triangle displays the contents of that bundle or directory.
The Flat Package Editor is not a "separate" tool. In fact, it resides inside the Contents/Resources directory of PackageMaker 3.0. You can, if you prefer, place the editor on the Dock. Just switch to the Finder and Control-click the PackageMaker tool. Choose Show Package Contents from the contextual menu, and open the Contents/Resources directory. Then drag Flat Package Editor from that directory onto the Dock.
Assume you want to add a new item to the flat package. To add a file, drag the file from the Finder to the editor window. Once the editor highlights the desired position in the package, drop the file at that position (Figure 9). The editor then copies the file into the package. If the position happens to be in a bundle or directory, the editor reveals its contents prior to the drop.
To add a bundle or directory, use the same steps of selecting the item from the Finder and dragging it to the editor window. This time, when you drop the item, the editor copies not only item but its contents as well (Figure 10). It even includes any subdirectories or hidden files inside the item. At the time of writing, the editor does not provide any means to filter out unwanted items.
To add a new directory to the package, click the New Folder button from the editor toolbar. The editor adds the directory at the end of the list (Figure 11, left). You can then rename the new directory by double-clicking its name.
To enclose a package item inside a new directory, first select the item from the window. Then click the New Folder button from the toolbar. This time, the editor creates the directory at the same position as the item. It then moves the item into said directory (Figure 11, right). But the editor will not enclose certain files (such as Distribution) with a new directory. Nor will it do the same for payload bundles or the Resources directory. So, if you do select any of these items, the editor will simply refuse to do the New Folder action.
Finally, to cancel any of the additions, choose Undo from the Edit menu. The editor then cancels each addition starting with the most recent one. To cancel all additions, choose Revert from the File menu. This one, however, leaves the editor in an unstable state, which can result in a crash.
Now assume you want to remove an item from the flat package. First, select the item from the editor window. Then click the Delete button on the window toolbar (Figure 12). If the selected item is a file, the editor marks it for deletion and then removes its icon from the window. If the item is a bundle or directory, the editor marks it and its contents for deletion. In either case, the item is still present in the flat package. To complete the removal, choose Save from the File menu. To cancel the removal, close the editor window; then click the Don't Save button from the ensuing dialog.
795a8134c1