views:

204

answers:

3

I'm writing what is basically a frontend to installer services on many platforms. One of the things that I (obviously) would like to know is whether an installation has succeeded. On most platforms it's easy: just check the return code / exit code of the installer. However, it isn't so easy on the Mac (using /usr/sbin/installer), because it always exits 0, and you must parse the output (after providing the -verboseR option) in order to determine whether it has succeeded or failed.

I'd just figure this out by trial and error, but I'm finding it hard to engineer myself packages that are, say, broken, to figure out what the system will say when a package is broken in some way.

So I ask, dear Lazyweb: is there a canonical parser for the output of /usr/sbin/installer -verboseR, or at least a guide describing the kinds of things it outputs? I've found this, which helps but doesn't get me all the way there. There must be something better; this seems like a common task.

+2  A: 

You should look at /var/log/install.log, which is where all the combined output from the Installer program goes. Also, depending on the nature of your program, you might find it useful to look at the receipt generated by the installer. These are found in /Library/Receipts. See this Apple technote for more info.

At the end of an installation, you get some logging output like this:

Jul 10 19:26:24 ant Installer[24618]: Starting installation:
Jul 10 19:26:24 ant Installer[24618]: Finalizing installation.
Jul 10 19:26:24 ant Installer[24618]: IFDInstallController 857550 state = 5
Jul 10 19:26:24 ant Installer[24618]: Displaying 'Install Succeeded' UI.
Jul 10 19:26:28 ant installdb[24624]: done. (0.006u + 0.004s)

While no hard return code is given here, there's at least enough to parse to determine if the installation was successful.

Nik Reiman
I understand that I can easily figure out whether the install succeeded; I was looking for a definitive guide on *everything* the installer could possibly output. I'll hold out for another answer, but thank you.
Josh K
+1  A: 

If you want to see what a broken package looks like, just replace one of the in-flight scripts (preflight, preinstall, preupgrade and the post* counterparts) with a script which returns non-zero. It doesn't have to do anything else, just return something which isn't zero (as documented in the Apple software delivery guide, any other return value cancels the installation).

Graham Lee
That sounds good, but I'd like to hold out for a perhaps more definitive answer on the output of the installer. Thanks.
Josh K
+2  A: 

What you're after is kind-of-sort-of-maybe-but-not-really documented here: http://lists.apple.com/archives/installer-dev/2006/Aug/msg00029.html and implemented here: http://glimmerblocker.org/browser/trunk/NotificationApp/src/NotificationApp.m?rev=390#L311

These searches will probably give you lots of sample text, if you need it:

http://lists.apple.com/archives/installer-dev/2006/Aug/msg00031.html suggests that there might be some "official" documentation on the bugtracker, but you need an ADC membership to find that...

What I've found out:

  • lines beginning installer:PHASE start a new phase. The text can be displayed as a heading to the user, and the percentage completion is set to 0.

  • lines beginning installer:STATUS are progress notifications, and contain text which can be displayed to the user. No indication of completion is given.

  • lines beginning installer:% indicate the degree of completion: they indicate the FRACTION of the work done, not the PERCENTAGE. (1.000000 == complete, 0.500000 == halfway)

  • a successful completion is indicated by the line: installer: The install was successful.

  • a failed installation is indicated by the line: installer: The install failed at any time.

  • if the previous line contains bracketed text (typically something like: installer: The install failed (The following install step failed: run <...>) then the bracketed text can be displayed to the user as a failure reason.

Stobor