Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vendor-install.sh: allow download vendors from HOMEBREW_ARTIFACT_DOMAIN and HOMEBREW_BOTTLE_DOMAIN #12042

Merged
merged 2 commits into from Sep 12, 2021

Conversation

XuehaiPan
Copy link
Contributor

@XuehaiPan XuehaiPan commented Sep 12, 2021

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

PR #11070 drops the support for users to download portable-ruby from HOMEBREW_BOTTLE_DOMAIN. Users cannot use geolocalized mirrors to speed up downloading and only packages host on GitHub are supported. (Ref tuna/issues#1224 (comment) and tuna/mirror-web#292 (comment))

This PR takes the URL from HOMEBREW_BOTTLE_DOMAIN back and adds the URL from HOMEBREW_ARTIFACT_DOMAIN (as documented for this environment variable).

This implementation may be a bit tricky to use the eval statement to expand an array from the name.

# Expand the name to an array of variables
# The array name must be "${VENDOR_NAME}_URLs"! Otherwise substitution errors will occur!
read -r -a VENDOR_URLs <<< "$(eval "echo "\$\{${VENDOR_NAME}_URLs[@]\}"")"

Some tests:

  • Unset HOMEBREW_ARTIFACT_DOMAIN and HOMEBREW_BOTTLE_DOMAIN:
$ brew cleanup -s --prune 0
Removing: /home/PanXuehai/.cache/Homebrew/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz... (10.4MB)

$ unset HOMEBREW_{ARTIFACT,BOTTLE}_DOMAIN

$ brew vendor-install ruby 
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:97e639a64dcec285392b53ad804b5334c324f1d2a8bdc2b5087b8bf8051e332f
################################################################################ 100.0%
==> Pouring portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
  • Invalid HOMEBREW_ARTIFACT_DOMAIN and HOMEBREW_BOTTLE_DOMAIN:
$ brew cleanup -s --prune 0
Removing: /home/PanXuehai/.cache/Homebrew/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz... (10.4MB)

$ export HOMEBREW_ARTIFACT_DOMAIN="https://localhost:10000"  # a invalid URL
$ export HOMEBREW_BOTTLE_DOMAIN="https://localhost:20000"  # a invalid URL

$ brew vendor-install ruby 
==> Downloading https://localhost:10000/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
curl: (35) OpenSSL SSL_connect: Connection reset by peer in connection to localhost:10000

==> Downloading https://localhost:20000/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
curl: (35) OpenSSL SSL_connect: Connection reset by peer in connection to localhost:20000

==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:97e639a64dcec285392b53ad804b5334c324f1d2a8bdc2b5087b8bf8051e332f
################################################################################ 100.0%
==> Pouring portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
  • Valid HOMEBREW_BOTTLE_DOMAIN:
$ brew cleanup -s --prune 0
Removing: /home/PanXuehai/.cache/Homebrew/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz... (10.4MB)

$ export HOMEBREW_ARTIFACT_DOMAIN="https://localhost:10000"  # a invalid URL
$ export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles"

$ brew vendor-install ruby 
==> Downloading https://localhost:10000/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
curl: (35) OpenSSL SSL_connect: Connection reset by peer in connection to localhost:10000

==> Downloading https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
################################################################################ 100.0%
==> Pouring portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz

$ brew vendor-install ruby
==> Downloading https://localhost:10000/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
Already downloaded: /home/PanXuehai/.cache/Homebrew/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
==> Pouring portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz

$ unset HOMEBREW_ARTIFACT_DOMAIN

$ brew vendor-install ruby
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
Already downloaded: /home/PanXuehai/.cache/Homebrew/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
==> Pouring portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz

$ brew cleanup -s --prune 0
Removing: /home/PanXuehai/.cache/Homebrew/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz... (10.4MB)

$ brew vendor-install ruby 
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
################################################################################ 100.0%
==> Pouring portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
  • All fails:
$ brew cleanup -s --prune 0
Removing: /home/PanXuehai/.cache/Homebrew/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz... (10.4MB)

$ export HOMEBREW_ARTIFACT_DOMAIN="https://localhost:10000"  # a invalid URL
$ export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles"

$ export http_proxy="http://localhost:20000"  # a invalid Proxy
$ export https_proxy="http://localhost:20000"  # a invalid Proxy

$ brew vendor-install ruby 
==> Downloading https://localhost:10000/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
curl: (7) Failed to connect to localhost port 20000: Connection refused

==> Downloading https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
curl: (7) Failed to connect to localhost port 20000: Connection refused

==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:97e639a64dcec285392b53ad804b5334c324f1d2a8bdc2b5087b8bf8051e332f
curl: (7) Failed to connect to localhost port 20000: Connection refused

==> Downloading https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3_2/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
curl: (7) Failed to connect to localhost port 20000: Connection refused

Error: Failed to download ruby from the following locations:
  - https://localhost:10000/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
  - https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
  - https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:97e639a64dcec285392b53ad804b5334c324f1d2a8bdc2b5087b8bf8051e332f
  - https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3_2/portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz

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
GitHub (used for Homebrew updates and binary packages).

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @XuehaiPan!

@MikeMcQuaid MikeMcQuaid merged commit 1fd1455 into Homebrew:master Sep 12, 2021
@XuehaiPan XuehaiPan deleted the vendor-from-bottle-domain branch September 13, 2021 01:41
@github-actions github-actions bot added the outdated PR was locked due to age label Oct 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants