cmd/vendor-install.sh: allow download vendors from HOMEBREW_ARTIFACT_DOMAIN and HOMEBREW_BOTTLE_DOMAIN
This commit is contained in:
parent
5c6d2b154f
commit
7da8a9ebc1
@ -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
|
||||
for url in "${VENDOR_URLs[@]}"
|
||||
do
|
||||
[[ -n "${HOMEBREW_QUIET}" || -n "${first_try}" ]] || ohai "Downloading ${url}" >&2
|
||||
first_try=''
|
||||
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}"
|
||||
"${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[@]}" "${VENDOR_URL}" -o "${temporary_path}"
|
||||
"${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}"
|
||||
"${HOMEBREW_CURL}" "${curl_args[@]}" "${url}" -o "${temporary_path}"
|
||||
fi
|
||||
|
||||
[[ -f "${temporary_path}" ]] && break
|
||||
done
|
||||
|
||||
if [[ ! -f "${temporary_path}" ]]
|
||||
then
|
||||
vendor_locations="$(printf " - %s\n" "${VENDOR_URLs[@]}")"
|
||||
odie <<EOS
|
||||
Failed to download ${VENDOR_URL} and ${VENDOR_URL2}!
|
||||
Failed to download ${VENDOR_NAME} from the following locations:
|
||||
${vendor_locations}
|
||||
|
||||
Do not file an issue on GitHub about this; you will need to figure out for
|
||||
yourself what issue with your internet connection restricts your access to
|
||||
@ -263,11 +279,9 @@ homebrew-vendor-install() {
|
||||
filename_var="${VENDOR_NAME}_FILENAME"
|
||||
sha_var="${VENDOR_NAME}_SHA"
|
||||
url_var="${VENDOR_NAME}_URL"
|
||||
url2_var="${VENDOR_NAME}_URL2"
|
||||
VENDOR_FILENAME="${!filename_var}"
|
||||
VENDOR_SHA="${!sha_var}"
|
||||
VENDOR_URL="${!url_var}"
|
||||
VENDOR_URL2="${!url2_var}"
|
||||
VENDOR_VERSION="$(<"${VENDOR_DIR}/portable-${VENDOR_NAME}-version")"
|
||||
|
||||
if [[ -z "${VENDOR_URL}" || -z "${VENDOR_SHA}" ]]
|
||||
@ -275,6 +289,11 @@ homebrew-vendor-install() {
|
||||
odie "No Homebrew ${VENDOR_NAME} ${VENDOR_VERSION} available for ${HOMEBREW_PROCESSOR} processors!"
|
||||
fi
|
||||
|
||||
# Expand the name to an array of variables
|
||||
# The array name must be "${VENDOR_NAME}_URLs"! Otherwise substitution errors will occur!
|
||||
# shellcheck disable=SC2086
|
||||
read -r -a VENDOR_URLs <<< "$(eval "echo "\$\{${url_var}s[@]\}"")"
|
||||
|
||||
CACHED_LOCATION="${HOMEBREW_CACHE}/${VENDOR_FILENAME}"
|
||||
|
||||
lock "vendor-install-${VENDOR_NAME}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user