scripts/utility in rvm-0.0.88 vs scripts/utility in rvm-0.0.89

- old
+ new

@@ -138,15 +138,14 @@ unset rvm_ruby_interpreter rvm_ruby_version rvm_url rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_ruby_binary rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_string rvm_ruby_string rvm_ruby_src_path rvm_ruby_repo_url rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_head_flag rvm_ruby_configure rvm_ruby_mode rvm_ruby_patch rvm_ruby_package_file rvm_ruby_package_name } __rvm_load_rvmrc() { if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi - if [[ -f $HOME/.rvmrc ]] ; then source $HOME/.rvmrc ; fi + if [[ -f "$HOME/.rvmrc" ]] ; then source "$HOME/.rvmrc" ; fi } __rvm_bin_scripts() { - # for rvm_ruby_binary in $(\ls $rvm_path/*/bin/ruby 2> /dev/null) ; do for rvm_ruby_binary in $rvm_path/*/bin/ruby ; do if [[ -x "$rvm_ruby_binary" ]] ; then rvm_ruby_string=$(dirname "$rvm_ruby_binary" | xargs dirname | xargs basename) __rvm_select __rvm_bin_script @@ -270,11 +269,11 @@ do prefix="$(echo ${tag/\//} | sed 's#^v1_##' | awk -F'_' '{print "(ruby-)1."$1"."$2}' | sed 's#p$##')" echo "${prefix}-t${tag/\//}" unset prefix tag done < <(svn list http://svn.ruby-lang.org/repos/ruby/tags/ | awk '/^v1_[8|9]/') - echo -e "(ruby-)1.8.6(-p383)\n(ruby-)1.8.6-head\n(ruby-)1.8.7(-p174)\n(ruby-)1.8.7-head\n(ruby-)1.9.1(-p243)\n(ruby-)1.9.1-head\n(ruby-)1.9.2-preview1" + echo -e "(ruby-)1.8.6(-p383)\n(ruby-)1.8.6-head\n(ruby-)1.8.7(-p174)\n(ruby-)1.8.7-head\n(ruby-)1.9.1(-p243)\n(ruby-)1.9.1(-p376)\n(ruby-)1.9.1-head\n(ruby-)1.9.2-preview1" echo -e "jruby-1.2.0\njruby-1.3.0\njruby-1.3.1\njruby(-1.4.0) # the default\njruby-head" echo -e "rbx(-head) # rubinius head, the default rbx \nrbx(-head) --jit (rubinius head with LLVM enabled)" echo -e "ree-1.8.6\nree(-1.8.7) # the default\nree-1.8.6-head\nree-1.8.7-head" echo -e "mput(-head) # shyouhei head, the default mput" if [[ "Darwin" = "$(uname)" ]] ; then @@ -284,96 +283,44 @@ ruby=$(which ruby 2>/dev/null) ; current_ruby="" if [[ ! -z "$ruby" ]] && [[ ! -z "$(echo $ruby | awk '/rvm/')" ]] ; then current_ruby="$(echo $ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null)" fi - for version in $(\ls -l $rvm_path/ 2> /dev/null | awk '/ ruby-[1-2].*/ { print $NF }') ; do - string=$($rvm_path/$version/bin/ruby -v) - if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - selected="1" + for version in $(\ls $rvm_path/ 2> /dev/null | awk '/[a-z]*-.*/ {print $NF}') ; do + if [[ ! -z "$(echo $version | awk '/^jruby-/')" ]] ; then + string="$($version -v | awk '{print $NF}')" else - echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" + string="[$(file $rvm_path/$version/bin/ruby | awk -F: '{print $2}' | awk '{print $NF}')]" fi - done ; unset version - - for version in $(\ls $rvm_path/ 2> /dev/null | awk '/ree-.*/ { print $NF }') ; do - string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" + echo -e "=> $(tput setaf 2)$version$(tput sgr0) $string" selected="1" else - echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" + echo -e " $(tput setaf 2)$version$(tput sgr0) $string" fi done ; unset version - for version in $(\ls $rvm_path/ 2> /dev/null | awk '/mput-.*/ { print $NF }') ; do - string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" - if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - selected="1" - else - echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - fi - done ; unset version - - for version in $(\ls $rvm_path/ 2> /dev/null | awk '/jruby-.*/ { print $NF }') ; do - string=$($rvm_path/$version/bin/ruby -v) - if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - selected="1" - else - echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - fi - done ; unset version - - # for version in $(\ls $rvm_path/ 2> /dev/null | awk '/rbx-.*/ { print $NF }') ; do - for version in "rbx-head" ; do - if [[ -f "$rvm_path/$version/bin/ruby" ]] ; then - string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" - if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - selected="1" - else - echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - fi - fi - done ; unset version - - - if [[ "Darwin" = "$(uname)" ]] ; then - for version in $(\ls $rvm_path/ 2> /dev/null | awk '/macruby-.*/ { print $NF }') ; do - string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" - if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - selected="1" - else - echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" - fi - done ; unset version - fi - if [[ -f "$rvm_path/default" ]] && [[ -s $rvm_path/default ]] ; then version=$(grep '^MY_RUBY_HOME' $rvm_path/default | awk -F"'" '{print $2}' | xargs basename) if [[ ! -z "$version" ]] ; then - string=$($rvm_path/$version/bin/ruby -v) + string=$(file $rvm_path/$version/bin/ruby) if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" + echo -e "=> $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0) $string" selected="1" else - echo -e " $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" + echo -e " $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0) $string" fi fi ; unset version fi system_ruby="$(rvm system ; which ruby 2>/dev/null)" if [[ ! -z "$system_ruby" ]] ; then - system_version=$($system_ruby -v) + system_version=$(file $(which ruby) | awk -F: '{print $2}' | grep 8 | awk '{print $NF}' | tr "\n" ' ') if [[ ! -z "$(which ruby 2>/dev/null)" ]] && [[ "$($(which ruby 2>/dev/null) -v)" = "$system_version" ]] ; then - echo -e "=> $(tput setaf 2)system$(tput sgr0) ( ruby -v # => $system_version )\n" + echo -e "=> $(tput setaf 2)system$(tput sgr0) [$system_version]\n" else - echo -e " $(tput setaf 2)system$(tput sgr0) ( ruby -v # => $system_version )\n" + echo -e " $(tput setaf 2)system$(tput sgr0) [$system_version]\n" fi else $rvm_scripts_path/log "info" "No system ruby found." fi @@ -417,11 +364,16 @@ else builtin cd $rvm_src_path && git clone git://github.com/wayneeseguin/rvm.git && builtin cd rvm/ && ./install fi else # TODO: rvm_install_path: - gem install rvm --no-rdoc --no-ri -q rvm && cd "$(rvm system ; gem env | grep "\- $HOME" | awk '{print $NF}')/gems/rvm-$(gem list rvm | sed 's/.*(//' | awk -F',' '{print $1 ; exit}')" && ./install + if [ $(gem list rvm --installed) = 'true' ]; then + gem update rvm --no-rdoc --no-ri --quiet + else + gem install rvm --no-rdoc --no-ri --quiet + fi + builtin cd "$(rvm system ; gem env | grep "\- $HOME" | awk '{print $NF}' | head -n 1)/gems/rvm-$(gem list rvm | sed 's/.*(//' | sed 's/).*//' | awk -F',' '{print $1 ; exit}')" && ./install fi __rvm_pushpop __rvm_hook "after_update" } @@ -468,20 +420,22 @@ rvm_ruby_mode="--$(echo $rvm_ruby_mode | sed 's/^m//')" fi load_path="$rvm_ruby_home/bin:$rvm_ruby_load_path" # TODO: the else case below should be run if $rvm_ruby_args =~ /\.rb$/ - if [[ "ruby" = "$binary" ]] && [[ "$rvm_benchmark_flag" -ne 1 ]] ; then + if [[ "ruby" = "$(basename $binary)" ]] && [[ "$rvm_benchmark_flag" -ne 1 ]] ; then if $rvm_scripts_path/match "$rvm_ruby_args" "\.rb$" ; then if [[ -z "$prefix" ]] ; then prefix="-S" ; fi if ! $rvm_scripts_path/match "$rvm_ruby_args" "$prefix" ; then rvm_ruby_args="$prefix $rvm_ruby_args" fi fi rvm_command="$binary $rvm_ruby_mode $rvm_ruby_require -I$load_path $rvm_ruby_args" - elif [[ "gem" = "$binary" ]] && match "$rvm_ruby_args" '^install' ; then - rvm_command="$binary $rvm_ruby_mode $rvm_ruby_args --no-rdoc --no-ri" + elif [[ "gem" = "$(basename $binary)" ]] && $rvm_scripts_path/match "$rvm_ruby_args" '^install' ; then + #__rvm_gem_install + #$rvm_scripts_path/gem install $rvm_ruby_args + rvm_command="$rvm_scripts_path/gems $rvm_ruby_mode $rvm_ruby_args --no-rdoc --no-ri" else rvm_command="$binary $rvm_ruby_mode $rvm_ruby_args" fi mkdir -p ./log/$rvm_ruby_string/ @@ -518,17 +472,16 @@ done elif [[ ! -z "$rvm_ruby_interpreter" ]] ; then unset rvm_ruby_string rvm_ruby_version __rvm_ruby_do else # all - rubies=($(\ls $rvm_path/*/bin/ruby)) - for full_binary in ${rubies[@]} ; do + for full_binary in $rvm_path/*/bin/ruby ; do if [[ -x "$full_binary" ]] ; then rvm_ruby_string="$(dirname $full_binary | xargs dirname | xargs basename)" __rvm_ruby_do fi - done ; unset full_binary rubies + done ; unset full_binary fi if [[ ! -z "$rvm_summary_flag" ]] ; then __rvm_summary ; fi if [[ ! -z "$rvm_yaml_flag" ]] ; then __rvm_yaml ; fi if [[ ! -z "$rvm_json_flag" ]] ; then __rvm_json ; fi @@ -651,11 +604,10 @@ if [[ ! -z "$rvm_all_flag" ]] ; then cat $actual_file ; fi done } __rvm_make_flags() { - PATH=${rvm_path}/usr/bin:$PATH ; export PATH # This is only an issue with Darwin :/ if [[ "Darwin" = "$(uname)" ]] ; then # ls /usr/lib/gcc/x86_64-apple-darwin10 # Set the build & host type @@ -693,7 +645,45 @@ if [[ -s "$rvm_hooks_path/$1" ]] ; then if [[ "$rvm_verbose_flag" -eq 1 ]] || [[ "$rvm_debug_flag" -eq 1 ]] ; then $rvm_scripts_path/log "info" "running hook $1" ; fi source "$rvm_hooks_path/$1" fi fi +} + +__rvm_gems_select() { + if [[ -z "$(which gem 2>/dev/null)" ]] ; then return 0 ; fi + + if [[ -z "$rvm_gem_set_name" ]] ; then + if [[ ! -z "$GEM_HOME" ]] ; then + rvm_gem_set_name=$(echo $GEM_HOME | xargs basename | awk -F'%' '{print $2}') + fi + + if [[ ! -z "$rvm_ruby_gem_home" ]] ; then + rvm_gem_set_name=$(echo $rvm_ruby_gem_home | xargs basename | awk -F'%' '{print $2}') + fi + + if [[ ! -z "$rvm_gem_set_name" ]] && ! $rvm_scripts_path/match "$rvm_gem_set_name" "^[0-9]\.[0-9]" ; then + rvm_ruby_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version%$rvm_gem_set_name" + else + if [[ ! -z "$rvm_ruby_interpreter" ]] && [[ ! -z "$rvm_ruby_version" ]] && [[ "$rvm_ruby_interpreter" != "system" ]] ; then + rvm_ruby_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version" + elif [[ -z "$GEM_HOME" ]] && [[ ! -z "$(which gem 2>/dev/null)" ]] ; then + rvm_ruby_gem_home=$(gem env gemdir) + elif [[ ! -z "$GEM_HOME" ]] ; then + rvm_ruby_gem_home="$GEM_HOME" + else + unset rvm_ruby_gem_home + fi + fi + if [[ -z "$rvm_gem_set_name" ]] ; then unset rvm_gem_set_name ; fi + else + rvm_ruby_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version%$rvm_gem_set_name" + fi +} + +__rvm_gems_use() { + mkdir -p "$rvm_ruby_gem_home" + GEM_HOME="$rvm_ruby_gem_home" ; export GEM_HOME + GEM_PATH="$GEM_HOME" ; export GEM_PATH + __rvm_use }