From 7f058f3141dee2e0b2a66037501475c3b1825968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 11 Jan 2022 14:43:02 +0100 Subject: [PATCH] fetch-brew-bottle.sh: don't hardcode macOS Mojave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise the OpenSSL installation fails due to lack of `mojave` key: ``` % brew info --json=v1 openssl@1.1 | jq '.[0].bottle.stable.files.mojave' null ``` Because of changes in bottle definition: https://github.com/Homebrew/homebrew-core/commit/6de466c3e5608807b57f3f0fb453ba914dfec2db Also added check for lack of URL and `-S` to `curl` to see errors. Signed-off-by: Jakub SokoĊ‚owski --- scripts/fetch-brew-bottle.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/fetch-brew-bottle.sh b/scripts/fetch-brew-bottle.sh index 1e95b94660..1f6c7b5972 100755 --- a/scripts/fetch-brew-bottle.sh +++ b/scripts/fetch-brew-bottle.sh @@ -8,7 +8,10 @@ function get_gh_pkgs_token() { } function get_bottle_json() { - brew info --json=v1 "${1}" | jq '.[0].bottle.stable.files.mojave' + brew info --json=v1 "${1}" | jq ' + .[0].bottle.stable.files | to_entries + | map(select(.key | test("(arm|linux)") | not)) + | first.value' } function fetch_bottle() { @@ -48,6 +51,11 @@ BOTTLE_JSON=$(get_bottle_json "${BOTTLE_NAME}") BOTTLE_URL=$(echo "${BOTTLE_JSON}" | jq -r .url) BOTTLE_SHA=$(echo "${BOTTLE_JSON}" | jq -r .sha256) +if [[ -z "${BOTTLE_URL}" ]] || [[ -z "${BOTTLE_SHA}" ]]; then + echo "Failed to identify bottle URL or SHA256!" >&2 + exit 1 +fi + echo "${BOTTLE_NAME} - Fetching bottle for macOS" fetch_bottle "${BOTTLE_PATH}" "${BOTTLE_URL}" trap "rm -fr ${BOTTLE_PATH}" EXIT ERR INT QUIT @@ -57,7 +65,7 @@ BOTTLE_LOCAL_SHA=$(shasum -a 256 "${BOTTLE_PATH}" | awk '{print $1}') if [[ "${BOTTLE_LOCAL_SHA}" != "${BOTTLE_SHA}" ]]; then echo "The SHA256 of downloaded bottle did not match!" >&2 - exit 1; + exit 1 fi echo "${BOTTLE_NAME} - Unpacking bottle tarball"