请考虑下面的sh代码片段-它生成的PAK文件总是安装在/Applications的ROOT目录下,并且在Mojave上无法启动,除非
sudo -R `whoami` /Applications/MyApp.app
(这个建议并不能解决我的问题…)
提前感谢!
#!/bin/bash
NAME="MyApp"
APP_NAME="${NAME}.app"
INSTALL_LOCATION="/Applications"
COMP_PLIST="./${NAME}-comp.plist"
SIGNING_IDENTITY="Videv Milko"
VERSION=`grep "<string>" ${APP_NAME}/Contents/Info.plist | tail -1 | sed -n 's/.*>(.*)<.*/1/p'`
PKG_NAME="$NAME-macos-x64-$VERSION.pkg"
# Chnage ownership
chown -R `whoami` "./${APP_NAME}"
# Build componenet plist
pkgbuild --root "./${APP_NAME}" --analyze "$COMP_PLIST"
# Update component plist to disable relocation of the instalation
plutil -replace BundleIsRelocatable -bool false "$COMP_PLIST"
# build the plugin
pkgbuild
--version "$VERSION"
--root "./${APP_NAME}"
--install-location "$INSTALL_LOCATION"
--sign "$SIGNING_IDENTITY"
--component-plist "$COMP_PLIST"
"tmp-${PKG_NAME}"
# Generate Distribution.xml
productbuild --synthesize
--package "tmp-${PKG_NAME}" ./Distribution.xml
# Change Distribution.xml (image, license, ...)
# TODO
# Finally, build the installer package
productbuild --distribution ./Distribution.xml
--package-path . "$PKG_NAME"
我认为这将有助于回答您的问题,为什么pkgbuild
总是将内容安装为root所有:https://keith.github.io/xcode-man-pages/pkgbuild.1.html#-ownership