mas/script/package

51 lines
1.4 KiB
Text
Raw Permalink 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
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
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_DIR}/distributions"
script/install "${DSTROOT}/usr/local" --universal
version="$(script/version)"
echo "==> 📦 Assembling installer package for mas ${version}"
2018-10-16 04:17:07 +00:00
# Assemble macOS installer component package (aka 'product archive').
2018-10-16 04:17:07 +00:00
pkgbuild \
--identifier "${IDENTIFIER}" \
--install-location '/' \
--version "${version}" \
--root "${DSTROOT}" \
"${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 \
--distribution "${DISTRIBUTION_PLIST}" \
--package-path "${BUILD_DIR}" \
"${DISTRIBUTION_PACKAGE}"
2018-10-16 04:17:07 +00:00
echo '==> 🔢 File Hash'
shasum -a 256 "${DISTRIBUTION_PACKAGE}"