On Mar 16, 2011, at 4:53 PM, Jeff Johnson wrote:
I have an app that runs "/usr/sbin/installer -package [packagePath] -applyChoiceChangesXML [XMLPath] -target /" with a third-party package. This works fine in most cases.
What is the format of the "ChoiceChangesXML" file? For best results you should use the format that is documented in `man installer` with the version of /usr/sbin/installer that shipped as part of Mac OS X 10.6.6. This is not a new format, but has been poorly documented until recently.
You can generate a template for the format by doing this:
/usr/sbin/installer -pkg /path/to/some.pkg -target / -showChoiceChangesXML
This format has the advantage of allow you to specify the desired state for the choice without having to know the current state. The older format is a toggle -- in order to get to the desired state, you have to know the initial state, which actually can vary from machine to machine.
However, I have one user who is reporting install failure with a bizarre problem. If the user runs "/usr/sbin/installer -package [packagePath] -showChoicesXML", it gives the result -1 for choiceIsSelected:
<key>choiceIdentifier</key>
<string>PKG_REF_0</string>
<key>choiceIsEnabled</key>
<false/>
<key>choiceIsSelected</key>
<integer>-1</integer>
<key>choiceIsVisible</key>
<true/>
<key>choiceSizeInKilobytes</key>
<integer>0</integer>
In normal cases, I see choiceIsSelected 1 rather than -1.
According to the installer man page:
The choiceAttribute and attributeSetting values are as follows:
choiceAttribute attributeSetting Description
selected 1 to select the choice, 0 to deselect it
Thus, -1 should not even be a possible value.
It _is_ a possible and legal value -- it means that some of the subchoices under this choice are selected and some are not. This is the "mixed" state that appears in the GUI as a minus sign or hyphen in the checkbox.