Skip to content

Commit

Permalink
Merge pull request #326 from quark-zju/keep-downloaded-tarball
Browse files Browse the repository at this point in the history
Keep downloaded tarball sometimes
  • Loading branch information
sferik committed Mar 25, 2013
2 parents 386b376 + 3d2f1a7 commit 1fb955e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,13 @@ verify_checksum() {
http() {
local method="$1"
local url="$2"
local file="$3"
[ -n "$url" ] || return 1

if type curl &>/dev/null; then
"http_${method}_curl" "$url"
"http_${method}_curl" "$url" "$file"
elif type wget &>/dev/null; then
"http_${method}_wget" "$url"
"http_${method}_wget" "$url" "$file"
else
echo "error: please install \`curl\` or \`wget\` and try again" >&2
exit 1
Expand All @@ -205,15 +206,15 @@ http_head_curl() {
}

http_get_curl() {
curl -qsSLf "$1"
curl -C - -o "${2:--}" -qsSLf "$1"
}

http_head_wget() {
wget -q --spider "$1" >&4 2>&1
}

http_get_wget() {
wget -nv -O- "$1"
wget -nv -c -O "${2:--}" "$1"
}

fetch_tarball() {
Expand All @@ -240,8 +241,13 @@ fetch_tarball() {
download_tarball "$package_url" "$package_filename" "$checksum"
}

{ tar xzvf "$package_filename"
rm -f "$package_filename"
{ if tar xzvf "$package_filename"; then
if [ -z "$KEEP_BUILD_PATH" ]; then
rm -f "$package_filename"
else
true
fi
fi
} >&4 2>&1
}

Expand All @@ -266,7 +272,7 @@ download_tarball() {

echo "-> $package_url" >&2

{ http get "$package_url" > "$package_filename"
{ http get "$package_url" "$package_filename"
verify_checksum "$package_filename" "$checksum"
} >&4 2>&1 || return 1

Expand Down

0 comments on commit 1fb955e

Please sign in to comment.