mas/script/install
2024-11-17 10:55:55 -07:00

39 lines
884 B
Bash
Executable file

#!/bin/bash -e
#
# script/install
# mas
#
# Installs mas into PREFIX.
#
# NOTE: This script is called by the mas Homebrew formula so it has only system
# dependencies aside from Swift.
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb
#
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
ARCH="$(uname -m)"
RELEASE=".build/${ARCH}-apple-macosx/release"
PREFIX=/usr/local
while [[ -n "${1}" ]]; do
if [[ "${1}" == '--universal' ]]; then
ARCH=universal
RELEASE=.build/apple/Products/Release
else
# Override default prefix path with optional arg
PREFIX="${1}"
fi
shift
done
echo "==> 📲 Installing mas $(script/version) for ${ARCH} to ${PREFIX}"
ditto -v \
"${RELEASE}/mas" \
"${PREFIX}/bin/mas"