2019-01-03 23:30:33 +00:00
|
|
|
#!/bin/bash -e
|
2019-01-19 04:37:51 +00:00
|
|
|
#
|
|
|
|
# script/package
|
|
|
|
# mas
|
|
|
|
#
|
|
|
|
# Builds macOS installer component and distribution packages.
|
|
|
|
#
|
2018-10-16 04:17:07 +00:00
|
|
|
|
2024-11-16 04:21:37 +00:00
|
|
|
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
|
|
|
|
|
|
|
|
if ! cd -- "${mas_dir}"; then
|
|
|
|
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
BUILD_DIR=.build
|
2024-11-16 02:46:11 +00:00
|
|
|
COMPONENT_PACKAGE="${BUILD_DIR}/mas_components.pkg"
|
|
|
|
DISTRIBUTION_PACKAGE="${BUILD_DIR}/mas.pkg"
|
2015-09-20 10:23:36 +00:00
|
|
|
|
2024-11-16 05:12:21 +00:00
|
|
|
IDENTIFIER=com.mphys.mas-cli
|
2019-01-04 00:20:15 +00:00
|
|
|
|
|
|
|
# Distribution package definition
|
|
|
|
# https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html
|
2024-11-16 05:12:21 +00:00
|
|
|
DISTRIBUTION_PLIST=Package/Distribution.plist
|
2018-12-21 01:59:38 +00:00
|
|
|
|
2021-04-29 05:28:29 +00:00
|
|
|
# Destination for install root
|
2024-11-16 04:21:37 +00:00
|
|
|
DSTROOT="${BUILD_DIR}/distributions"
|
2024-11-16 02:46:11 +00:00
|
|
|
script/install "${DSTROOT}/usr/local" --universal
|
2018-12-21 01:59:38 +00:00
|
|
|
|
2024-11-16 18:47:13 +00:00
|
|
|
version="$(script/version)"
|
2018-12-21 01:59:38 +00:00
|
|
|
|
2024-11-16 18:47:13 +00:00
|
|
|
echo "==> 📦 Assembling installer package for mas ${version}"
|
2018-10-16 04:17:07 +00:00
|
|
|
|
2024-11-16 05:12:21 +00:00
|
|
|
# Assemble macOS installer component package (aka 'product archive').
|
2018-10-16 04:17:07 +00:00
|
|
|
pkgbuild \
|
2024-11-16 02:46:11 +00:00
|
|
|
--identifier "${IDENTIFIER}" \
|
2024-11-16 05:12:21 +00:00
|
|
|
--install-location '/' \
|
2024-11-16 18:47:13 +00:00
|
|
|
--version "${version}" \
|
2024-11-16 02:46:11 +00:00
|
|
|
--root "${DSTROOT}" \
|
|
|
|
"${COMPONENT_PACKAGE}"
|
2018-10-16 04:17:07 +00:00
|
|
|
|
2024-11-16 05:12:21 +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 \
|
2024-11-16 02:46:11 +00:00
|
|
|
--distribution "${DISTRIBUTION_PLIST}" \
|
|
|
|
--package-path "${BUILD_DIR}" \
|
|
|
|
"${DISTRIBUTION_PACKAGE}"
|
2018-10-16 04:17:07 +00:00
|
|
|
|
2024-11-16 05:12:21 +00:00
|
|
|
echo '==> 🔢 File Hash'
|
2024-11-16 02:46:11 +00:00
|
|
|
shasum -a 256 "${DISTRIBUTION_PACKAGE}"
|