mas/script/install

80 lines
2.3 KiB
Text
Raw Normal View History

2019-01-03 23:30:33 +00:00
#!/bin/bash -e
#
# script/install
# This script is called by the Homebrew formula, so should not
# rely on any dependencies.
#
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.
PREFIX=/usr/local
# Artifacts to copy.
2018-10-17 23:18:55 +00:00
FRAMEWORK_NAME=MasKit.framework
BINARY_NAME=mas
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
echo "==> 📲 Installing mas ($VERSION) to $PREFIX"
xcodebuild \
-project "$PROJECT" \
-scheme "$SCHEME" \
-configuration "$CONFIG" \
OBJROOT="$BUILD_DIR" \
SYMROOT="$BUILD_DIR" \
DSTROOT="$INSTALL_TEMPORARY_FOLDER" \
install
# Deep copy MasKit.framework
2018-10-17 22:48:35 +00:00
ditto -v \
"$INSTALL_TEMPORARY_FOLDER/Frameworks" \
"$PREFIX/Frameworks"
# 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
# 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"
# 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"