Loading bin/ruby-build +18 −2 Original line number Diff line number Diff line Loading @@ -300,16 +300,32 @@ http() { local file="$3" [ -n "$url" ] || return 1 if type curl &>/dev/null; then if type aria2c &>/dev/null; then "http_${method}_aria2c" "$url" "$file" elif type curl &>/dev/null; then "http_${method}_curl" "$url" "$file" elif type wget &>/dev/null; then "http_${method}_wget" "$url" "$file" else echo "error: please install \`curl\` or \`wget\` and try again" >&2 echo "error: please install \`aria2c\`, \`curl\` or \`wget\` and try again" >&2 exit 1 fi } http_head_aria2c() { options="" [ -n "${IPV4}" ] && options="--disable-ipv6=true" [ -n "${IPV6}" ] && options="--disable-ipv6=false" aria2c --dry-run ${options} "$1" >&4 2>&1 } http_get_aria2c() { options="" [ -n "${IPV4}" ] && options="--disable-ipv6=true" [ -n "${IPV6}" ] && options="--disable-ipv6=false" aria2c -o "${2:--}" ${options} "$1" } http_head_curl() { options="" [ -n "${IPV4}" ] && options="--ipv4" Loading test/build.bats +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ export -n RUBY_CONFIGURE_OPTS setup() { mkdir -p "$INSTALL_ROOT" stub md5 false stub curl false stub aria2c false } executable() { Loading test/cache.bats +11 −11 Original line number Diff line number Diff line Loading @@ -10,19 +10,19 @@ setup() { @test "packages are saved to download cache" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/without-checksum assert_success assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub aria2c } @test "cached package without checksum" { stub curl stub aria2c cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH" Loading @@ -31,13 +31,13 @@ setup() { assert_success assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub aria2c } @test "cached package with valid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl stub aria2c cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH" Loading @@ -47,7 +47,7 @@ setup() { assert [ -x "${INSTALL_ROOT}/bin/package" ] assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub aria2c unstub shasum } Loading @@ -57,8 +57,8 @@ setup() { local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo invalid" "echo $checksum" stub curl "-*I* : true" \ "-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" stub aria2c "--dry-run * : true" \ "-o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2" touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" Loading @@ -69,13 +69,13 @@ setup() { assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] assert diff -q "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz" unstub curl unstub aria2c unstub shasum } @test "nonexistent cache directory is ignored" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent" Loading @@ -85,5 +85,5 @@ setup() { assert [ -x "${INSTALL_ROOT}/bin/package" ] refute [ -d "$RUBY_BUILD_CACHE_PATH" ] unstub curl unstub aria2c } test/checksum.bats +17 −17 Original line number Diff line number Diff line Loading @@ -6,103 +6,103 @@ export RUBY_BUILD_CACHE_PATH= @test "package URL without checksum" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/without-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c } @test "package URL with valid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub shasum } @test "package URL with invalid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-invalid-checksum assert_failure refute [ -f "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub shasum } @test "package URL with checksum but no shasum support" { stub shasum false stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub shasum } @test "package URL with valid md5 checksum" { stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-md5-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub md5 } @test "package URL with md5 checksum but no md5 support" { stub md5 false stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-md5-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub md5 } @test "package with invalid checksum" { stub shasum true "echo invalid" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum assert_failure refute [ -f "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub shasum } @test "existing tarball in build location is reused" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl false stub aria2c false stub wget false export -n RUBY_BUILD_CACHE_PATH Loading @@ -125,7 +125,7 @@ DEF stub shasum true \ "echo invalid" \ "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" export -n RUBY_BUILD_CACHE_PATH export RUBY_BUILD_BUILD_PATH="${TMP}/build" Loading @@ -144,7 +144,7 @@ DEF } @test "package URL with checksum of unexpected length" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" run_inline_definition <<DEF install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#checksum_of_unexpected_length" copy Loading test/fetch.bats +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ setup() { } @test "failed download displays error message" { stub curl false stub aria2c false install_fixture definitions/without-checksum assert_failure Loading Loading
bin/ruby-build +18 −2 Original line number Diff line number Diff line Loading @@ -300,16 +300,32 @@ http() { local file="$3" [ -n "$url" ] || return 1 if type curl &>/dev/null; then if type aria2c &>/dev/null; then "http_${method}_aria2c" "$url" "$file" elif type curl &>/dev/null; then "http_${method}_curl" "$url" "$file" elif type wget &>/dev/null; then "http_${method}_wget" "$url" "$file" else echo "error: please install \`curl\` or \`wget\` and try again" >&2 echo "error: please install \`aria2c\`, \`curl\` or \`wget\` and try again" >&2 exit 1 fi } http_head_aria2c() { options="" [ -n "${IPV4}" ] && options="--disable-ipv6=true" [ -n "${IPV6}" ] && options="--disable-ipv6=false" aria2c --dry-run ${options} "$1" >&4 2>&1 } http_get_aria2c() { options="" [ -n "${IPV4}" ] && options="--disable-ipv6=true" [ -n "${IPV6}" ] && options="--disable-ipv6=false" aria2c -o "${2:--}" ${options} "$1" } http_head_curl() { options="" [ -n "${IPV4}" ] && options="--ipv4" Loading
test/build.bats +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ export -n RUBY_CONFIGURE_OPTS setup() { mkdir -p "$INSTALL_ROOT" stub md5 false stub curl false stub aria2c false } executable() { Loading
test/cache.bats +11 −11 Original line number Diff line number Diff line Loading @@ -10,19 +10,19 @@ setup() { @test "packages are saved to download cache" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/without-checksum assert_success assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub aria2c } @test "cached package without checksum" { stub curl stub aria2c cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH" Loading @@ -31,13 +31,13 @@ setup() { assert_success assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub aria2c } @test "cached package with valid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl stub aria2c cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH" Loading @@ -47,7 +47,7 @@ setup() { assert [ -x "${INSTALL_ROOT}/bin/package" ] assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub aria2c unstub shasum } Loading @@ -57,8 +57,8 @@ setup() { local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo invalid" "echo $checksum" stub curl "-*I* : true" \ "-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" stub aria2c "--dry-run * : true" \ "-o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2" touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" Loading @@ -69,13 +69,13 @@ setup() { assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] assert diff -q "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz" unstub curl unstub aria2c unstub shasum } @test "nonexistent cache directory is ignored" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent" Loading @@ -85,5 +85,5 @@ setup() { assert [ -x "${INSTALL_ROOT}/bin/package" ] refute [ -d "$RUBY_BUILD_CACHE_PATH" ] unstub curl unstub aria2c }
test/checksum.bats +17 −17 Original line number Diff line number Diff line Loading @@ -6,103 +6,103 @@ export RUBY_BUILD_CACHE_PATH= @test "package URL without checksum" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/without-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c } @test "package URL with valid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub shasum } @test "package URL with invalid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-invalid-checksum assert_failure refute [ -f "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub shasum } @test "package URL with checksum but no shasum support" { stub shasum false stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub shasum } @test "package URL with valid md5 checksum" { stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-md5-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub md5 } @test "package URL with md5 checksum but no md5 support" { stub md5 false stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-md5-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub md5 } @test "package with invalid checksum" { stub shasum true "echo invalid" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum assert_failure refute [ -f "${INSTALL_ROOT}/bin/package" ] unstub curl unstub aria2c unstub shasum } @test "existing tarball in build location is reused" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl false stub aria2c false stub wget false export -n RUBY_BUILD_CACHE_PATH Loading @@ -125,7 +125,7 @@ DEF stub shasum true \ "echo invalid" \ "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" export -n RUBY_BUILD_CACHE_PATH export RUBY_BUILD_BUILD_PATH="${TMP}/build" Loading @@ -144,7 +144,7 @@ DEF } @test "package URL with checksum of unexpected length" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" run_inline_definition <<DEF install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#checksum_of_unexpected_length" copy Loading
test/fetch.bats +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ setup() { } @test "failed download displays error message" { stub curl false stub aria2c false install_fixture definitions/without-checksum assert_failure Loading