Re: Tell why it failed
Re: Tell why it failed
- Subject: Re: Tell why it failed
- From: Conor Schutzman <email@hidden>
- Date: Thu, 06 Jun 2013 10:21:51 -0700
That was kind of my point, but perhaps I could have been more clear.
Instead of exit codes, instead build your if-thens to include different log messages based on on success or failure, than your log becomes a history of not only what failed, but when. If you don't want further commands to be process downstream in any failure condition, then just include exit lines in the if-then so that any unwanted state results in the script halting.
On Jun 6, 2013, at 10:11 AM, Bill Coderre <email@hidden> wrote:
> No, that failure message cannot be changed.
>
> Apple's installer, officially, does not support returning anything other than "0" in a preflight or postflight script. If your product installer is chained together with a bunch of other installers, returning non-zero causes all the downstream installers to be skipped.
>
> Suggestion: have your app do "first run setup" and have a full GUI in place to help. This will also cover the case that the user has been naughty and drag-installed. If you wish, you can have your postflight do some variant on launching the app.
>
>
>
>
> On Jun 6, 2013, at 10:01 AM, Conor Schutzman <email@hidden> wrote:
>> You have pretty limited control over that UI. In fact, I don't even know if any of the GUI tools (Packages, PackageMaker, Casper Composer, etc.) even let you customize the failure message, let alone offer different screens for different failures.
>>
>> Therefore, your script has to do all of the heavy lifting. There are two main ways to log what your script is doing, you can either redirect std out and std err messages into a text file somewhere, or you can use logger to write directly to the syslog (and thus viewable in Console.app). You can even go one step further, and write a function to use echo to write log messages to a file, this is what I do.
>>
>> Here is a a little quick and dirty uninstall script for VMware that demonstrates both building a function for echo, and redirecting std out to a log file.
>>
>>
>> #!/usr/bin/env bash
>>
>> ## HEADER
>> SoftwareTitle=VMware
>> LogFolder="$3/Library/Logs/Packages"
>> LogFile="$LogFolder/Uninstall.log"
>> TimeStamp=`date "+%a %b%e %Y %T"`
>> writeLog(){
>> LogMessage=$1
>> echo "[$TimeStamp] [$SoftwareTitle]: $LogMessage" >> "$LogFile"
>> }
>>
>> ## LOGGING
>> if [[ ! -d $LogFolder ]]; then
>> mkdir -p $LogFolder
>> chown root:wheel $LogFolder
>> chmod 775 $LogFolder
>> fi
>> if [[ ! -w $LogFile ]]; then
>> touch -f $LogFile
>> chown root:wheel $LogFile
>> chmod 775 $LogFile
>> fi
>> echo "====================" >> "$LogFile"
>>
>> ## QUITTING APP
>> writeLog "Quitting application."
>> osascript -e 'tell application "VMware Fusion" to quit'
>>
>> ## APPLICATION
>> AppName="VMware Fusion"
>> if [[ -e "$3/Applications/$AppName.app" ]]; then
>> rm -Rdv "$3/Applications/$AppName.app" >> $LogFile
>> fi
>> if [[ -e "$3/Users/$USER/Applications/$AppName.app" ]]; then
>> rm -Rdv "$3/Users/$USER/Applications/$AppName.app" >> $LogFile
>> fi
>> if [[ -e "$3/Library/Preferences/$AppName" ]]; then
>> rm -Rdv "$3/Library/Preferences/$AppName" >> $LogFile
>> fi
>>
>> ## RECEIPT
>> ReceiptList=$(pkgutil --packages | grep vmware)
>> for EachReceipt in ${ReceiptList[@]}; do
>> pkgutil --forget $EachReceipt >> $LogFile
>> done
>>
>> ## FOOTER
>> echo "====================" >> "$LogFile"
>> exit 0
>>
>>
>> On Jun 6, 2013, at 9:27 AM, Scott Grosch <email@hidden> wrote:
>>
>>> My installer depends heavily on a postinstall script to do most of the work. The "install" part of the package just copies some data in, but then in postinstall I turn on Postgres, create the user/db, configure a bunch of files, etc….
>>>
>>> There are many ways it can fail though, and right now I just do an "exit 1" and then the installer says the installation failed.
>>>
>>> How do I provide the user with a message as to exactly *why* it failed? For example, I'd like to be able to say, "Unable to connect to Postgres" so that they know to go check their configuration, for example.
>
_______________________________________________
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