2020-09-07 16:15:01 +00:00
|
|
|
#!/bin/bash -e
|
2019-03-31 22:50:25 +00:00
|
|
|
#
|
2019-04-01 03:05:13 +00:00
|
|
|
# script/brew_formula_update
|
2019-03-31 22:50:25 +00:00
|
|
|
# mas
|
|
|
|
#
|
|
|
|
# Updates mas Homebrew core formula:
|
|
|
|
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/mas.rb
|
|
|
|
#
|
2019-04-01 04:00:29 +00:00
|
|
|
# brew bump-formula-pr --help
|
|
|
|
#
|
2019-03-31 22:50:25 +00:00
|
|
|
|
2024-03-04 04:35:52 +00:00
|
|
|
CORE_FORMULA_PATH="$(brew --repository homebrew/core)/Formula"
|
2019-03-31 22:50:25 +00:00
|
|
|
|
|
|
|
function usage {
|
2024-02-19 06:31:03 +00:00
|
|
|
echo "Usage: brew_formula_update [v1.0] [sha1_hash]"
|
2021-03-21 23:50:09 +00:00
|
|
|
echo "- version will be inferred using version script if not provided"
|
|
|
|
echo "- sha will be inferred from the current commit if not provided"
|
|
|
|
exit 1
|
2019-03-31 22:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# arg 1 - version tag
|
|
|
|
if test -n "$1"; then
|
2023-11-25 23:04:18 +00:00
|
|
|
MAS_VERSION="$1"
|
2019-03-31 22:50:25 +00:00
|
|
|
else
|
2023-11-25 23:04:18 +00:00
|
|
|
MAS_VERSION="v$(script/version)"
|
2019-03-31 22:50:25 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# arg 2 - revision (commit hash)
|
|
|
|
if test -n "$2"; then
|
2021-03-21 23:50:09 +00:00
|
|
|
REVISION="$2"
|
2019-03-31 22:50:25 +00:00
|
|
|
else
|
2023-11-25 23:04:18 +00:00
|
|
|
REVISION=$(git rev-parse "$MAS_VERSION")
|
2019-03-31 22:50:25 +00:00
|
|
|
fi
|
|
|
|
|
2024-03-04 04:43:58 +00:00
|
|
|
# Force brew to use the local repository instead of the API.
|
|
|
|
# Disable API before any install, reinstall or upgrade commands.
|
|
|
|
export HOMEBREW_NO_INSTALL_FROM_API=1
|
|
|
|
|
2024-03-04 04:35:52 +00:00
|
|
|
if test ! -f "$CORE_FORMULA_PATH/mas.rb"; then
|
2024-02-19 06:31:03 +00:00
|
|
|
brew install mas
|
|
|
|
fi
|
|
|
|
|
2019-03-31 23:34:33 +00:00
|
|
|
echo "Checking to see if this update can be a simple bump."
|
2024-03-04 04:35:52 +00:00
|
|
|
diff "Homebrew/mas.rb" "$CORE_FORMULA_PATH/mas.rb"
|
2019-04-01 04:00:29 +00:00
|
|
|
|
|
|
|
# diff exit status
|
|
|
|
status=$?
|
|
|
|
formula_revisions=0
|
|
|
|
if test $status -ne 0; then
|
2021-03-21 23:50:09 +00:00
|
|
|
echo "There are changes in the local formula (Homebrew/mas.rb) that haven't been released yet."
|
|
|
|
#exit $status
|
|
|
|
formula_revisions=1
|
2019-03-31 23:34:33 +00:00
|
|
|
fi
|
|
|
|
|
2023-11-25 23:04:18 +00:00
|
|
|
echo "==> 🧪 Updating homebrew-core formula mas ($MAS_VERSION, $REVISION)"
|
2019-03-31 22:50:25 +00:00
|
|
|
|
|
|
|
echo "Validating formula"
|
|
|
|
brew bump-formula-pr \
|
2023-11-25 23:04:18 +00:00
|
|
|
--tag="$MAS_VERSION" \
|
2021-03-21 23:50:09 +00:00
|
|
|
--revision="$REVISION" \
|
|
|
|
--strict \
|
|
|
|
mas
|
2019-03-31 22:50:25 +00:00
|
|
|
|
2019-04-01 04:00:29 +00:00
|
|
|
# brew exit status
|
|
|
|
status=$?
|
|
|
|
if test $status -ne 0; then
|
2021-03-21 23:50:09 +00:00
|
|
|
echo "Formula did not validate using 'brew bump-formula-pr'"
|
|
|
|
exit $status
|
2019-04-01 04:00:29 +00:00
|
|
|
fi
|
|
|
|
|
2024-03-04 04:35:52 +00:00
|
|
|
pushd "$CORE_FORMULA_PATH" || exit 2
|
2019-03-31 22:50:25 +00:00
|
|
|
|
|
|
|
echo "Updating formula"
|
2019-04-01 04:00:29 +00:00
|
|
|
if test $formula_revisions -eq 1; then
|
2021-03-21 23:50:09 +00:00
|
|
|
# Options to
|
|
|
|
dry_run="--dry-run --write"
|
2019-04-01 04:00:29 +00:00
|
|
|
fi
|
|
|
|
|
2019-03-31 22:50:25 +00:00
|
|
|
brew bump-formula-pr \
|
2023-11-25 23:04:18 +00:00
|
|
|
--tag="$MAS_VERSION" \
|
2021-03-21 23:50:09 +00:00
|
|
|
--revision="$REVISION" \
|
|
|
|
--strict \
|
|
|
|
--verbose \
|
|
|
|
"$dry_run" \
|
|
|
|
mas
|