2019-01-03 23:30:33 +00:00
|
|
|
#!/bin/bash -e
|
2018-12-21 04:16:11 +00:00
|
|
|
#
|
|
|
|
# script/install
|
|
|
|
# This script is called by the Homebrew formula, so should not
|
|
|
|
# rely on any dependencies.
|
|
|
|
#
|
2018-10-17 21:43:02 +00:00
|
|
|
|
2018-12-21 01:58:39 +00:00
|
|
|
BUILD_DIR="$PWD/build"
|
|
|
|
PROJECT="mas-cli.xcodeproj"
|
|
|
|
SCHEME="mas-cli Release"
|
|
|
|
CONFIG="Release"
|
|
|
|
VERSION=$(agvtool what-marketing-version -terse1)
|
|
|
|
|
|
|
|
# Destination for `xcodebuild install`
|
|
|
|
INSTALL_TEMPORARY_FOLDER=${DSTROOT:-build/distributions}
|
|
|
|
|
|
|
|
# Final destination.
|
2018-10-17 21:43:02 +00:00
|
|
|
PREFIX=/usr/local
|
2018-12-21 01:58:39 +00:00
|
|
|
|
|
|
|
# Artifacts to copy.
|
2018-10-17 23:18:55 +00:00
|
|
|
FRAMEWORK_NAME=MasKit.framework
|
|
|
|
BINARY_NAME=mas
|
2018-10-17 21:43:02 +00:00
|
|
|
|
2018-10-17 22:48:35 +00:00
|
|
|
# Override default prefix path with optional 1st arg
|
2018-10-17 22:18:30 +00:00
|
|
|
if test -n "$1"; then
|
|
|
|
PREFIX="$1"
|
|
|
|
fi
|
|
|
|
|
2018-12-21 01:58:39 +00:00
|
|
|
echo "==> 📲 Installing mas ($VERSION) to $PREFIX"
|
2018-10-17 21:43:02 +00:00
|
|
|
|
2018-12-21 04:16:11 +00:00
|
|
|
xcodebuild \
|
|
|
|
-project "$PROJECT" \
|
|
|
|
-scheme "$SCHEME" \
|
|
|
|
-configuration "$CONFIG" \
|
|
|
|
OBJROOT="$BUILD_DIR" \
|
|
|
|
SYMROOT="$BUILD_DIR" \
|
|
|
|
DSTROOT="$INSTALL_TEMPORARY_FOLDER" \
|
|
|
|
install
|
2018-10-17 21:43:02 +00:00
|
|
|
|
2018-12-21 01:58:39 +00:00
|
|
|
# Deep copy MasKit.framework
|
2018-10-17 22:48:35 +00:00
|
|
|
ditto -v \
|
|
|
|
"$INSTALL_TEMPORARY_FOLDER/Frameworks" \
|
|
|
|
"$PREFIX/Frameworks"
|
2018-10-17 21:43:02 +00:00
|
|
|
|
2018-12-21 01:58:39 +00:00
|
|
|
# Copy mas binary
|
2018-10-17 22:48:35 +00:00
|
|
|
ditto -v \
|
|
|
|
"$INSTALL_TEMPORARY_FOLDER/bin" \
|
|
|
|
"$PREFIX/bin"
|
2018-10-17 23:18:55 +00:00
|
|
|
|
2018-12-21 01:58:39 +00:00
|
|
|
# Homebrew wants to fix install linkage...
|
|
|
|
#
|
|
|
|
# Error: Failed changing dylib ID of /usr/local/Cellar/mas/1.4.3/Frameworks/MasKit.framework/Versions/A/Frameworks/Result.framework/Versions/A/Result
|
|
|
|
# from @rpath/Result.framework/Versions/A/Result
|
|
|
|
# to /usr/local/opt/mas/Frameworks/MasKit.framework/Versions/A/Frameworks/Result.framework/Versions/A/Result
|
|
|
|
# Error: Failed to fix install linkage
|
|
|
|
# The formula built, but you may encounter issues using it or linking other
|
|
|
|
# formula against it.
|
|
|
|
#
|
|
|
|
# Setting the rpath to use @executable_path appears to suppress this behavior.
|
|
|
|
|
2018-10-17 23:18:55 +00:00
|
|
|
echo "==> 🔗 Update dylib load paths"
|
|
|
|
|
2018-12-21 01:58:39 +00:00
|
|
|
# install_name_tool
|
|
|
|
# -rpath old new
|
|
|
|
# Changes the rpath path name old to new in the specified Mach-O binary.
|
|
|
|
# More than one of these options can be specified. If the Mach-O binary does
|
|
|
|
# not contain the old rpath path name in a specified -rpath it is an error.
|
|
|
|
|
2018-10-17 23:18:55 +00:00
|
|
|
install_name_tool \
|
|
|
|
-rpath \
|
|
|
|
"/usr/local/Frameworks" \
|
|
|
|
"@executable_path/../Frameworks" \
|
|
|
|
"$PREFIX/bin/$BINARY_NAME"
|
|
|
|
|
|
|
|
install_name_tool \
|
|
|
|
-rpath \
|
|
|
|
"/usr/local/Frameworks/$FRAMEWORK_NAME/Versions/Current/Frameworks" \
|
|
|
|
"@executable_path/../Frameworks/$FRAMEWORK_NAME/Versions/Current/Frameworks" \
|
|
|
|
"$PREFIX/bin/$BINARY_NAME"
|