Loading README.md +27 −22 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ definitions. The build process may be configured through the following environment variables: | Variable | Function | | ------------------------ | ------------------------------------------------------------------------------------------------ | | ------------------------------- | ------------------------------------------------------------------------------------------------ | | `TMPDIR` | Where temporary files are stored. | | `RUBY_BUILD_BUILD_PATH` | Where sources are downloaded and built. (Default: a timestamped subdirectory of `TMPDIR`) | | `RUBY_BUILD_CACHE_PATH` | Where to cache downloaded package files. (Default: `~/.rbenv/cache` if invoked as rbenv plugin) | Loading @@ -74,6 +74,7 @@ The build process may be configured through the following environment variables: | `RUBY_BUILD_CURL_OPTS` | Additional options to pass to `curl` for downloading. | | `RUBY_BUILD_WGET_OPTS` | Additional options to pass to `wget` for downloading. | | `RUBY_BUILD_MIRROR_URL` | Custom mirror URL root. | | `RUBY_BUILD_MIRROR_PACKAGE_URL` | Custom complete mirror URL (e.g. http://mirror.example.com/package-1.0.0.tar.gz). | | `RUBY_BUILD_SKIP_MIRROR` | Bypass the download mirror and fetch all package files from their original URLs. | | `RUBY_BUILD_ROOT` | Custom build definition directory. (Default: `share/ruby-build`) | | `RUBY_BUILD_DEFINITIONS` | Additional paths to search for build definitions. (Colon-separated list) | Loading Loading @@ -134,6 +135,10 @@ will fall back to downloading the package from the original location if: You may specify a custom mirror by setting `RUBY_BUILD_MIRROR_URL`. If a mirror site doesn't conform to the above URL format, you can specify the complete URL by setting `RUBY_BUILD_MIRROR_PACKAGE_URL`. It behaves the same as `RUBY_BUILD_MIRROR_URL` except being a complete URL. The default ruby-build download mirror is sponsored by [Basecamp](https://basecamp.com/). Loading bin/ruby-build +4 −2 Original line number Diff line number Diff line Loading @@ -365,6 +365,8 @@ fetch_tarball() { if [[ -z "$RUBY_BUILD_DEFAULT_MIRROR" || $package_url != */cache.ruby-lang.org/* ]]; then mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum" fi elif [ -n "$RUBY_BUILD_MIRROR_PACKAGE_URL" ]; then mirror_url="$RUBY_BUILD_MIRROR_PACKAGE_URL" fi fi Loading Loading @@ -1409,7 +1411,7 @@ else unset RUBY_BUILD_CACHE_PATH fi if [ -z "$RUBY_BUILD_MIRROR_URL" ]; then if [ -z "$RUBY_BUILD_MIRROR_URL" -a -z "$RUBY_BUILD_MIRROR_PACKAGE_URL" ]; then RUBY_BUILD_MIRROR_URL="https://dqw8nmjcqpjn7.cloudfront.net" RUBY_BUILD_DEFAULT_MIRROR=1 else Loading @@ -1418,7 +1420,7 @@ else fi if [ -n "$RUBY_BUILD_SKIP_MIRROR" ] || ! has_checksum_support compute_sha2; then unset RUBY_BUILD_MIRROR_URL unset RUBY_BUILD_MIRROR_URL RUBY_BUILD_MIRROR_PACKAGE_URL fi ARIA2_OPTS="${RUBY_BUILD_ARIA2_OPTS} ${IPV4+--disable-ipv6=true} ${IPV6+--disable-ipv6=false}" Loading test/mirror.bats +59 −0 Original line number Diff line number Diff line Loading @@ -126,3 +126,62 @@ DEF unstub curl unstub shasum } @test "package is fetched from complete mirror URL" { export RUBY_BUILD_MIRROR_URL= export RUBY_BUILD_MIRROR_PACKAGE_URL=http://mirror.example.com/package-1.0.0.tar.gz local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : true" \ "-q -o * -*S* $RUBY_BUILD_MIRROR_PACKAGE_URL : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } @test "package is fetched from original URL if complete mirror URL download fails" { export RUBY_BUILD_MIRROR_URL= export RUBY_BUILD_MIRROR_PACKAGE_URL=http://mirror.example.com/package-1.0.0.tar.gz local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : false" \ "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } @test "package is fetched from original URL if complete mirror URL download checksum is invalid" { export RUBY_BUILD_MIRROR_URL= export RUBY_BUILD_MIRROR_PACKAGE_URL=http://mirror.example.com/package-1.0.0.tar.gz local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo invalid" "echo $checksum" stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : true" \ "-q -o * -*S* $RUBY_BUILD_MIRROR_PACKAGE_URL : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum echo "$output" >&2 assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } Loading
README.md +27 −22 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ definitions. The build process may be configured through the following environment variables: | Variable | Function | | ------------------------ | ------------------------------------------------------------------------------------------------ | | ------------------------------- | ------------------------------------------------------------------------------------------------ | | `TMPDIR` | Where temporary files are stored. | | `RUBY_BUILD_BUILD_PATH` | Where sources are downloaded and built. (Default: a timestamped subdirectory of `TMPDIR`) | | `RUBY_BUILD_CACHE_PATH` | Where to cache downloaded package files. (Default: `~/.rbenv/cache` if invoked as rbenv plugin) | Loading @@ -74,6 +74,7 @@ The build process may be configured through the following environment variables: | `RUBY_BUILD_CURL_OPTS` | Additional options to pass to `curl` for downloading. | | `RUBY_BUILD_WGET_OPTS` | Additional options to pass to `wget` for downloading. | | `RUBY_BUILD_MIRROR_URL` | Custom mirror URL root. | | `RUBY_BUILD_MIRROR_PACKAGE_URL` | Custom complete mirror URL (e.g. http://mirror.example.com/package-1.0.0.tar.gz). | | `RUBY_BUILD_SKIP_MIRROR` | Bypass the download mirror and fetch all package files from their original URLs. | | `RUBY_BUILD_ROOT` | Custom build definition directory. (Default: `share/ruby-build`) | | `RUBY_BUILD_DEFINITIONS` | Additional paths to search for build definitions. (Colon-separated list) | Loading Loading @@ -134,6 +135,10 @@ will fall back to downloading the package from the original location if: You may specify a custom mirror by setting `RUBY_BUILD_MIRROR_URL`. If a mirror site doesn't conform to the above URL format, you can specify the complete URL by setting `RUBY_BUILD_MIRROR_PACKAGE_URL`. It behaves the same as `RUBY_BUILD_MIRROR_URL` except being a complete URL. The default ruby-build download mirror is sponsored by [Basecamp](https://basecamp.com/). Loading
bin/ruby-build +4 −2 Original line number Diff line number Diff line Loading @@ -365,6 +365,8 @@ fetch_tarball() { if [[ -z "$RUBY_BUILD_DEFAULT_MIRROR" || $package_url != */cache.ruby-lang.org/* ]]; then mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum" fi elif [ -n "$RUBY_BUILD_MIRROR_PACKAGE_URL" ]; then mirror_url="$RUBY_BUILD_MIRROR_PACKAGE_URL" fi fi Loading Loading @@ -1409,7 +1411,7 @@ else unset RUBY_BUILD_CACHE_PATH fi if [ -z "$RUBY_BUILD_MIRROR_URL" ]; then if [ -z "$RUBY_BUILD_MIRROR_URL" -a -z "$RUBY_BUILD_MIRROR_PACKAGE_URL" ]; then RUBY_BUILD_MIRROR_URL="https://dqw8nmjcqpjn7.cloudfront.net" RUBY_BUILD_DEFAULT_MIRROR=1 else Loading @@ -1418,7 +1420,7 @@ else fi if [ -n "$RUBY_BUILD_SKIP_MIRROR" ] || ! has_checksum_support compute_sha2; then unset RUBY_BUILD_MIRROR_URL unset RUBY_BUILD_MIRROR_URL RUBY_BUILD_MIRROR_PACKAGE_URL fi ARIA2_OPTS="${RUBY_BUILD_ARIA2_OPTS} ${IPV4+--disable-ipv6=true} ${IPV6+--disable-ipv6=false}" Loading
test/mirror.bats +59 −0 Original line number Diff line number Diff line Loading @@ -126,3 +126,62 @@ DEF unstub curl unstub shasum } @test "package is fetched from complete mirror URL" { export RUBY_BUILD_MIRROR_URL= export RUBY_BUILD_MIRROR_PACKAGE_URL=http://mirror.example.com/package-1.0.0.tar.gz local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : true" \ "-q -o * -*S* $RUBY_BUILD_MIRROR_PACKAGE_URL : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } @test "package is fetched from original URL if complete mirror URL download fails" { export RUBY_BUILD_MIRROR_URL= export RUBY_BUILD_MIRROR_PACKAGE_URL=http://mirror.example.com/package-1.0.0.tar.gz local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : false" \ "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } @test "package is fetched from original URL if complete mirror URL download checksum is invalid" { export RUBY_BUILD_MIRROR_URL= export RUBY_BUILD_MIRROR_PACKAGE_URL=http://mirror.example.com/package-1.0.0.tar.gz local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo invalid" "echo $checksum" stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : true" \ "-q -o * -*S* $RUBY_BUILD_MIRROR_PACKAGE_URL : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum echo "$output" >&2 assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum }