2019-01-13 07:15:46 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
#
|
|
|
|
# script/bottle
|
|
|
|
# mas
|
|
|
|
#
|
2019-01-19 04:37:51 +00:00
|
|
|
# Builds bottles of mas Homebrew formula for custom tap:
|
|
|
|
# https://github.com/mas-cli/homebrew-tap
|
2019-01-13 07:15:46 +00:00
|
|
|
#
|
|
|
|
|
2021-03-20 18:27:05 +00:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# Variables
|
|
|
|
#
|
|
|
|
|
2019-01-13 07:48:55 +00:00
|
|
|
BUILD_DIR="$PWD/build"
|
|
|
|
BOTTLE_DIR="$BUILD_DIR/bottles"
|
|
|
|
VERSION=$(script/version)
|
|
|
|
ROOT_URL="https://dl.bintray.com/phatblat/mas-bottles"
|
2021-03-20 18:27:05 +00:00
|
|
|
|
2021-03-20 19:15:19 +00:00
|
|
|
# Supports macOS versions 11.0 (arm64 & x86_64), 10.15, 10.14, 10.13, 10.12, 10.11
|
|
|
|
# NOTE: The built bottle will have the *current* macOS name, which is why the
|
|
|
|
# latest is first in the list (aka ${OS_VERSIONS[0]})
|
|
|
|
# TODO: Add support for arm64_big_sur
|
2021-03-20 18:27:05 +00:00
|
|
|
OS_VERSIONS=(big_sur catalina mojave high_sierra sierra el_capitan)
|
|
|
|
|
|
|
|
# Output filename from build-bottle command
|
2019-01-13 07:48:55 +00:00
|
|
|
OLD_FILENAME="mas--${VERSION}.${OS_VERSIONS[0]}.bottle.tar.gz"
|
2019-01-13 07:15:46 +00:00
|
|
|
|
2021-03-20 18:27:05 +00:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# Preflight checks
|
|
|
|
#
|
2019-01-13 07:15:46 +00:00
|
|
|
|
|
|
|
# Ensure core formula isn't shadowed by custom tap
|
|
|
|
brew tap --list-pinned | grep mas-cli/tap && brew tap-unpin mas-cli/tap
|
|
|
|
|
|
|
|
# Uninstall if necessary
|
|
|
|
if brew ls --versions mas > /dev/null; then
|
|
|
|
brew uninstall mas
|
|
|
|
fi
|
|
|
|
|
2019-04-30 13:09:06 +00:00
|
|
|
# Uninstall if still found on path
|
|
|
|
if command -v mas > /dev/null; then
|
2020-09-07 16:39:42 +00:00
|
|
|
script/uninstall || true # ignore failure
|
2019-04-30 13:09:06 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Purge the Carthage cache to avoid this error from Homebrew sandboxing:
|
|
|
|
# A shell task (/usr/bin/env git checkout --quiet --force 0.15.0 (launched in /Users/ben/Library/Caches/org.carthage.CarthageKit/dependencies/Commandant)) failed with exit code 128:
|
|
|
|
# fatal: Unable to create '/Users/ben/Library/Caches/org.carthage.CarthageKit/dependencies/Commandant/./index.lock': Operation not permitted
|
|
|
|
rm -rf ~/Library/Caches/org.carthage.CarthageKit
|
|
|
|
|
2021-03-20 18:27:05 +00:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# Build the formula for the current macOS version and architecture.
|
|
|
|
#
|
|
|
|
|
2021-03-20 19:11:38 +00:00
|
|
|
echo "==> 🍼 Bottling mas ${VERSION} for: ${OS_VERSIONS[*]}"
|
2019-01-13 07:15:46 +00:00
|
|
|
brew install --build-bottle mas
|
|
|
|
|
2019-01-13 08:24:22 +00:00
|
|
|
# Generate bottle do block, dropping last 2 lines
|
|
|
|
brew bottle --verbose --no-rebuild --root-url=$ROOT_URL mas
|
2021-03-20 19:11:38 +00:00
|
|
|
SHA256=$(shasum --algorithm 256 "${OLD_FILENAME}" | cut -f 1 -d ' ' -)
|
2019-01-13 07:48:55 +00:00
|
|
|
|
|
|
|
mkdir -p "$BOTTLE_DIR"
|
|
|
|
|
2019-01-13 08:24:22 +00:00
|
|
|
# Start of bottle block
|
2021-03-20 18:27:05 +00:00
|
|
|
BOTTLE_BLOCK=$(cat <<-EOF
|
2021-03-20 19:11:38 +00:00
|
|
|
bottle do
|
|
|
|
root_url "$ROOT_URL"
|
2021-03-20 18:27:05 +00:00
|
|
|
EOF
|
2019-01-13 08:24:22 +00:00
|
|
|
)
|
|
|
|
|
2021-03-20 18:27:05 +00:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# Copy the bottle for all macOS version + architecture combinations.
|
|
|
|
#
|
|
|
|
|
2019-01-13 07:48:55 +00:00
|
|
|
# Fix filename
|
|
|
|
for os in ${OS_VERSIONS[*]}; do
|
|
|
|
new_filename="mas-${VERSION}.${os}.bottle.tar.gz"
|
2021-03-20 19:11:38 +00:00
|
|
|
cp -v "${OLD_FILENAME}" "${BOTTLE_DIR}/${new_filename}"
|
2019-01-13 08:24:22 +00:00
|
|
|
|
|
|
|
# Append each os
|
2021-03-20 19:11:38 +00:00
|
|
|
# BOTTLE_BLOCK="$(printf "${BOTTLE_BLOCK}\n sha256 cellar: :any, %-15s %s" "${os}:" "${SHA256}")"
|
2021-03-20 18:27:05 +00:00
|
|
|
BOTTLE_BLOCK="$BOTTLE_BLOCK"$(cat <<-EOF
|
2019-01-13 08:24:22 +00:00
|
|
|
|
2021-02-13 21:19:14 +00:00
|
|
|
sha256 cellar: :any, $os: "$SHA256"
|
2021-03-20 18:27:05 +00:00
|
|
|
EOF
|
2019-01-13 08:24:22 +00:00
|
|
|
)
|
2019-01-13 07:48:55 +00:00
|
|
|
done
|
|
|
|
|
2019-01-13 08:24:22 +00:00
|
|
|
# End of bottle block
|
2021-03-20 19:11:38 +00:00
|
|
|
BOTTLE_BLOCK=$(cat <<-EOF
|
2019-01-13 08:24:22 +00:00
|
|
|
|
2021-03-20 19:11:38 +00:00
|
|
|
end
|
2021-03-20 18:27:05 +00:00
|
|
|
EOF
|
2019-01-13 08:24:22 +00:00
|
|
|
)
|
|
|
|
|
2021-03-20 19:11:38 +00:00
|
|
|
rm "${OLD_FILENAME}"
|
|
|
|
ls -l "${BOTTLE_DIR}"
|
|
|
|
echo "${BOTTLE_BLOCK}"
|