scripts/fetch in rvm-0.1.20 vs scripts/fetch in rvm-0.1.21
- old
+ new
@@ -4,32 +4,40 @@
trap "if [[ -d $rvm_tmp_path/ ]] && [[ -f $rvm_tmp_path/$$ ]] ; then rm -f $rvm_tmp_path/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15
record_md5() {
if [[ "Darwin" = "$(uname)" ]] || [[ "FreeBSD" = "$(uname)" ]]; then
- archive_md5="$(md5 $archive | awk '{print $NF}')"
+ archive_md5="$(/sbin/md5 $archive | awk '{print $NF}')"
else
archive_md5="$(md5sum $archive | awk '{print $1}')"
fi
$rvm_scripts_path/db "$rvm_config_path/md5" "$archive" "$archive_md5"
}
+builtin cd "$rvm_archives_path"
+
+if [[ -z "$1" ]] ; then $rvm_scripts_path/log "fail" "BUG: $0 called without an argument :/" ; exit 1 ; fi
+
+url="$1"; download=1 ; package_name="$2"
+
if ! which curl &> /dev/null; then
$rvm_scripts_path/log "fail" "rvm requires curl, which does not seem to exist in your path :("
exit 1
elif [[ ! -z ${rvm_proxy} ]] ; then
- fetch_command="curl -x${rvm_proxy} -O -L --create-dirs -C - " # -s for silent
+ fetch_command="curl -x${rvm_proxy} -L --create-dirs -C - " # -s for silent
else
- fetch_command="curl -O -L --create-dirs -C - " # -s for silent
+ fetch_command="curl -L --create-dirs -C - " # -s for silent
fi
-builtin cd "$rvm_archives_path"
+if [[ ! -z "$package_name" ]] ; then
+ fetch_command="${fetch_command} -o ${package_name} "
+ archive="$package_name"
+else
+ fetch_command="${fetch_command} -O "
+ archive=$(basename "$url")
+fi
-if [[ -z "$1" ]] ; then $rvm_scripts_path/log "fail" "BUG: $0 called without an argument :/" ; exit 1 ; fi
-
-archive=$(basename "$1") ; downlaod=1
-
if [[ ! -z "$rvm_debug_flag" ]] ; then $rvm_scripts_path/log "debug" "Fetching $archive" ; fi
# Check first if we have the correct archive
archive_md5="$($rvm_scripts_path/db "$rvm_config_path/md5" "$archive")"
if [[ -e "$archive" ]] && [[ ! -z "$archive_md5" ]] ; then
@@ -47,16 +55,16 @@
download=1
fi
if [[ $download -gt 0 ]] ; then
rm -f $archive
- eval $fetch_command "$1"
+ eval $fetch_command "$url"
result=$?
if [[ $result -gt 0 ]] ; then
retry=0
if [[ $result -eq 78 ]] ; then
- $rvm_scripts_path/log "error" "The requested url does not exist: '$1'"
+ $rvm_scripts_path/log "error" "The requested url does not exist: '$url'"
elif [[ $result -eq 18 ]] ; then
$rvm_scripts_path/log "error" "Partial file. Only a part of the file was transferred. Removing partial and re-trying."
rm -f "$archive"
retry=1
elif [[ $result -eq 33 ]] ; then
@@ -66,10 +74,10 @@
else
$rvm_scripts_path/log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
fi
if [[ $retry -eq 1 ]] ; then
- eval $fetch_command "$1"
+ eval $fetch_command "$url"
result=$?
if [[ $result -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
else
record_md5