2019-01-03 15:30:33 -08:00
|
|
|
#!/bin/bash -e
|
2019-01-18 21:37:51 -07:00
|
|
|
#
|
|
|
|
# script/package
|
|
|
|
# mas
|
|
|
|
#
|
|
|
|
# Builds macOS installer component and distribution packages.
|
|
|
|
#
|
2018-10-15 22:17:07 -06:00
|
|
|
|
2021-04-28 22:28:29 -07:00
|
|
|
BUILD_DIR="$PWD/.build"
|
2019-01-03 16:20:15 -08:00
|
|
|
COMPONENT_PACKAGE="$BUILD_DIR/mas_components.pkg"
|
|
|
|
DISTRIBUTION_PACKAGE="$BUILD_DIR/mas.pkg"
|
2015-09-20 11:23:36 +01:00
|
|
|
|
2018-12-20 18:59:38 -07:00
|
|
|
IDENTIFIER="com.mphys.mas-cli"
|
2019-01-03 16:20:15 -08:00
|
|
|
|
|
|
|
# Distribution package definition
|
|
|
|
# https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html
|
|
|
|
DISTRIBUTION_PLIST="Package/Distribution.plist"
|
2018-12-20 18:59:38 -07:00
|
|
|
|
2021-04-28 22:28:29 -07:00
|
|
|
# Destination for install root
|
|
|
|
DSTROOT=.build/distributions
|
2021-05-07 11:33:39 -07:00
|
|
|
script/install "$DSTROOT/usr/local" --universal
|
2018-12-20 18:59:38 -07:00
|
|
|
|
2019-01-13 00:58:51 -07:00
|
|
|
VERSION=$(script/version)
|
2018-12-20 18:59:38 -07:00
|
|
|
|
2018-10-15 22:17:07 -06:00
|
|
|
echo "==> 📦 Assemble an installer package"
|
|
|
|
|
2019-01-03 16:20:15 -08:00
|
|
|
# Assemble macOS installer component package (aka "product archive").
|
2018-10-15 22:17:07 -06:00
|
|
|
pkgbuild \
|
2021-03-21 16:50:09 -07:00
|
|
|
--identifier "$IDENTIFIER" \
|
2021-04-28 22:28:29 -07:00
|
|
|
--install-location "/" \
|
2021-03-21 16:50:09 -07:00
|
|
|
--version "$VERSION" \
|
2021-04-28 22:28:29 -07:00
|
|
|
--root "$DSTROOT" \
|
2021-03-21 16:50:09 -07:00
|
|
|
"$COMPONENT_PACKAGE"
|
2018-10-15 22:17:07 -06:00
|
|
|
|
2019-01-03 16:20:15 -08:00
|
|
|
# Build distribution package (aka "product archive"). Not sure why, but this is how Carthage does it.
|
2021-04-28 22:28:29 -07:00
|
|
|
# https://github.com/Carthage/Carthage/blob/master/Makefile#L69
|
2018-10-15 22:17:07 -06:00
|
|
|
productbuild \
|
2021-03-21 16:50:09 -07:00
|
|
|
--distribution "$DISTRIBUTION_PLIST" \
|
|
|
|
--package-path "$BUILD_DIR" \
|
|
|
|
"$DISTRIBUTION_PACKAGE"
|
2018-10-15 22:17:07 -06:00
|
|
|
|
2021-04-28 22:28:29 -07:00
|
|
|
echo "==> 🔢 File Hash"
|
2019-01-03 16:20:15 -08:00
|
|
|
shasum -a 256 "$DISTRIBUTION_PACKAGE"
|