请考虑以下 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"