Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PackageMaker to run a script on install

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?

like image 699
Abdullah Jibaly Avatar asked Mar 12 '09 22:03

Abdullah Jibaly


2 Answers

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.

like image 116
epatel Avatar answered Oct 14 '22 11:10

epatel


I just managed to include a Shell script to my package that I made with PackageMaker. I needed to add my app to the login items after installation, so I made a script called postflight.sh and put it into a folder. (it seems it works with any location)

And then in my package, I have Applications. In Contents, Package:Applications, in the Scripts tab, I choose the postflight.sh in Postflight section. That's it.

my postflight.sh starts with

#!/bin/bash

and then it has some script to put the app into the login items. When I didn't have that, I could make the package, but the installation failed. Hope this is helpful.

like image 21
joon Avatar answered Oct 14 '22 11:10

joon