macospackagemakerxar

Scriptable way to create flat .pkg files with custom resources and scripts


I have created a flat .pkg file with following options on 10.7 using PackageMaker 3.0.6:

/Applications/PackageMaker.app/Contents/MacOS/Package --root ./myroot \
 --id com.myroot.pkg --title "My Root" --scripts ./scripts --target 10.5 \
 --verbose --resources ./resources --root-volume-only --domain system \
 --no-relocate --versio 1.0 --certificate "My Cert Name"

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.

How can I add a custom background, welcome and license to a flat package?

As far as I can tell, the Distribution file in the .pkg is missing references to the background, welcome and license files.

As a workaround I tried using xar. If I unpack the package with xar like so:

xar -xf ./myroot.pkg -C work

and add the 3 tags for those files, then pack it again with xar:

cd work && xar -cf ../myroot2.pkg *

I get a package that starts installation ok with my background etc., but when it comes time to install my .app I get these errors (from /var/log/install.log):

 run preupgrade script for myroot
Could not create task for action: run preupgrade script for myroot2
Install failed: The Installer could not extract files from the package for myroot2. Contact the software manufacturer for assistance.
IFDInstallController 863170 state = 7

I have also tried Flat Package Editor: open myroot.pkg, drag out Distribution, edit it, drag it back, delete old Distribution, save. Same problem as with xar.

I would prefer to have a fully scriptable solution as opposed to using GUIs.

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.


Solution

  • PackageMaker always was buggy has hell, and got deprecated with Mac OS X 10.6 Snow Leopard.

    You should use pkgbuild together with productbuild.