Re: Flat distribution and script requirement
Re: Flat distribution and script requirement
- Subject: Re: Flat distribution and script requirement
- From: Michael Babin <email@hidden>
- Date: Mon, 05 Mar 2012 14:43:00 -0600
On Mar 3, 2012, at 12:24 PM, Bill Coderre wrote:
>> Using an embedded script is only supported by Installer.app (or
>> installer or installd) in Mac OS X 10.6 and later.
>
> Let me point out a distinction here: You can always run any executable program as part of your installation "preflight" and "postflight."
>
> However, it's difficult (on purpose) to run an executable program during the "InstallationCheck" and "VolumeCheck" part of your installation. Here's why:
>
> There's a rule of Installers for Mac OS X: They are not supposed to change the user's computer until the user clicks "Install."
>
> When the Installer is running the Distribution code, that code is JavaScript. Apple set up the JavaScript environment so that the Distribution would not be able to modify the user's computer.
>
> However, there are some things that the JavaScript cannot do. For instance, maybe you have to run a unix executable to go look up some information to decide what should be installed. (Simple case: You are installing a unix program, and to find out its version, you have to get the result of the shell command myprogram --version)
>
> In order to allow that, you use the JavaScript command system.run. It is documented on page 31 of the Installer JavaScript Reference.
>
> HOWEVER THIS IS IMPORTANT AND YOU SHOULD READ IT AND PAY ATTENTION AND SWEAR TO TAKE IT TO HEART
>
> Using sytem.run means that you could accidentally change the user's computer before they've even clicked "Install." That would be so uncool.
>
> If there is any way to avoid using it, DO NOT USE IT. Apple has gone to rather interesting extremes to avoid using it.
>
> Note that if you do use it, your user will see a scary dialog saying "This installer must run a program in order to decide if installation can proceed."
>
> So, you can use it. But please do not, unless you have to.
Thanks for the words of caution and the explanation. In this case, we are using an embedded script to make sure that Java is installed before allowing the install to proceed. We use a simple script, the contents of which are:
#!/bin/bash
java=/usr/bin/java
if $java -version
then
echo success, java installed
exit 0
else
echo failure, java not installed
exit 1
fi
The beneficial side effect of using "java -version", as opposed to checking for the presence of a file or other such test, is that it will trigger the Java install process (with user confirmation before doing so) on Lion. So we are being careful, in this case, to not change anything on the user's computer without their knowledge and approval.
_______________________________________________
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