Skip to content

Instantly share code, notes, and snippets.

@bikram990
Created July 26, 2017 04:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bikram990/b9dc73163f749c393f69e9e0149debdd to your computer and use it in GitHub Desktop.
Save bikram990/b9dc73163f749c393f69e9e0149debdd to your computer and use it in GitHub Desktop.
Create macOS flat Package from .app in /Applications
#!/bin/sh
TempDir="/tmp/pkg"
AppPath=$1
TargetPath=$2
PackageIdentifier=$3
Certificate=$4
if [ $# -ne 3 ]
then
echo "Usage: $0 <AppPath> <TargetPath> <PackageIdentifier> <CertificateCommonName or CertificateChecksum>"
exit 1
fi
rm -rf ${TempDir}
mkdir -p ${TempDir}
mkdir -p ${TargetPath}
cp -r ${AppPath} ${TempDir}
cd /tmp
pkgbuild --analyze --root ${TempDir} package.plist
pkgbuild --root ${TempDir} --component-plist package.plist --identifier ${PackageIdentifier} package.pkg
productbuild --synthesize --package package.pkg packageDistribution.xml
productbuild --distribution ./packageDistribution.xml --package-path . InstallerPackage.pkg
productsign --timestamp=none --sign "$Certificate" InstallerPackage.pkg SignedInstallerPackage.pkg
rm package.plist
rm package.pkg
rm packageDistribution.xml
rm -rf ${TempDir}
mv SignedInstallerPackage.pkg ${TargetPath}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment