Loading bin/ruby-build +18 −28 Original line number Diff line number Diff line Loading @@ -246,6 +246,12 @@ compute_md5() { fi } declare -a HAS_CHECKSUM_SUPPORT has_checksum_support() { local checksum_command="$1" return ${HAS_CHECKSUM_SUPPORT[$checksum_command]:=$(echo test | "$checksum_command" >/dev/null; echo $?)} } verify_checksum() { local checksum_command local filename="$1" Loading @@ -255,22 +261,19 @@ verify_checksum() { [ -e "$filename" ] || return 0 case "${#expected_checksum}" in 0) # If there's no expected checksum, return success return 0 ;; 32) # MD5 [ -n "$HAS_MD5_SUPPORT" ] || return 0 checksum_command="compute_md5" ;; 64) # SHA2 256 [ -n "$HAS_SHA2_SUPPORT" ] || return 0 checksum_command="compute_sha2" ;; *) # unknown checksum algorithm, return failure return 1 ;; # If expected checksum is empty, return success 0) return 0 ;; # MD5 32) checksum_command="compute_md5" ;; # SHA2 256 64) checksum_command="compute_sha2" ;; # unknown checksum algorithm, return failure *) return 1 ;; esac # If chosen provided checksum algorithm isn't supported, return success has_checksum_support "$checksum_command" || return 0 # If the computed checksum is empty, return failure local computed_checksum=`echo "$($checksum_command < "$filename")" | tr [A-Z] [a-z]` [ -n "$computed_checksum" ] || return 1 Loading Loading @@ -1225,23 +1228,10 @@ else RUBY_BUILD_DEFAULT_MIRROR= fi if [ -n "$RUBY_BUILD_SKIP_MIRROR" ]; then unset RUBY_BUILD_MIRROR_URL fi if echo test | compute_sha2 >/dev/null; then HAS_SHA2_SUPPORT=1 else unset HAS_SHA2_SUPPORT if [ -n "$RUBY_BUILD_SKIP_MIRROR" ] || ! has_checksum_support compute_sha2; then unset RUBY_BUILD_MIRROR_URL fi if echo test | compute_md5 >/dev/null; then HAS_MD5_SUPPORT=1 else unset HAS_MD5_SUPPORT fi SEED="$(date "+%Y%m%d%H%M%S").$$" LOG_PATH="${TMP}/ruby-build.${SEED}.log" RUBY_BIN="${PREFIX_PATH}/bin/ruby" Loading test/cache.bats +0 −6 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ setup() { @test "packages are saved to download cache" { stub shasum true stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/without-checksum Loading @@ -19,12 +18,10 @@ setup() { [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub shasum } @test "cached package without checksum" { stub shasum true stub curl cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH" Loading @@ -35,7 +32,6 @@ setup() { [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub shasum } Loading Loading @@ -79,7 +75,6 @@ setup() { @test "nonexistent cache directory is ignored" { stub shasum true stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent" Loading @@ -91,5 +86,4 @@ setup() { [ ! -d "$RUBY_BUILD_CACHE_PATH" ] unstub curl unstub shasum } test/checksum.bats +0 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ export RUBY_BUILD_CACHE_PATH= @test "package URL without checksum" { stub shasum true stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/without-checksum Loading @@ -14,7 +13,6 @@ export RUBY_BUILD_CACHE_PATH= [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } Loading Loading
bin/ruby-build +18 −28 Original line number Diff line number Diff line Loading @@ -246,6 +246,12 @@ compute_md5() { fi } declare -a HAS_CHECKSUM_SUPPORT has_checksum_support() { local checksum_command="$1" return ${HAS_CHECKSUM_SUPPORT[$checksum_command]:=$(echo test | "$checksum_command" >/dev/null; echo $?)} } verify_checksum() { local checksum_command local filename="$1" Loading @@ -255,22 +261,19 @@ verify_checksum() { [ -e "$filename" ] || return 0 case "${#expected_checksum}" in 0) # If there's no expected checksum, return success return 0 ;; 32) # MD5 [ -n "$HAS_MD5_SUPPORT" ] || return 0 checksum_command="compute_md5" ;; 64) # SHA2 256 [ -n "$HAS_SHA2_SUPPORT" ] || return 0 checksum_command="compute_sha2" ;; *) # unknown checksum algorithm, return failure return 1 ;; # If expected checksum is empty, return success 0) return 0 ;; # MD5 32) checksum_command="compute_md5" ;; # SHA2 256 64) checksum_command="compute_sha2" ;; # unknown checksum algorithm, return failure *) return 1 ;; esac # If chosen provided checksum algorithm isn't supported, return success has_checksum_support "$checksum_command" || return 0 # If the computed checksum is empty, return failure local computed_checksum=`echo "$($checksum_command < "$filename")" | tr [A-Z] [a-z]` [ -n "$computed_checksum" ] || return 1 Loading Loading @@ -1225,23 +1228,10 @@ else RUBY_BUILD_DEFAULT_MIRROR= fi if [ -n "$RUBY_BUILD_SKIP_MIRROR" ]; then unset RUBY_BUILD_MIRROR_URL fi if echo test | compute_sha2 >/dev/null; then HAS_SHA2_SUPPORT=1 else unset HAS_SHA2_SUPPORT if [ -n "$RUBY_BUILD_SKIP_MIRROR" ] || ! has_checksum_support compute_sha2; then unset RUBY_BUILD_MIRROR_URL fi if echo test | compute_md5 >/dev/null; then HAS_MD5_SUPPORT=1 else unset HAS_MD5_SUPPORT fi SEED="$(date "+%Y%m%d%H%M%S").$$" LOG_PATH="${TMP}/ruby-build.${SEED}.log" RUBY_BIN="${PREFIX_PATH}/bin/ruby" Loading
test/cache.bats +0 −6 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ setup() { @test "packages are saved to download cache" { stub shasum true stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/without-checksum Loading @@ -19,12 +18,10 @@ setup() { [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub shasum } @test "cached package without checksum" { stub shasum true stub curl cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH" Loading @@ -35,7 +32,6 @@ setup() { [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] unstub curl unstub shasum } Loading Loading @@ -79,7 +75,6 @@ setup() { @test "nonexistent cache directory is ignored" { stub shasum true stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent" Loading @@ -91,5 +86,4 @@ setup() { [ ! -d "$RUBY_BUILD_CACHE_PATH" ] unstub curl unstub shasum }
test/checksum.bats +0 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ export RUBY_BUILD_CACHE_PATH= @test "package URL without checksum" { stub shasum true stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/without-checksum Loading @@ -14,7 +13,6 @@ export RUBY_BUILD_CACHE_PATH= [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } Loading