mas/script/package

52 lines
1.8 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
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"
# Component package definition
COMPONENTS_PLIST="Package/Components.plist"
# 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 `xcodebuild install`
# DSTROOT will be updated if unset.
INSTALL_TEMPORARY_FOLDER=${DSTROOT:-build/distributions}
2019-01-16 01:31:35 +00:00
mkdir -p "$INSTALL_TEMPORARY_FOLDER"
VERSION=$(script/version)
2018-10-16 04:17:07 +00:00
echo "==> 📦 Assemble an installer package"
# Assemble macOS installer component package (aka "product archive").
# Using /usr/local prefix to avoid the following errors with "/"
# - installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)
# - GUI warning: This package is incompatible with this version of macOS and may fail to install. (may damage your system... )
2018-10-16 04:17:07 +00:00
pkgbuild \
--identifier "$IDENTIFIER" \
--install-location "/usr/local" \
--version "$VERSION" \
--root "$INSTALL_TEMPORARY_FOLDER" \
--component-plist "$COMPONENTS_PLIST" \
"$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.
# https://github.com/Carthage/Carthage/blob/master/Makefile#L87
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
2018-10-16 04:27:20 +00:00
echo "==> 🔢 Files Hashes"
shasum -a 256 "$DISTRIBUTION_PACKAGE"