I'm having strange issues trying to install a package I've created when a different version of the application already exists in /Applications
The installer throws an error about the postinstall script failing, seemingly because the last thing that script tries to do is call "open /Applications/App Name.app" which appears to be failing because the application is mistakenly being installed to "/Applications/App Name.localized/App Name.app"
I can't figure out why this is happening during the installation and a follow-up attempt to install the same package succeeds because that time the application properly gets installed to "/Applications/App Name.app"
Here are some background & details:
- In previous releases of this app, there were some issues I believe were related to relocation so since then the I added a preinstall script to the installation package that first checks for the existence of "/Applications/App Name.app" & removes it should it be found
- Here is how the package is being built:
#!/bin/bash
IDENTITY_NAME_APPLICATION="Developer ID Application: COMPANY NAME LLC"
IDENTITY_NAME_INSTALLER="Developer ID Installer: COMPANY NAME LLC"
TMPDIR="./tmp"
RAWAPP="App Name.app"
APP_PLIST="./plist/com.corp.appname.plist"
PKGNAME="App_Name.pkg"
echo "Setup tmp directory: ${TMPDIR}"
rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}/root/Applications
mkdir -p ${TMPDIR}/root/Library/LaunchDaemons
if [ ! -d "./Raw App/${RAWAPP}" ]; then
echo "ERROR: could not find ./Raw App/${RAWAPP}"
exit 1
fi
cp -r "./Raw App/${RAWAPP}" ${TMPDIR}/root/Applications
cp -r "${APP_PLIST}" ${TMPDIR}/root/Library/LaunchDaemons
echo "Codesigning the app bundle"
codesign \
--options runtime \
--timestamp --deep \
-s "$IDENTITY_NAME_APPLICATION" \
"${TMPDIR}/root/Applications/${RAWAPP}"
echo "Creating a codesigned installer"
pkgbuild \
--sign "$IDENTITY_NAME_INSTALLER" \
--root "${TMPDIR}/root" \
--component-plist "./plist/appname_component.plist" \
--scripts ./scripts \
${TMPDIR}/AppNameComponent.pkg
productbuild \
--sign "$IDENTITY_NAME_INSTALLER" \
--package ${TMPDIR}/AppNameComponent.pkg \
${TMPDIR}/${PKGNAME}
echo "Clean up"
rm -r ${TMPDIR}/root ${TMPDIR}/AppNameComponent.pkg
echo "Final codesigned pkg: ${TMPDIR}/${PKGNAME}"
The issue is discussed here: http://www.openradar.me/33005768
Installer creates .localized directory for application bundle
When installing an upgrade package that contains an application bundle that does not match the CFBundleIdentifier of the application that is being upgraded, macOS installer creates a .localized directory and installs the upgrade in this directory instead of upgrading the application in place.
The solution is to make sure to use the same Identifier between applications