Re: Option to execute a command?
Re: Option to execute a command?
- Subject: Re: Option to execute a command?
- From: Nathan Sims <email@hidden>
- Date: Wed, 30 Mar 2011 13:08:48 -0700
Thanks Karl, Greg, and Per. I am much farther along now.
When I run my build package, the installation fails due to not being able to run the pre and post scripts:
installd[2326]: PackageKit: Executing script "./preinstall" in /private/tmp/PKInstallSandbox.d9BoJ7/Scripts
installd[2326]: ./preinstall: launchctl: Error unloading: edu.caltech.autonomy.foo
. . .
installd[2326]: PackageKit: Executing script "./postinstall" in /private/tmp/PKInstallSandbox.d9BoJ7/Scripts/
installd[2326]: ./postinstall: launchctl: Dubious ownership on file (skipping): /Library/LaunchAgents/edu.caltech.autonomy.foo.plist
installd[2326]: ./postinstall: nothing found to load
What ownership is the plist file supposed to have? All the files have been moved into the correct places on disk by the installer, and the scripts are all +x. If I manually do a 'launchctl load /Library/LaunchAgents/edu.caltech.autonomy.foo.plist' it works, but the installer doesn't seem to like it.
On Mar 30, 2011, at 12:11 PM, Karl Kuehn wrote:
> One thing that is missing in this conversation is that you could be running this installer targeted at a volume other than the boot volume. It is really simple to catch this case, so we should always be pushing people to do this when they write installer scripts. More inline:
>
> On Mar 30, 2011, at 11:36 AM, Greg Neagle wrote:
>
>>> preinstall:
>>>
>>>> #!/bin/bash
>>>>
>>>> LAUNCHD=/Library/LaunchDaemons/edu.caltech.autonomy.foo.plist
>>>> if [ -e "$LAUNCHD" ]; then
>>>> launchctl unload -w "$LAUNCHD"
>>>> fi
>>
>> This unloads the launchd job defined in /Library/LaunchDaemons/edu.caltech.autonomy.foo.plist only if it already exists. This is useful for reinstalls and installs of new versions of your software. The file does not need to exist.
>
> Here you should be checking if the target volume is '/'. This is simple in this case, just replace the appropriate line with this:
>
> if [ -e "$LAUNCHD" ] && [ "$3" == "/" ]; then
>
> And secondarily I don't understand why you would use the '-w' flag. That is going to have the effect of causing this to never get launched (automatically) again. And remember on 10.6 this flag has moved to separate file. It happens later you are also using the 'load -w', so this will get undone. But it is not needed, and could lead to unexpected side-effects in odd cases.
>
>
>>> postinstall:
>>>
>>>> #!/bin/bash
>>>>
>>>> launchctl load -w /Library/LaunchDaemons/edu.caltech.autonomy.foo.plist
>>>>
>>
>> Since this is a postinstall script, the payload has been installed, which presumably includes your launchd plist.
>> This script simply tells launchd to load the plist.
>
> Same change for this, but you only need to test if $3 is what you expect. I also don't think you need the '-w' here either. That would mess with the settings the user may have made.
>
>> So I don't see why you need the plist file anywhere other than your package payload.
>
> Agreed.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden