diff --git a/bin/ruby-build b/bin/ruby-build index f4692754a0..ade6e6a955 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -432,11 +432,9 @@ fetch_tarball() { local tarball_filename="$(basename "$package_url")" log_info "Downloading ${tarball_filename}..." # Explicitly connect downloader utilities to the original stderr. - if http head "$mirror_url"; then - download_tarball "$mirror_url" "$package_filename" "$checksum" 2>&3 - else + http head "$mirror_url" && + download_tarball "$mirror_url" "$package_filename" "$checksum" 2>&3 || download_tarball "$package_url" "$package_filename" "$checksum" 2>&3 - fi fi if log_command tar $tar_args "$package_filename" >/dev/null; then diff --git a/test/build.bats b/test/build.bats index 44e86a6953..a791d5e012 100755 --- a/test/build.bats +++ b/test/build.bats @@ -721,7 +721,8 @@ DEF @test "TruffleRuby post-install hook" { rmdir "$INSTALL_ROOT" executable "${RUBY_BUILD_CACHE_PATH}/truffleruby-test/lib/truffle/post_install_hook.sh" <&2 assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] @@ -23,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com @test "package URL with checksum but no shasum support bypasses mirror" { stub shasum false - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4" install_fixture definitions/with-checksum @@ -41,7 +40,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com stub shasum true "echo $checksum" stub curl "-*I* $mirror_url : true" \ - "-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" + "-q -fL -o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" install_fixture definitions/with-checksum @@ -59,7 +58,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com stub shasum true "echo $checksum" stub curl "-*I* $mirror_url : false" \ - "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4" install_fixture definitions/with-checksum @@ -77,11 +76,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com stub shasum true "echo invalid" "echo $checksum" stub curl "-*I* $mirror_url : true" \ - "-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ - "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + "-q -fL -o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \ + "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4" install_fixture definitions/with-checksum - echo "$output" >&2 assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] @@ -97,7 +95,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com stub shasum true "echo $checksum" stub curl "-*I* : true" \ - "-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ + "-q -fL -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \ install_fixture definitions/with-checksum @@ -114,7 +112,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" - stub curl "-q -o * -*S* https://cache.ruby-lang.org/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub curl "-q -fL -o * https://cache.ruby-lang.org/* : cp $FIXTURE_ROOT/\${5##*/} \$4" run_inline_definition <&2 assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ]