Skip to content

Commit

Permalink
Merge pull request #17295 from Homebrew/artifact_domain_no_fallback
Browse files Browse the repository at this point in the history
Add HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK
  • Loading branch information
carlocab committed May 14, 2024
2 parents 960b1eb + a37864d commit 909e650
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Library/Homebrew/cmd/vendor-install.sh
Expand Up @@ -47,6 +47,11 @@ set_ruby_variables() {
if [[ -n "${HOMEBREW_ARTIFACT_DOMAIN}" ]]
then
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
if [[ -n "${HOMEBREW_BOTTLE_DOMAIN}" ]]
then
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/download_strategy.rb
Expand Up @@ -405,6 +405,7 @@ def fetch(timeout: nil)

if (domain = Homebrew::EnvConfig.artifact_domain)
url = url.sub(%r{^https?://#{GitHubPackages::URL_DOMAIN}/}o, "#{domain.chomp("/")}/")
urls = [] if Homebrew::EnvConfig.artifact_domain_no_fallback?
end

ohai "Downloading #{url}"
Expand Down
6 changes: 6 additions & 0 deletions Library/Homebrew/env_config.rb
Expand Up @@ -44,6 +44,12 @@ module EnvConfig
"to instead be downloaded from " \
"`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: {
description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \
"e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, " \
Expand Down
6 changes: 5 additions & 1 deletion Library/Homebrew/resource.rb
Expand Up @@ -237,8 +237,12 @@ def determine_url_mirrors
# glibc-bootstrap
if url.start_with?("https://github.com/Homebrew/glibc-bootstrap/releases/download")
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

if Homebrew::EnvConfig.bottle_domain != HOMEBREW_BOTTLE_DEFAULT_DOMAIN
tag, filename = url.split("/").last(2)
extra_urls << "#{Homebrew::EnvConfig.bottle_domain}/glibc-bootstrap/#{tag}/#{filename}"
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/Manpage.md
Expand Up @@ -3510,6 +3510,12 @@ command execution e.g. `$(cat file)`.
downloaded from
`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`

: Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some
Expand Down
3 changes: 3 additions & 0 deletions manpages/brew.1
Expand Up @@ -2244,6 +2244,9 @@ Linux only: Pass this value to a type name representing the compiler\[u2019]s \f
\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
.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
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
Expand Down

0 comments on commit 909e650

Please sign in to comment.