PDA

View Full Version : PackageMaker Postflight Doesn't Run




macdong
Aug 30, 2010, 05:28 PM
I have a package that installs an application and a plist for launch daemon. The installation works just fine, but the preflight/postflight scripts won't run. The script are named preflight and postflight, executable bit is set, just don't know what I missed. I am using PackageMaker 3.0.4 under OS X 10.6. The postflight script is as below:

#!/bin/sh
/bin/launchctl load /Library/LaunchDaemons/com.mycompany.myapp.plist
exit 0

Thanks for any help.



chown33
Aug 30, 2010, 05:39 PM
Obvious question: How do you know the postflight doesn't run?
That is, what is your evidence that it doesn't run, as distinct from it running but failing within the shell script itself?

Have you tried a diagnostic postflight (or preflight) script, such as:
#!/bin/bash
echo "$@"
exit 0

macdong
Aug 30, 2010, 05:40 PM
Obvious question: How do you know the postflight doesn't run?
That is, what is your evidence that it doesn't run, as distinct from running but failing within the shell script itself?

Well, i've verified that the script actually runs fine from Terminal, and I was watching the console for any log my app generates, and there is nothing. But you are right, I should put an echo in there to see if it's getting called and failed or not getting called at all.

macdong
Aug 30, 2010, 05:45 PM
Obvious question: How do you know the postflight doesn't run?
That is, what is your evidence that it doesn't run, as distinct from it running but failing within the shell script itself?

Have you tried a diagnostic postflight (or preflight) script, such as:
#!/bin/bash
echo "$@"
exit 0


Thanks for pointing out the obvious, the script does get called. But my problem still remains, if a different one. Why does the script work in Terminal, but not as a postflight script? It's a straight forward one-liner.

chown33
Aug 30, 2010, 06:09 PM
Thanks for pointing out the obvious, the script does get called. But my problem still remains, if a different one. Why does the script work in Terminal, but not as a postflight script? It's a straight forward one-liner.

Once again, how do you know it doesn't work? What is your evidence?

Does launchctl return a failure exit status? Is the launchd job notably absent when you check for it afterwards?

What userid are you running the postflight script under? If it's root, then launchctl will target the init process (pid 1), not the current user's login process. If it's not root, then non-root users can't start or stop shared daemons.

If you're checking with launchctl, what userid is it running as?

Guiyon
Aug 31, 2010, 10:01 AM
Is is a bundle-style package or a flat package? IIRC, Apple limits the autorun scripts to 'preinstall' and 'postinstall' in a flat package.