Merge pull request #17295 from Homebrew/artifact_domain_no_fallback

Add HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK
This commit is contained in:
Carlo Cabrera 2024-05-14 21:21:20 +08:00 committed by GitHub
commit 909e650668
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 29 additions and 1 deletions

View File

@ -47,6 +47,11 @@ set_ruby_variables() {
if [[ -n "${HOMEBREW_ARTIFACT_DOMAIN}" ]] if [[ -n "${HOMEBREW_ARTIFACT_DOMAIN}" ]]
then then
ruby_URLs+=("${HOMEBREW_ARTIFACT_DOMAIN}/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}") ruby_URLs+=("${HOMEBREW_ARTIFACT_DOMAIN}/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}")
if [[ -n "${HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK}" ]]
then
ruby_URL="${ruby_URLs[0]}"
return
fi
fi fi
if [[ -n "${HOMEBREW_BOTTLE_DOMAIN}" ]] if [[ -n "${HOMEBREW_BOTTLE_DOMAIN}" ]]
then then

View File

@ -405,6 +405,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
if (domain = Homebrew::EnvConfig.artifact_domain) if (domain = Homebrew::EnvConfig.artifact_domain)
url = url.sub(%r{^https?://#{GitHubPackages::URL_DOMAIN}/}o, "#{domain.chomp("/")}/") url = url.sub(%r{^https?://#{GitHubPackages::URL_DOMAIN}/}o, "#{domain.chomp("/")}/")
urls = [] if Homebrew::EnvConfig.artifact_domain_no_fallback?
end end
ohai "Downloading #{url}" ohai "Downloading #{url}"

View File

@ -44,6 +44,12 @@ module Homebrew
"to instead be downloaded from " \ "to instead be downloaded from " \
"`http://localhost:8080/v2/homebrew/core/gettext/manifests/0.21`", "`http://localhost:8080/v2/homebrew/core/gettext/manifests/0.21`",
}, },
HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK: {
description: "If `HOMEBREW_ARTIFACT_DOMAIN` and `HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK` are both set, " \
"if the request to `HOMEBREW_ARTIFACT_DOMAIN` fails then it Homebrew will error rather than " \
"trying any other/default URLs.",
boolean: true,
},
HOMEBREW_AUTO_UPDATE_SECS: { HOMEBREW_AUTO_UPDATE_SECS: {
description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \ description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \
"e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, " \ "e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, " \

View File

@ -237,8 +237,12 @@ class Resource < Downloadable
# glibc-bootstrap # glibc-bootstrap
if url.start_with?("https://github.com/Homebrew/glibc-bootstrap/releases/download") if url.start_with?("https://github.com/Homebrew/glibc-bootstrap/releases/download")
if (artifact_domain = Homebrew::EnvConfig.artifact_domain.presence) if (artifact_domain = Homebrew::EnvConfig.artifact_domain.presence)
extra_urls << url.sub("https://github.com", artifact_domain) artifact_url = url.sub("https://github.com", artifact_domain)
return [artifact_url] if Homebrew::EnvConfig.artifact_domain_no_fallback?
extra_urls << artifact_url
end end
if Homebrew::EnvConfig.bottle_domain != HOMEBREW_BOTTLE_DEFAULT_DOMAIN if Homebrew::EnvConfig.bottle_domain != HOMEBREW_BOTTLE_DEFAULT_DOMAIN
tag, filename = url.split("/").last(2) tag, filename = url.split("/").last(2)
extra_urls << "#{Homebrew::EnvConfig.bottle_domain}/glibc-bootstrap/#{tag}/#{filename}" extra_urls << "#{Homebrew::EnvConfig.bottle_domain}/glibc-bootstrap/#{tag}/#{filename}"

View File

@ -25,6 +25,9 @@ module Homebrew::EnvConfig
sig { returns(T.nilable(::String)) } sig { returns(T.nilable(::String)) }
def artifact_domain; end def artifact_domain; end
sig { returns(T::Boolean) }
def artifact_domain_no_fallback?; end
sig { returns(T.nilable(::String)) } sig { returns(T.nilable(::String)) }
def auto_update_secs; end def auto_update_secs; end

View File

@ -3510,6 +3510,12 @@ command execution e.g. `$(cat file)`.
downloaded from downloaded from
`http://localhost:8080/v2/homebrew/core/gettext/manifests/0.21` `http://localhost:8080/v2/homebrew/core/gettext/manifests/0.21`
`HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK`
: If `HOMEBREW_ARTIFACT_DOMAIN` and `HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK` are
both set, if the request to `HOMEBREW_ARTIFACT_DOMAIN` fails then it Homebrew
will error rather than trying any other/default URLs.
`HOMEBREW_AUTO_UPDATE_SECS` `HOMEBREW_AUTO_UPDATE_SECS`
: Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some : Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some

View File

@ -2244,6 +2244,9 @@ Linux only: Pass this value to a type name representing the compiler\[u2019]s \f
\fBHOMEBREW_ARTIFACT_DOMAIN\fP \fBHOMEBREW_ARTIFACT_DOMAIN\fP
Prefix all download URLs, including those for bottles, with this value\. For example, \fBHOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080\fP will cause a formula with the URL \fBhttps://example\.com/foo\.tar\.gz\fP to instead download from \fBhttp://localhost:8080/https://example\.com/foo\.tar\.gz\fP\&\. Bottle URLs however, have their domain replaced with this prefix\. This results in e\.g\. \fBhttps://ghcr\.io/v2/homebrew/core/gettext/manifests/0\.21\fP to instead be downloaded from \fBhttp://localhost:8080/v2/homebrew/core/gettext/manifests/0\.21\fP Prefix all download URLs, including those for bottles, with this value\. For example, \fBHOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080\fP will cause a formula with the URL \fBhttps://example\.com/foo\.tar\.gz\fP to instead download from \fBhttp://localhost:8080/https://example\.com/foo\.tar\.gz\fP\&\. Bottle URLs however, have their domain replaced with this prefix\. This results in e\.g\. \fBhttps://ghcr\.io/v2/homebrew/core/gettext/manifests/0\.21\fP to instead be downloaded from \fBhttp://localhost:8080/v2/homebrew/core/gettext/manifests/0\.21\fP
.TP .TP
\fBHOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK\fP
If \fBHOMEBREW_ARTIFACT_DOMAIN\fP and \fBHOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK\fP are both set, if the request to \fBHOMEBREW_ARTIFACT_DOMAIN\fP fails then it Homebrew will error rather than trying any other/default URLs\.
.TP
\fBHOMEBREW_AUTO_UPDATE_SECS\fP \fBHOMEBREW_AUTO_UPDATE_SECS\fP
Run \fBbrew update\fP once every \fBHOMEBREW_AUTO_UPDATE_SECS\fP seconds before some commands, e\.g\. \fBbrew install\fP, \fBbrew upgrade\fP and \fBbrew tap\fP\&\. Alternatively, disable auto\-update entirely with \fBHOMEBREW_NO_AUTO_UPDATE\fP\&\. Run \fBbrew update\fP once every \fBHOMEBREW_AUTO_UPDATE_SECS\fP seconds before some commands, e\.g\. \fBbrew install\fP, \fBbrew upgrade\fP and \fBbrew tap\fP\&\. Alternatively, disable auto\-update entirely with \fBHOMEBREW_NO_AUTO_UPDATE\fP\&\.
.RS .RS