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
 | 
					# shellcheck disable=SC2034
 | 
				
			||||||
if [[ -n "${ruby_SHA}" && -n "${ruby_FILENAME}" ]]
 | 
					if [[ -n "${ruby_SHA}" && -n "${ruby_FILENAME}" ]]
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
  ruby_URL="https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}"
 | 
					  ruby_URLs=()
 | 
				
			||||||
  ruby_URL2="https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3_2/${ruby_FILENAME}"
 | 
					  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
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
check_linux_glibc_version() {
 | 
					check_linux_glibc_version() {
 | 
				
			||||||
@ -76,7 +86,10 @@ quiet_stderr() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
fetch() {
 | 
					fetch() {
 | 
				
			||||||
  local -a curl_args
 | 
					  local -a curl_args
 | 
				
			||||||
 | 
					  local url
 | 
				
			||||||
  local sha
 | 
					  local sha
 | 
				
			||||||
 | 
					  local first_try=1
 | 
				
			||||||
 | 
					  local vendor_locations
 | 
				
			||||||
  local temporary_path
 | 
					  local temporary_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  curl_args=()
 | 
					  curl_args=()
 | 
				
			||||||
@ -119,31 +132,34 @@ fetch() {
 | 
				
			|||||||
  then
 | 
					  then
 | 
				
			||||||
    [[ -n "${HOMEBREW_QUIET}" ]] || echo "Already downloaded: ${CACHED_LOCATION}" >&2
 | 
					    [[ -n "${HOMEBREW_QUIET}" ]] || echo "Already downloaded: ${CACHED_LOCATION}" >&2
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    if [[ -f "${temporary_path}" ]]
 | 
					    for url in "${VENDOR_URLs[@]}"
 | 
				
			||||||
    then
 | 
					    do
 | 
				
			||||||
      # HOMEBREW_CURL is set by brew.sh (and isn't mispelt here)
 | 
					      [[ -n "${HOMEBREW_QUIET}" || -n "${first_try}" ]] || ohai "Downloading ${url}" >&2
 | 
				
			||||||
      # shellcheck disable=SC2153
 | 
					      first_try=''
 | 
				
			||||||
      "${HOMEBREW_CURL}" "${curl_args[@]}" -C - "${VENDOR_URL}" -o "${temporary_path}"
 | 
					      if [[ -f "${temporary_path}" ]]
 | 
				
			||||||
      if [[ $? -eq 33 ]]
 | 
					 | 
				
			||||||
      then
 | 
					      then
 | 
				
			||||||
        [[ -n "${HOMEBREW_QUIET}" ]] || echo "Trying a full download" >&2
 | 
					        # HOMEBREW_CURL is set by brew.sh (and isn't mispelt here)
 | 
				
			||||||
        rm -f "${temporary_path}"
 | 
					        # shellcheck disable=SC2153
 | 
				
			||||||
        "${HOMEBREW_CURL}" "${curl_args[@]}" "${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[@]}" "${url}" -o "${temporary_path}"
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        "${HOMEBREW_CURL}" "${curl_args[@]}" "${url}" -o "${temporary_path}"
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
    else
 | 
					
 | 
				
			||||||
      "${HOMEBREW_CURL}" "${curl_args[@]}" "${VENDOR_URL}" -o "${temporary_path}"
 | 
					      [[ -f "${temporary_path}" ]] && break
 | 
				
			||||||
    fi
 | 
					    done
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if [[ ! -f "${temporary_path}" ]]
 | 
					 | 
				
			||||||
    then
 | 
					 | 
				
			||||||
      [[ -n "${HOMEBREW_QUIET}" ]] || ohai "Downloading ${VENDOR_URL2}" >&2
 | 
					 | 
				
			||||||
      "${HOMEBREW_CURL}" "${curl_args[@]}" "${VENDOR_URL2}" -o "${temporary_path}"
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -f "${temporary_path}" ]]
 | 
					    if [[ ! -f "${temporary_path}" ]]
 | 
				
			||||||
    then
 | 
					    then
 | 
				
			||||||
 | 
					      vendor_locations="$(printf "  - %s\n" "${VENDOR_URLs[@]}")"
 | 
				
			||||||
      odie <<EOS
 | 
					      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
 | 
					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
 | 
					yourself what issue with your internet connection restricts your access to
 | 
				
			||||||
@ -263,11 +279,9 @@ homebrew-vendor-install() {
 | 
				
			|||||||
  filename_var="${VENDOR_NAME}_FILENAME"
 | 
					  filename_var="${VENDOR_NAME}_FILENAME"
 | 
				
			||||||
  sha_var="${VENDOR_NAME}_SHA"
 | 
					  sha_var="${VENDOR_NAME}_SHA"
 | 
				
			||||||
  url_var="${VENDOR_NAME}_URL"
 | 
					  url_var="${VENDOR_NAME}_URL"
 | 
				
			||||||
  url2_var="${VENDOR_NAME}_URL2"
 | 
					 | 
				
			||||||
  VENDOR_FILENAME="${!filename_var}"
 | 
					  VENDOR_FILENAME="${!filename_var}"
 | 
				
			||||||
  VENDOR_SHA="${!sha_var}"
 | 
					  VENDOR_SHA="${!sha_var}"
 | 
				
			||||||
  VENDOR_URL="${!url_var}"
 | 
					  VENDOR_URL="${!url_var}"
 | 
				
			||||||
  VENDOR_URL2="${!url2_var}"
 | 
					 | 
				
			||||||
  VENDOR_VERSION="$(<"${VENDOR_DIR}/portable-${VENDOR_NAME}-version")"
 | 
					  VENDOR_VERSION="$(<"${VENDOR_DIR}/portable-${VENDOR_NAME}-version")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [[ -z "${VENDOR_URL}" || -z "${VENDOR_SHA}" ]]
 | 
					  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!"
 | 
					    odie "No Homebrew ${VENDOR_NAME} ${VENDOR_VERSION} available for ${HOMEBREW_PROCESSOR} processors!"
 | 
				
			||||||
  fi
 | 
					  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}"
 | 
					  CACHED_LOCATION="${HOMEBREW_CACHE}/${VENDOR_FILENAME}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  lock "vendor-install-${VENDOR_NAME}"
 | 
					  lock "vendor-install-${VENDOR_NAME}"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user