Parsing output / usr / sbin / installer

I am writing what is basically the interface to installers on many platforms. One of the things that I (obviously) would like to know is whether the installation succeeded. On most platforms, this is simple: just check the installer return / exit code code. However, on a Mac this is not so simple (using /usr/sbin/installer ), because it always goes out of 0, and you have to parse the output (after providing the -verboseR option) to determine whether it succeeded or failed.

I would just understand it by trial and error, but itโ€™s hard for me to develop packages that are, say, broken, to understand what the system will say when the package somehow breaks.

So, I ask, dear Lazyvb: is there a canonical parser to output /usr/sbin/installer -verboseR or at least a guide describing the kinds of things it outputs? I found this one that helps, but does not bring me to the end. There must be something better; this seems like a common task.

+4
source share
3 answers

What you need is a kind of genus, perhaps, but not 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 are likely to give you a lot of example text if you need it:

http://lists.apple.com/archives/installer-dev/2006/Aug/msg00031.html suggests that there might be some kind of โ€œofficialโ€ documentation for bugtracker, but you need ADC membership to find this ...

What I learned:

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

  • lines beginning with installer:STATUS are notifications of work done and contain text that can be displayed to the user. No indication of completion.

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

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

  • An unsuccessful installation is indicated on the line: installer: The install failed at any time.

  • if the previous line contains text in brackets (usually something like: installer: The install failed (The following install step failed: run <...>) ), then the text in square brackets can be displayed to the user as the reason for the failure.

+4
source

You should look at /var/log/install.log, which contains all the combined output of the Installer program. In addition, depending on the nature of your program, you may find it useful to view the receipt created by the installer. They are located in / Library / Receipts. See this technologist for more information.

At the end of the installation, you will get some log output:

 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 the hard return code is not listed here, at least enough for parsing to determine if the installation was successful.

+2
source

If you want to see what a broken package looks like, just replace one of the in-flight scripts ( preflight , preinstall , preupgrade and post* ) with a script that returns non-zero. It should not do anything, just return something that is not zero (as described in the Apple Software Delivery Guide , any other return value will cancel the installation).

+1
source

All Articles