为MacO创建一个pkg安装程序,使其能够在用户的主目录中进行安装

问题描述

我想创建一个pkg文件以将捆绑软件安装在用户目录(/ Users // Applications /)中。

我该怎么办?

我使用产品构建时将文件传输到产品:

productbuild --component ./Bundle.app --product ./file.plist

file.plist包含

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>home</key>
  <true/>
</dict>
</plist>

但这不起作用...

是否有可能实现此行为 pkgbuild 要么 productbuild

解决方法

我想出了办法。

  1. pkgbuild --root <path to app> --identifier <identifier> --scripts <path to scripts>--install-location Applications/Name.app Package.pkg

  2. productbuild --synthesize --package ./Package.pkg Distribution.xml

  3. 通过在installer-gui-script中添加标签来编辑文件Distribution.xml: <domains enable_anywhere="false" enable_currentUserHome="true" enable_localSystem="false"/>

  4. productbuild --distribution ./Distribution.xml --package-path ./Package.pkg Product.pkg