33shopt -s extglob
44set -o errtrace
55set -o errexit
6+ set -o pipefail
67
78rvm_install_initialize ()
89{
@@ -26,7 +27,9 @@ rvm_install_initialize()
2627
2728log () { printf " %b\n" " $* " ; }
2829debug (){ [[ ${rvm_debug_flag:- 0} -eq 0 ]] || printf " %b\n" " $* " >&2 ; }
29- fail () { log " \nERROR: $* \n" >&2 ; exit 1 ; }
30+ warn () { log " WARN: $* " >&2 ; }
31+ fail () { fail_with_code 1 " $* " ; }
32+ fail_with_code () { code=" $1 " ; shift ; log " \nERROR: $* \n" >&2 ; exit " $code " ; }
3033
3134rvm_install_commands_setup ()
3235{
@@ -256,9 +259,10 @@ fetch_version()
256259 return 0
257260 fi
258261 done
262+ fail_with_code 4 " Exhausted all sources trying to fetch version '$version ' of RVM!"
259263}
260264
261- # Returns a sorted list of all version tags from a repository
265+ # Returns a sorted list of most recent tags from a repository
262266fetch_versions ()
263267{
264268 typeset _account _domain _repo _url
@@ -267,7 +271,7 @@ fetch_versions()
267271 _repo=$3
268272 case ${_domain} in
269273 (bitbucket.org)
270- _url=https://${_domain} /api/1 .0/repositories/${_account} /${_repo} /branches- tags
274+ _url=" https://api. ${_domain} /2 .0/repositories/${_account} /${_repo} /refs/ tags?sort=-name&pagelen=20 "
271275 ;;
272276 (github.com)
273277 _url=https://api.${_domain} /repos/${_account} /${_repo} /tags
@@ -277,8 +281,9 @@ fetch_versions()
277281 _url=https://${_domain} /api/v3/repos/${_account} /${_repo} /tags
278282 ;;
279283 esac
280- __rvm_curl -s ${_url} |
281- \a wk -v RS=' ,' -v FS=' "' ' $2=="name"{print $4}' |
284+
285+ { __rvm_curl -sS " ${_url} " || warn " ...the preceeding error with code $? occurred while fetching $_url " ; } |
286+ \a wk -v RS=' ,|values":' -v FS=' "' ' $2=="name"&&$4!="rvm"{print $4}' |
282287 sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n
283288}
284289
@@ -408,28 +413,22 @@ verify_package_pgp()
408413 then
409414 log " GPG verified '$1 '"
410415 else
411- typeset _ret=$?
412- log " \
413- Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. \
414- Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).
416+ typeset _return=$?
415417
418+ log " \
416419GPG signature verification failed for '$1 ' - '$3 '! Try to install GPG v2 and then fetch the public key:
417420
418- ${SUDO_USER: +sudo } gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
421+ ${SUDO_USER: +sudo }${rvm_gpg_command ##*/ } --keyserver hkp://keyserver.ubuntu.com -- recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
419422
420423or if it fails:
421424
422425 command curl -sSL https://rvm.io/mpapis.asc | ${SUDO_USER: +sudo }${rvm_gpg_command##*/ } --import -
426+ command curl -sSL https://rvm.io/pkuczynski.asc | ${SUDO_USER: +sudo }${rvm_gpg_command##*/ } --import -
423427
424- the key can be compared with:
425-
426- https://rvm.io/mpapis.asc
427- https://keybase.io/mpapis
428-
429- NOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade \
430- or upgrade to newer version (if available) or use the second method described above.
428+ In case of further problems with validation please refer to https://rvm.io/rvm/security
431429"
432- exit $_ret
430+
431+ exit ${_return}
433432 fi
434433}
435434
@@ -832,7 +831,7 @@ and re-mount partition ${partition} without the noexec option."
832831
833832rvm_install_select_and_get_version ()
834833{
835- typeset _version_release
834+ typeset dir _version_release _version
836835
837836 for dir in " $rvm_src_path " " $rvm_archives_path "
838837 do
@@ -843,24 +842,27 @@ rvm_install_select_and_get_version()
843842 case " ${version} " in
844843 (head)
845844 _version_release=" ${branch} "
846- install_head sources[@] ${branch:- master} || exit $?
845+ install_head sources[@] ${branch:- master}
847846 ;;
848847
849848 (latest)
850- install_release sources[@] $( fetch_version sources[@]) || exit $?
849+ _version=$( fetch_version sources[@])
850+ install_release sources[@] " $_version "
851851 ;;
852852
853853 (latest-minor)
854- version=" $( \c at " $rvm_path /VERSION" ) "
855- install_release sources[@] $( fetch_version sources[@] ${version% .* } ) || exit $?
854+ version=" $( < " $rvm_path /VERSION" ) "
855+ _version=$( fetch_version sources[@] ${version% .* } )
856+ install_release sources[@] " $_version "
856857 ;;
857858
858859 (latest-* )
859- install_release sources[@] $( fetch_version sources[@] ${version# latest-} ) || exit $?
860+ _version=$( fetch_version sources[@] ${version# latest-} )
861+ install_release sources[@] " $_version "
860862 ;;
861863
862864 (+ ([[:digit:]]).+ ([[:digit:]]).+ ([[:digit:]])) # x.y.z
863- install_release sources[@] ${version} || exit $?
865+ install_release sources[@] ${version}
864866 ;;
865867
866868 (* )
@@ -893,7 +895,7 @@ rvm_install_ruby_and_gems()
893895 __rvm_print_headline
894896
895897 for _ruby in ${install_rubies[@]}
896- do command rvm " ${forwarded_flags[@]} " install ${_ruby} -j 2
898+ do command rvm " ${forwarded_flags[@]} " install ${_ruby}
897899 done
898900 # set the first one as default, skip rest
899901 for _ruby in ${install_rubies[@]}
0 commit comments