#!/bin/bash # Create macOS installation packages. # Based on bomutils tutorial: http://bomutils.dyndns.org/tutorial.html cd $(dirname $0) [ -r ../src/VERSION ] && VERSION="$(cat ../src/VERSION)" || (echo "Can't get version from ../src/VERSION" 1>&2; exit 1) AUTHOR="OpenGnsys Project" # Create empty directories. rm -fr build mkdir -p build && cd build mkdir -p flat/base.pkg flat/Resources/en.lproj mkdir -p root/Applications # Copy application and script files. Exclude 'test_modules' cp -a ../../src root/Applications/OGAgent.app; rm -rf root/Applications/OGAgent.app/test_modules cp -a ../scripts . # Create plist file. cat << EOT > root/Applications/OGAgent.app/OGAgent.plist BuildAliasOf OGAgent BuildVersion $VERSION $AUTHOR EOT # Add files in the base package. ( cd root && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > flat/base.pkg/Payload # Create PackageInfo file. cat << EOT > flat/base.pkg/PackageInfo EOT # Compress the scripts folder. ( cd scripts && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > flat/base.pkg/Scripts # Create BOM file. mkbom -u 0 -g 80 root flat/base.pkg/Bom # Create Distribution file. cat << EOT > flat/Distribution OGAgent $VERSION #base.pkg EOT # Create new Xar application archive. rm -f ../../../OGAgentInstaller-$VERSION.pkg ( cd flat && xar --compression none -cf "../../../OGAgentInstaller-$VERSION.pkg" * )