Search code examples
macosscriptingpackagemaker

Using scripts in PackageMaker (Mac OS X)


I'm trying to build an install package on Mac for my application(s) (there are two .app-s). One of them is a GUI and the other is an agent (service). The install package must run a script (that's the only way I know it can be done) at the end of the installation, so that the agent would be installed as an agent. There is also a .plist file that is installed in /Library/LaunchAgents, but that's what PackageMaker does automatically (ie without the need of a script).

The problem is that... I can't make the script run. I get "Installation failed" at the end. I don't know what the problem is. Can somebody please help?

A few more details:

  • I'm trying to do this at the postflight step (after the installation is done). just a guess... do I need to call my file with the same name (eg. postflight)?
  • I suppose this is the correct directory and path I have set. After dozens of attempts, in the last one I set as "relative path" the path where the PackageMaker document is (in the same folder I have the script). Is there something important I should know about paths that might cause the problem? (the fact is, however, that the build is successful)
  • do I have to write something specific to allow the script to be executed? I've got the following script: MyInstall.sh

with the following contents (without quotes):

"#!/bin/sh

sudo launchctl load /Library/LaunchAgents/com.MyCompany.MyService.plist"

(note that com.Mycompany.MyService.plist is already there - it puts it there on install).

P.S. In some of my attempts to make it work, PackageMaker crushed.

Can anybody PLEASE help?


Solution

  • You can look at the installation log.

    When the Installer application is running, go to the Window menu and select Installation Log. This will open a separate log window. In this window, select Display All from the combo box. You will be able to see why your script is failing.