Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing the output of /usr/sbin/installer

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.

like image 413
joshk0 Avatar asked Mar 01 '23 13:03

joshk0


2 Answers

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:

  • google:"installer:phase" "installer:status" "installer:%"
  • google:"installer: The install failed"
  • google:"installer: The install was successful" and
  • google:"The following install step failed" and

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.

like image 155
Stobor Avatar answered Mar 08 '23 17:03

Stobor


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.

like image 44
Nik Reiman Avatar answered Mar 08 '23 16:03

Nik Reiman