2019-01-03 23:30:33 +00:00
#!/bin/bash -e
2018-10-16 04:17:07 +00:00
2018-12-21 01:59:38 +00:00
BUILD_DIR="$PWD/build"
2019-01-04 00:20:15 +00:00
COMPONENT_PACKAGE="$BUILD_DIR/mas_components.pkg"
DISTRIBUTION_PACKAGE="$BUILD_DIR/mas.pkg"
2015-09-20 10:23:36 +00:00
2018-12-21 01:59:38 +00:00
IDENTIFIER="com.mphys.mas-cli"
2019-01-04 00:20:15 +00:00
# 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"
2018-12-21 01:59:38 +00:00
# Destination for `xcodebuild install`
# DSTROOT will be updated if unset.
INSTALL_TEMPORARY_FOLDER=${DSTROOT:-build/distributions}
2019-01-04 00:20:15 +00:00
mkdir -p $INSTALL_TEMPORARY_FOLDER
2018-12-21 01:59:38 +00:00
2019-01-13 07:58:51 +00:00
VERSION=$(script/version)
2018-12-21 01:59:38 +00:00
2019-01-06 22:04:22 +00:00
# Final destination.
PREFIX=/usr/local
# Override default prefix path with optional 1st arg
if test -n "$1"; then
PREFIX="$1"
fi
2018-12-21 01:59:38 +00:00
# Run Xcode's install process
2019-01-06 22:04:22 +00:00
script/install "$PREFIX"
2015-09-20 17:58:31 +00:00
2018-10-16 04:17:07 +00:00
echo "==> 📦 Assemble an installer package"
2019-01-04 00:20:15 +00:00
# Assemble macOS installer component package (aka "product archive").
# Using /usr/local prefix to avoid the following errors with "/"
2018-10-16 21:54:02 +00:00
# - 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" \
2018-10-16 21:54:02 +00:00
--install-location "/usr/local" \
2018-12-21 01:59:38 +00:00
--version "$VERSION" \
2019-01-04 00:20:15 +00:00
--root "$INSTALL_TEMPORARY_FOLDER" \
--component-plist "$COMPONENTS_PLIST" \
"$COMPONENT_PACKAGE"
2018-10-16 04:17:07 +00:00
2019-01-04 00:20:15 +00:00
# Build distribution package (aka "product archive"). Not sure why, but this is how Carthage does it.
2018-10-16 21:54:02 +00:00
# https://github.com/Carthage/Carthage/blob/master/Makefile#L87
2018-10-16 04:17:07 +00:00
productbuild \
--distribution "$DISTRIBUTION_PLIST" \
2019-01-04 00:20:15 +00:00
--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"
2019-01-04 00:20:15 +00:00
shasum -a 256 "$DISTRIBUTION_PACKAGE"