Scripts
You can bundle executable files within your package and Installer.app will run these executables during the install. Generally these files will be shell scripts.
In a built package, scripts are stored in the Contents/Resources/
directory of your package and must have their executable bit set. When building a package, scripts and all other resources should be placed in the Install_resources
directory or your root. This directory can be specified in the “Scripts” tab of the PackageMaker user interface.

Installation scripts run during the actual installation of your package. Installer.app looks for scripts with specific names at certain times. You should use the following names for your scripts:
preflight
: Executed before the installation process.postflight
: Executed after the installation process.preinstall
: Executed before installing a single package. Not executed during an upgrade.postinstall
: Executed after installing a single package. Not executed during an upgrade.preupgrade
: Executed before upgrading a single package. Not executed during an install.postupgrade
: Executed after upgrading a single package. Not executed during an install.
Arguments
Installer.app provides the following arguments:
$1
: The full path to the installation package.$2
: The full path to the installation destination.$3
: The mountpoint of the destination volume.$4
: The root directory for the current System folder.
Environment Variables
In addition to arguments, Installer.app sets some Environment variables:
$INSTALLER_TEMP
: The scratch area used by Installer.app for temporary work. Executable files may write to this directory, but must not overwrite Installer files. Available to preinstall, preupgrade, postflight, postupgrade, and postinstall.$PACKAGE_PATH
: Same as the $1 argument. Available to preinstall, preupgrade, postfight, and postupgrade.$RECEIPT_PATH
: The full path to the directory containing the file being executed. This is a location to which the package has been copied. The executable can currently use this path to locate other files in the package, but this may change in the future. Available to postflight, postupgrade, and postinstall.$SCRIPT_NAME
: The name of the file being executed. Available to postflight, postupgrade, and postinstall.$TMPDIR
: This variable is set when the user is doing a Net or CD installation, but is not set when the user is running on a local writable file system. If set, it contains a path to a location on a writable destination volume. Available to preinstall, preupgrade, postflight, postupgrade, and postinstall.
An Example
#!/bin/bash # # This postflight script echoes the values of the available # arguments and environmental variables. # echo "Start postflight script" echo "" echo "Arguments:" echo "" echo "\$1: full path to the installation package" echo " $1" echo "\$2: full path to the installation destination" echo " $2" echo "\$3: mountpoint of the destination volume" echo " $3" echo "\$4: root directory \"/\" for the current System folder" echo " $4" echo "" echo "Environment variables available to a postflight executable:" echo " INSTALLER_TEMP, PACKAGE_PATH, RECEIPT_PATH, SCRIPT_NAME, and TMPDIR" echo "" echo "\$INSTALLER_TEMP: scratch area used by Installer for temporary work files" echo " $INSTALLER_TEMP" echo "" echo "\$PACKAGE_PATH: full path to the installation package; should be same as \$1" echo " $PACKAGE_PATH" echo "" echo "\$RECEIPT_PATH: full path to directory containing the file being executed" echo " $RECEIPT_PATH" echo "" echo "\$SCRIPT_NAME: name of the file being executed" echo " $SCRIPT_NAME" echo "" echo "\$TMPDIR: if set, a path to a location on a writable destination volume" echo " $TMPDIR" echo "" echo "End postflight script" exit 0