From d0912e4fb550490423af42954b715be2f15370ec Mon Sep 17 00:00:00 2001 From: WU Jun Date: Tue, 12 Mar 2013 16:40:13 +0800 Subject: [PATCH 1/2] use --continue when downloading tarball --- bin/ruby-build | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index 47914219..a7fb4362 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -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 @@ -205,7 +206,7 @@ http_head_curl() { } http_get_curl() { - curl -qsSLf "$1" + curl -C - -o "${2:--}" -qsSLf "$1" } http_head_wget() { @@ -213,7 +214,7 @@ http_head_wget() { } http_get_wget() { - wget -nv -O- "$1" + wget -nv -c -O "${2:--}" "$1" } fetch_tarball() { @@ -266,7 +267,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 From 3d2f1a72775e00f7256355ca15792928926da0aa Mon Sep 17 00:00:00 2001 From: WU Jun Date: Tue, 12 Mar 2013 16:49:17 +0800 Subject: [PATCH 2/2] keep source tarball if '--keep' or 'tar xf' fails --- bin/ruby-build | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index a7fb4362..8e721b67 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -241,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 }