Sunday, September 13, 2009

Repackage Xcode for distribution

The Xcode distribution from Apple consists of an installer metapackage and all the sub-packages are stored in a directory called "packages" located at the same level as the installer metapackage.

No existing tools (Iceberg etc..) will allow you to use this metapackage, so in order to distribute as an installer (to be installed by end users or pushed out via utilities like ARD or LANrev) you need to create a dummy package with a postflight script that runs the terminal installer program and include the Xcode installer metapackage and package folder in the package resources.  Iceberg is a great utility to create packages and this can be done easily.  Here is the postflight script.

installer -package "$1/Contents/Resources/XcodeTools.mpkg" -target /

Notice the "$1/Contents/Resources" refers to the path to the packages Resources folder.   This is a great trick for any utility commands that you wish to install with a package and run as part of a script.