Dragimi Smehurko
Dragimi Smehurko

Reputation: 61

Pkgbuild and Productbuild PKG installs always under ROOT. Why?

Please consider the following sh snippet - it produces PAK file that ALWAYS installs under ROOT in /Applications and fails to launch on Mojave unless

sudo -R `whoami` /Applications/MyApp.app

is issued ...

(this suggestion does not resolve it for me ...)

Thanks in advance!

#!/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" 

Upvotes: 1

Views: 1242

Answers (1)

BrandonMFong
BrandonMFong

Reputation: 101

I think this will help answer your question as to why the pkgbuild always installs contents as root-owned: https://keith.github.io/xcode-man-pages/pkgbuild.1.html#-ownership

Upvotes: 0

Related Questions