Please note that the new Flat Package format Apple is now using differs from the below.
Look Here for more details
http://s.sudre.free.fr/Stuff/Ivanhoe/FLAT.html
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 or /var/db/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.