从Mountain Lion到Lion或Snow leopard制作OS X安装程序包

时间:2013-10-03 10:10:42

标签: macos packaging pkgbuild productbuild

我正在this教程后打包我的Mac应用程序。

包分两步生成:

  1. 首先,我使用pkgbuild生成一个临时包。它只包含二进制文件

    pkgbuild --root ${ROOT} --scripts ${SCRIPTS} --identifier myapp \
             --version ${VERSION} --install-location ${INSTALL_DIR} %PKG%
    

    其中%PKG%Distribution.xml中的临时包文件名。

  2. 然后我生成一个包含前一个tmp包的包,一个Distribution.xml,背景图片等productbuild

    productbuild --distribution ${DIST_FILE} --package-path ${PKG_PATH} \
                 --resources ${RESOURCES} ~/myapp.pkg'
    
  3. Distribution.xml看起来像这样:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <installer-gui-script minSpecVersion="1">
        <title>MyApp</title>
        <options hostArchitectures="x86_64"/>
        <options customize="never" rootVolumeOnly="true"/>
        <welcome file="Welcome.rtf"/>
        <license file="license.rtf"/>
        <background file="background.png" scaling="proportional" alignment="bottomleft"/>
        <os-version min="10.6.6"/>
        <options customize="never" require-scripts="false"/>
        <product id="myapp" version="%VERSION%" />
        <choices-outline>
            <line choice="default">
                <line choice="myapp"/>
            </line>
        </choices-outline>
        <choice id="default"/>
        <choice id="myapp" visible="false">
            <pkg-ref id="myapp"/>
        </choice>
        <pkg-ref id="myapp" version="%VERSION%" onConclusion="none">%PKG%</pkg-ref>
    </installer-gui-script>
    

    如果程序包在与其创建的操作系统版本相同的机器上执行 - 本例中为Mountain Lion - 但它在早期版本中抛出“无法在此计算机中安装”错误,则该程序包正常工作;日志显示“安装检查失败”。消息。

    然而,临时软件包安装在Lion和Snow Leopard上运行良好。不知何故,productbuild限制了应用程序的安装位置。我已尝试设置Distribution.xml,但结果是一样的。

1 个答案:

答案 0 :(得分:6)

<os-version>元素需要嵌套在<allowed-os-versions>

<allowed-os-versions>
    <os-version min="10.6.6" />
</allowed-os-versions>

您还应在minSpecVersion="2"中设置<installer-gui-script>

请参阅Distribution Definition XML Schema Reference