Ah, interesting, thanks! I admit I hadn't tested it yet. I was assuming it wouldn't work, because the installer option -showChoiceChangesXML doesn't work on 10.5.
-Jeff
On Mar 17, 2011, at 2:55 PM, Greg Neagle wrote: The alternate format works just fine under 10.5.x in my testing and has been around for quite a while; certainly before Snow Leopard shipped. The only thing "new" is that Apple has finally publicly documented it and updated /usr/sbin/installer to help you create it. /usr/sbin/installer in Leopard can use this format just fine.
-Greg On Mar 17, 2011, at 12:45 PM, Jeff Johnson wrote: Hi Greg.
Thank you very much for your response. I was not aware of the new format was indeed using the older "toggle" format. It appears that the new format is not supported on Mac OS X 10.5, is that correct? Unfortunately, my app still needs to support 10.5.
In any case, on further investigation it turns out that the selected state was not really the problem. The problem was that one of the choices was disabled and could not be toggled, which causes installer to fail. I was finally able to reproduce, and as far as I can tell, the choice is disabled in certain cases by an InstallationCheck script.
-Jeff
On Mar 17, 2011, at 10:26 AM, Greg Neagle wrote: 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. -Greg
|