mas/script/package
Ross Goldberg 6b1903cde9
cd into root of mas project at beginning of every bash script.
Partial #638

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
2024-11-16 14:47:22 -05:00

50 lines
1.4 KiB
Bash
Executable file

#!/bin/bash -e
#
# script/package
# mas
#
# Builds macOS installer component and distribution packages.
#
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"
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"
# Destination for install root
DSTROOT="${BUILD_DIR}/distributions"
script/install "${DSTROOT}/usr/local" --universal
MAS_VERSION="$(script/version)"
echo "==> 📦 Assemble an installer package"
# Assemble macOS installer component package (aka "product archive").
pkgbuild \
--identifier "${IDENTIFIER}" \
--install-location "/" \
--version "${MAS_VERSION}" \
--root "${DSTROOT}" \
"${COMPONENT_PACKAGE}"
# Build distribution package (aka "product archive"). Not sure why, but this is how Carthage does it.
# https://github.com/Carthage/Carthage/blob/master/Makefile#L69
productbuild \
--distribution "${DISTRIBUTION_PLIST}" \
--package-path "${BUILD_DIR}" \
"${DISTRIBUTION_PACKAGE}"
echo "==> 🔢 File Hash"
shasum -a 256 "${DISTRIBUTION_PACKAGE}"