问题
I want to do my installation of pkg file as silent install from mac terminal. So i used the below command to do silent install.
sudo installer -store -pkg "/User/MyName/Desktop/helloWorld.pkg" -target /
It perfectly installed my application. But i want to pass arguments from this command line script to package installer that was created in package maker. So that i can able to use this argument value in post/pre installation script inside the package installer.
Is there any possibility to pass my value as argument in the above command?
回答1:
This is not possible from the command since the "installer
" command does not support any such arguments. However, you may try using a configuration file which you can read from pre/postinstall script and do the required actions.
回答2:
In installer
manual you can find something like this:
installer(8) [osx man page]
-applyChoiceChangesXML pathToXMLFile Applies the install choice changes specified in pathToXMLFile to the default choices in the package before installation. This allows the command-line installer to customize choice what gets installed. See CHOICE CHANGES FILE for details of this XML format. Any prob- lems encountered while applying the choice changes will be reported to the LOG_INSTALL facility (i.e. to /var/log/install.log), and also to stdout if -dumplog is used.
And section CHOICE CHANGES FILE says: installer(8) [osx man page]
CHOICE CHANGES FILE
A ``choiceChanges'' file allows individual installer choices to be selected or deselected. A template choiceChanges file for a given package can be generated with the -showChoiceChangesXML option, and is interpreted as follows.
The choiceChanges file is a property list containing an array of dictionaries. Each dictionary has the following three keys:
Key Description
choiceIdentifier Identifier for the choice to be modified (string)
choiceAttribute One of the attribute names described below (string)
attributeSetting A setting that depends on the choiceAttribute, described below (number or string)The choiceAttribute and attributeSetting values are as follows:
choiceAttribute attributeSetting Description
selected (number) 1 to select the choice, 0 to deselect it
enabled (number) 1 to enable the choice, 0 to disable it
visible (number) 1 to show the choice, 0 to hide it
customLocation (string) path at which to install the choice (see below)Note that there can be multiple dictionaries for the same choiceIdentifier, since there can be multiple attributes set for a single choice.
The customLocation attribute can be set for a choice only if that choice explicitly allows a user-defined path. That is, if the choice would have a Location popup when viewed in the Customize pane of the Installer application, it can be set via customLocation. (Otherwise, instal- lation paths cannot be arbitrarily modified, since the package author must account for custom install locations for the installation to work properly.)
This xml can be generated before stating installation and you do not need script to process it (like other answer suggest).
来源:https://stackoverflow.com/questions/28325244/how-to-pass-arguments-to-package-installer-from-mac-terminal