Using PackageMaker to run a script on install

Abdullah Jibaly picture Abdullah Jibaly · Mar 12, 2009 · Viewed 26.7k times · Source

I have an app I need to create an installer for, and all the installer needs to do (besides copying the app) is run a script (or executable) that is not part of the app itself. Any help on how I can do this? I see in the Requirements tab there is a Results of Script action, and there is also the Preinstall Actions in the Actions tab which has an Open File action. Will either of these do the job or should I be looking elsewhere?

Answer

epatel picture epatel · Mar 12, 2009

Here is a good How-to

There are 7 types of scripts than can be launched during the Installation Process:

InstallationCheck: This script is launched at the beginning of the installation process (even before the Authentication step). It can be used to check that the Package can be installed on this computer.

VolumeCheck: This script is launched in the "Select Destination" step. It is used to determine on which volume the Package can be installed.

preflight: This script is launched just after the user clicked on the "Install" button.

preinstall / preupgrade: This script is launched after the preflight script if there's one (in the case of a single package installation); otherwise just after the user clicked on the "Install" button.

As you see, there's 2 types of scripts here. The preinstall one is launched when the Package has never been installed (from an Installer.app point of view), the preupgrade one is launched when the Package has already been installed. To determine whether a Package has already been installed or not, Installer.app is having a look at the content of the following directory: /Library/Receipts. If there's a file named PackageName.pkg within it, then the Package has already been installed, otherwise it's the first install.

postinstall / postupgrade: This script is launched after the files in the package have been installed. See (preinstall / preupgrade) to see which one is launched.

postflight: This script is launched after the postinstall / postupgrade script or when the package has been installed.