mas/script/install

56 lines
1.3 KiB
Text
Raw Normal View History

2019-01-03 23:30:33 +00:00
#!/bin/bash -e
#
# script/install
# mas
#
# Installs mas into PREFIX using the following steps:
#
# 1. Invokes the xcodebuild install action.
# 2. Copies the mas binary and MasKit.framework bundle into their correct
# relative positions under PREFIX.
#
# NOTE: This script is called by the mas Homebrew formula so it has only system
# dependencies aside from xcodebuild.
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/mas.rb
#
BUILD_DIR="$PWD/build"
PROJECT="mas-cli.xcodeproj"
SCHEME="mas-cli Release"
CONFIG="Release"
VERSION=$(script/version)
# Destination for `xcodebuild install`
INSTALL_TEMPORARY_FOLDER=${DSTROOT:-build/distributions}
# Final destination.
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
2021-03-21 23:50:09 +00:00
PREFIX="$1"
elif [[ $(uname -m) == 'arm64' ]]; then
2021-03-21 23:50:09 +00:00
PREFIX=/opt/homebrew
else
2021-03-21 23:50:09 +00:00
PREFIX=/usr/local
2018-10-17 22:18:30 +00:00
fi
echo "==> 📲 Installing mas ($VERSION) to $PREFIX"
xcodebuild \
2021-03-21 23:50:09 +00:00
-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 \
2021-03-21 23:50:09 +00:00
"$INSTALL_TEMPORARY_FOLDER/Frameworks" \
"$PREFIX/Frameworks"
# Copy mas binary
2018-10-17 22:48:35 +00:00
ditto -v \
2021-03-21 23:50:09 +00:00
"$INSTALL_TEMPORARY_FOLDER/bin" \
"$PREFIX/bin"