Skip to content

Commit e18c47d

Browse files
authored
Merge pull request #2569 from rbenv/drop-default-mirror
Drop the default package mirror
2 parents 2f5f2fc + df045bd commit e18c47d

File tree

7 files changed

+12
-202
lines changed

7 files changed

+12
-202
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,3 @@ jobs:
2020
run: git clone --depth 1 --branch v1.10.0 https://github.com/bats-core/bats-core.git bats
2121
- name: Run tests
2222
run: PATH="./bats/bin:$PATH" script/test
23-
- name: Verify download URL checksums
24-
if: github.event_name == 'pull_request'
25-
run: ./script/mirror verify "$COMMIT_RANGE"
26-
env:
27-
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..

.github/workflows/mirror.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,15 @@ See the next section for more information on how to author checksums.
147147

148148
#### Package Mirrors
149149

150-
To speed up downloads, ruby-build fetches package files from a mirror hosted on
151-
Amazon CloudFront. To benefit from this, the packages must specify their checksum:
150+
You may specify a custom mirror by setting `RUBY_BUILD_MIRROR_URL`. When set,
151+
ruby-build will first attempt to download packages from the mirror before falling
152+
back to the original URL.
152153

153154
```sh
154155
# example:
156+
export RUBY_BUILD_MIRROR_URL="https://my-mirror.example.com"
155157
install_package "ruby-2.6.5" "https://ruby-lang.org/ruby-2.6.5.tgz#<SHA2>"
158+
# Will first try: https://my-mirror.example.com/<SHA2>
156159
```
157160

158161
ruby-build will first try to fetch this package from `$RUBY_BUILD_MIRROR_URL/<SHA2>`
@@ -164,15 +167,10 @@ will fall back to downloading the package from the original location if:
164167
- no tool is available to calculate the checksum; or
165168
- `RUBY_BUILD_SKIP_MIRROR` is enabled.
166169

167-
You may specify a custom mirror by setting `RUBY_BUILD_MIRROR_URL`.
168-
169170
If a mirror site doesn't conform to the above URL format, you can specify the
170171
complete URL by setting `RUBY_BUILD_MIRROR_PACKAGE_URL`. It behaves the same as
171172
`RUBY_BUILD_MIRROR_URL` except being a complete URL.
172173

173-
The default ruby-build download mirror is sponsored by
174-
[Basecamp](https://basecamp.com/).
175-
176174
#### Keeping the build directory after installation
177175

178176
Both `ruby-build` and `rbenv install` accept the `-k` or `--keep` flag, which

bin/ruby-build

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,7 @@ fetch_tarball() {
479479
package_url="${package_url%%#*}"
480480

481481
if [ -n "$RUBY_BUILD_MIRROR_URL" ]; then
482-
if [[ -z "$RUBY_BUILD_DEFAULT_MIRROR" || $package_url != */cache.ruby-lang.org/* ]]; then
483-
mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
484-
fi
482+
mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
485483
elif [ -n "$RUBY_BUILD_MIRROR_PACKAGE_URL" ]; then
486484
mirror_url="$RUBY_BUILD_MIRROR_PACKAGE_URL"
487485
fi
@@ -1579,12 +1577,8 @@ else
15791577
unset RUBY_BUILD_CACHE_PATH
15801578
fi
15811579

1582-
if [ -z "$RUBY_BUILD_MIRROR_URL" ] && [ -z "$RUBY_BUILD_MIRROR_PACKAGE_URL" ]; then
1583-
RUBY_BUILD_MIRROR_URL="https://dqw8nmjcqpjn7.cloudfront.net"
1584-
RUBY_BUILD_DEFAULT_MIRROR=1
1585-
else
1580+
if [ -n "$RUBY_BUILD_MIRROR_URL" ]; then
15861581
RUBY_BUILD_MIRROR_URL="${RUBY_BUILD_MIRROR_URL%/}"
1587-
RUBY_BUILD_DEFAULT_MIRROR=
15881582
fi
15891583

15901584
if [ -n "$RUBY_BUILD_SKIP_MIRROR" ] || ! has_checksum_support compute_sha2; then

script/mirror

Lines changed: 0 additions & 128 deletions
This file was deleted.

test/cache.bats

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ export RUBY_BUILD_CACHE_PATH="$TMP/cache"
5050
}
5151

5252

53-
@test "cached package with invalid checksum falls back to mirror and updates cache" {
53+
@test "cached package with invalid checksum falls back to original URL and updates cache" {
5454
export RUBY_BUILD_SKIP_MIRROR=
55+
export RUBY_BUILD_MIRROR_URL=
5556
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
5657

5758
stub shasum true "echo invalid" "echo $checksum"
58-
stub curl "-*I* : true" \
59-
"-q -fL -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"
59+
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
6060

6161
mkdir -p "$RUBY_BUILD_CACHE_PATH"
6262
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"

test/mirror.bats

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,12 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
8989
}
9090

9191

92-
@test "default mirror URL" {
92+
@test "no default mirror URL" {
9393
export RUBY_BUILD_MIRROR_URL=
9494
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
9595

9696
stub shasum true "echo $checksum"
97-
stub curl "-*I* : true" \
98-
"-q -fL -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \
97+
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
9998

10099
install_fixture definitions/with-checksum
101100

@@ -107,24 +106,6 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
107106
}
108107

109108

110-
@test "package URL with ruby-lang CDN with default mirror URL will bypasses mirror" {
111-
export RUBY_BUILD_MIRROR_URL=
112-
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
113-
114-
stub shasum true "echo $checksum"
115-
stub curl "-q -fL -o * https://cache.ruby-lang.org/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
116-
117-
run_inline_definition <<DEF
118-
install_package "package-1.0.0" "https://cache.ruby-lang.org/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
119-
DEF
120-
121-
assert_success
122-
assert [ -x "${INSTALL_ROOT}/bin/package" ]
123-
124-
unstub curl
125-
unstub shasum
126-
}
127-
128109

129110
@test "package is fetched from complete mirror URL" {
130111
export RUBY_BUILD_MIRROR_URL=

0 commit comments

Comments
 (0)