4

How to combine two package installer files (PKG) to one big combined installer file? by using Package Installer?

codingenious
  • 8,385
  • 12
  • 60
  • 90
CastAway1970
  • 85
  • 1
  • 6

1 Answers1

5

You can use productbuild to wrap several "component" packages into one "product archive". For example, you can do something like this:

productbuild --resource ./RESOURCE_FOLDER --package-path package1.pkg --package-path package2.pkg --distribution distribution.xml combine_package.pkg

productbuild does not only combine two packages together, it also gives you a chance to add more customizations to the product package. For instance, you can add a welcome screen and license page. You can also give user the choice to select which packages he would like to install. All you need to do is to provide a "distribution" xml file that looks like the following:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="2">
    <title>My Installer</title>
    <welcome file="welcome.html"/>
    <readme file="readme.html" />
    <license file="license.html" />
    <background file="background.png" alignment="bottomleft" mime-type="image/png" scaling="proportional"/>
    <conclusion file="conclusion.html" />
    <options customize="allow" require-scripts="false"/>
    <choices-outline>
        <line choice="com.mycorp.package1"/>
        <line choice="com.mycorp.package1"/>
    </choices-outline>
    <choice id="com.mycorp.package1" title="Package 1" customLocation="/Library">
        <pkg-ref id="com.mycorp.package1">package1.pkg</pkg-ref>
    </choice>
    <choice id="com.mycorp.package" title="Package 1" customLocation="/Library">
        <pkg-ref id="com.mycorp.package2">package2.pkg</pkg-ref>
    </choice>
</installer-gui-script>

and put all resource html files under the folder you specified with the --resource flag.

Please visit https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html to see a detailed reference of how to write a distribution.xml.

Mingjing Zhang
  • 943
  • 5
  • 11