Choices, Choices

A little while back I did some work with installers ability to apply a choicechanges.xml file to a command line install.  Today I tried to explain it to a co-worker and realized that brilliant me never wrote it down.

The goal was to be able to chose which parts of an installer would run when I deployed my package.  When you run some installers from the GUI you’ll see options like this (I used Any Connect for documentation purposes):

Screen Shot 2015-11-02 at 11.15.54 AM

After a bit of Googling I found Office For Mac Help, an unofficial blog for those using Office on a Macintosh.  Their writeup on using the command line to install Office was exactly what I needed.  In fact, the only reason I’m even writing my own post is because I noticed a few changes in the commands since their article was last updated.

TL;DR

is now

In fact, all the installer commands now follow this new format.

From the  installer man page:


Okay, here is the long version.

 

Assuming the file is on your desktop, create a folder to work with, mine is called Test 3, then the basic command to get started is:

By default all components of the pkg will be installed. To selectively install components you’ll need to utilize a choices file that will be deployed with the installer and called as part of the install process.

To view a list of choices available use the following command

You can also add a grep command to identify the choiceIdentifiers

Which will result in a plist that looks like this:

Each ChoiceIdentifier matches one of the choices in the GUI installer. (see picture above)

Your next step is to create a choices file designating the items you want to install. Each item you include in the file corresponds to selecting or deselecting in the GUI. Since everything is selected by default, you deselect and item by adding its choiceIdentifier to the file.

Begin by creating a new xml file called mychoices.xml with in your working directory. Each item is identified by adding it to an array.

This mychoices.xml file will install everything except WebSecurity, FireAmp, DART and Posture.

To verify the correct choices will be installed use this command:

Now you can compare your first plist to the current results, for example, originally web security indicated the following:

Now you can see:

Showing that it won’t be installed. (The attribute setting of 1 in the first example indicates it will be selected, when it changes to 0 it will no longer be selected.)

Now you can rebuild your package:

and you should see a nice confirmation message:

Now you should have a pkg file that you can distribute via whatever method you prefer.

Enjoy.

 

Many thanks to Office For Mac Help for their walkthrough and a shoutout to Patrick Fergus’s original write up “Creating an Installer Choice Changes XML file for Leopard” on AFP548.com, which sadly doesn’t seem to be there anymore.

 

1 thought on “Choices, Choices

  1. I was floored how far that Leopard Choice Changes post went. I think it was even published in a dead tree book.

    However there is a newer format of Choice Changes that’s a little less…obscure than the old one. The old format simulated “clicks” in the Installer.app GUI, whereas the newer format names specific Choices and declares whether or not they are “selected”. See here:

    https://jamfnation.jamfsoftware.com/discussion.html?id=13946#responseChild84049

    Also, note that the statement “you should have a pkg file that you can distribute via whatever method you prefer” should be qualified–you’ll have a Choice Changes file that can be applied when invoking “installer” at the CLI, _but_ the installation method (CLI, Munki, Casper, etc.) needs to support referencing those choices. No change is made to the pkg itself, and (for example) invoking the “installer” command a second time _without_ the reference to the Choice Changes file will result in a standard, unmodified install of the software.

Leave a Reply

Your email address will not be published. Required fields are marked *