mas/script/package

44 lines
1.2 KiB
Text
Raw Normal View History

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