Skip to content

Commit

Permalink
allow providing multiple servers for binary rubies, closes #1265
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Oct 29, 2012
1 parent 0fd84b2 commit 9391d28
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 28 deletions.
12 changes: 10 additions & 2 deletions help/mount
Expand Up @@ -85,6 +85,14 @@ RVM requires just https server for your own hosting, the pattern for building ur


Where: Where:


- `rvm_remote_server_url` - can be defined in `~/.rvmrc` or in `$rvm_path/user/db` - `rvm_remote_server_url` - can be defined in `$rvm_path/user/db`
- `rvm_system_server_path` - can be defined in `~/.rvmrc` or in `$rvm_path/user/db`, autodetected - `rvm_system_server_path` - can be defined in `$rvm_path/user/db`, autodetected if not defined
- `rvm_ruby_string` - is the name specified by user - `rvm_ruby_string` - is the name specified by user

For multiple servers/paths suffix the definition with numbers, for example:

rvm_remote_server_url=https://own.company.com/binaries
rvm_system_server_path=my/system
rvm_remote_server_url1=https://rvm.io/binaries

When coresponding path is not defined for url then it is autodetected.
22 changes: 0 additions & 22 deletions scripts/functions/manage/rubinius
@@ -1,27 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash


file_exists_at_url()
{
typeset _url
_url="${1:-}"
if [[ -n "${_url}" ]]
then
( #subshell to be able to temporary disable curl function
unset curl 2>/dev/null
if curl -slk --head ${_url} 2>&1 | \head -n 1 | GREP_OPTIONS="" \grep '200 OK' >/dev/null 2>&1
then
return 0
else
return 1
fi
)
else
rvm_log "Warning: URL was not passed to __rvm_check_for_tarball"
return 1
fi

}

rbx_configure_with_path() rbx_configure_with_path()
{ {
typeset name _opt_path typeset name _opt_path
Expand Down
39 changes: 35 additions & 4 deletions scripts/functions/utility
Expand Up @@ -475,9 +475,10 @@ __rvm_detect_system()
_system_arch="${_system_arch//[ \/]/_}" _system_arch="${_system_arch//[ \/]/_}"
} }


# params: [printf_if=-] [suffix]
__rvm_system_path() __rvm_system_path()
{ {
true "${rvm_remote_server_path:=$(__rvm_db "rvm_remote_server_path")}" rvm_remote_server_path="$(__rvm_db "rvm_remote_server_path${2:-}")"
[[ -n "${rvm_remote_server_path}" ]] || [[ -n "${rvm_remote_server_path}" ]] ||
if __rvm_detect_system if __rvm_detect_system
then rvm_remote_server_path="${_system_name}/${_system_version}/${_system_arch}" then rvm_remote_server_path="${_system_name}/${_system_version}/${_system_arch}"
Expand All @@ -488,11 +489,26 @@ __rvm_system_path()
fi fi
} }


# params: return_on_end return_on_failed_link [suffix] [file]
__rvm_remote_server_path_single()
{
rvm_remote_server_url="$( __rvm_db "rvm_remote_server_url${3:-}" )"
[[ -n "$rvm_remote_server_url" ]] || return $1
__rvm_system_path "" "${3:-}"
if file_exists_at_url "${rvm_remote_server_url}/${rvm_remote_server_path}${4:+/}${4:-}"
then printf "%b" "${rvm_remote_server_url}/${rvm_remote_server_path}${4:+/}${4:-}"
else return $2
fi
}

# params: [file_name]
__rvm_remote_server_path() __rvm_remote_server_path()
{ {
true "${rvm_remote_server_url:=$( __rvm_db "rvm_remote_server_url" )}" typeset _iterator
__rvm_system_path _iterator=""
printf "%b" "${rvm_remote_server_url}/${rvm_remote_server_path}${1:+/}${1:-}" while ! __rvm_remote_server_path_single 0 1 "${_iterator}" "${1:-}"
do : $(( _iterator+=1 ))
done
} }


__list_remote_rubies_for() __list_remote_rubies_for()
Expand Down Expand Up @@ -547,3 +563,18 @@ __rvm_gemsets_initial()
rvm_log "Skipped importing default gemsets" rvm_log "Skipped importing default gemsets"
fi fi
} }

file_exists_at_url()
{
if
[[ -n "${1:-}" ]]
then
if \curl -slk --head "$1" 2>&1 | \head -n 1 | GREP_OPTIONS="" \grep '200 OK' >/dev/null 2>&1

This comment has been minimized.

Copy link
@wenzowski

wenzowski Apr 18, 2013

What's the rationale for curl -s (--silent) here? Would substituting curl -S (--show-error) break anything? Related to possible fix for #1814

This comment has been minimized.

Copy link
@mpapis

mpapis Apr 18, 2013

Author Member

-s and -k are here on purpose, this function checks for existence of a file, it should fail only when the file is missing, it should not print any output as it can be ran multiple times and it's status can not represent fail in the function.

then return 0
else return 1
fi
else
rvm_log "Warning: URL was not passed to file_exists_at_url"
return 1
fi
}

0 comments on commit 9391d28

Please sign in to comment.