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.

The “Scripts” tab

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:

Arguments

Installer.app provides the following arguments:

Environment Variables

In addition to arguments, Installer.app sets some Environment variables:

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