diff --git a/Library/Homebrew/cmd/vendor-install.sh b/Library/Homebrew/cmd/vendor-install.sh index 6c5d4878ab..baeacad110 100644 --- a/Library/Homebrew/cmd/vendor-install.sh +++ b/Library/Homebrew/cmd/vendor-install.sh @@ -34,8 +34,18 @@ fi # shellcheck disable=SC2034 if [[ -n "${ruby_SHA}" && -n "${ruby_FILENAME}" ]] then - ruby_URL="https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}" - ruby_URL2="https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3_2/${ruby_FILENAME}" + ruby_URLs=() + if [[ -n "${HOMEBREW_ARTIFACT_DOMAIN}" ]] + then + ruby_URLs+=("${HOMEBREW_ARTIFACT_DOMAIN}/bottles-portable-ruby/${ruby_FILENAME}") + fi + if [[ -n "${HOMEBREW_BOTTLE_DOMAIN}" ]] + then + ruby_URLs+=("${HOMEBREW_BOTTLE_DOMAIN}/bottles-portable-ruby/${ruby_FILENAME}") + fi + ruby_URLs+=("https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}" + "https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3_2/${ruby_FILENAME}") + ruby_URL="${ruby_URLs[0]}" fi check_linux_glibc_version() { @@ -76,7 +86,10 @@ quiet_stderr() { fetch() { local -a curl_args + local url local sha + local first_try=1 + local vendor_locations local temporary_path curl_args=() @@ -119,31 +132,34 @@ fetch() { then [[ -n "${HOMEBREW_QUIET}" ]] || echo "Already downloaded: ${CACHED_LOCATION}" >&2 else - if [[ -f "${temporary_path}" ]] - then - # HOMEBREW_CURL is set by brew.sh (and isn't mispelt here) - # shellcheck disable=SC2153 - "${HOMEBREW_CURL}" "${curl_args[@]}" -C - "${VENDOR_URL}" -o "${temporary_path}" - if [[ $? -eq 33 ]] + for url in "${VENDOR_URLs[@]}" + do + [[ -n "${HOMEBREW_QUIET}" || -n "${first_try}" ]] || ohai "Downloading ${url}" >&2 + first_try='' + if [[ -f "${temporary_path}" ]] then - [[ -n "${HOMEBREW_QUIET}" ]] || echo "Trying a full download" >&2 - rm -f "${temporary_path}" - "${HOMEBREW_CURL}" "${curl_args[@]}" "${VENDOR_URL}" -o "${temporary_path}" + # HOMEBREW_CURL is set by brew.sh (and isn't mispelt here) + # shellcheck disable=SC2153 + "${HOMEBREW_CURL}" "${curl_args[@]}" -C - "${url}" -o "${temporary_path}" + if [[ $? -eq 33 ]] + then + [[ -n "${HOMEBREW_QUIET}" ]] || echo "Trying a full download" >&2 + rm -f "${temporary_path}" + "${HOMEBREW_CURL}" "${curl_args[@]}" "${url}" -o "${temporary_path}" + fi + else + "${HOMEBREW_CURL}" "${curl_args[@]}" "${url}" -o "${temporary_path}" fi - else - "${HOMEBREW_CURL}" "${curl_args[@]}" "${VENDOR_URL}" -o "${temporary_path}" - fi - - if [[ ! -f "${temporary_path}" ]] - then - [[ -n "${HOMEBREW_QUIET}" ]] || ohai "Downloading ${VENDOR_URL2}" >&2 - "${HOMEBREW_CURL}" "${curl_args[@]}" "${VENDOR_URL2}" -o "${temporary_path}" - fi + + [[ -f "${temporary_path}" ]] && break + done if [[ ! -f "${temporary_path}" ]] then + vendor_locations="$(printf " - %s\n" "${VENDOR_URLs[@]}")" odie <