scripts/rvm-ruby-installer in rvm-0.0.45 vs scripts/rvm-ruby-installer in rvm-0.0.46

- old
+ new

@@ -100,11 +100,11 @@ __rvm_log "info" "\tCompiling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..." if [ -z "$rvm_ruby_make" ] ; then __rvm_run "make" make $rvm_make_flags else - __rvm_run "make" $rvm_ruby_make + __rvm_run "make" $rvm_ruby_make $rvm_make_flags fi if [ $? -gt 0 ] ; then result=$? ; return $result ; fi if [ -z "$rvm_ruby_make" ] ; then __rvm_log "info" "\tInstalling $rvm_ruby_package_name" @@ -233,11 +233,12 @@ __rvm_pushpop ;; rbx|rubinius) unset GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC - PATH="$rvm_system_path" ; export PATH + PATH=$(echo $PATH | tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -) + PATH=$rvm_bin_path:$PATH ; export PATH rvm_ruby_repo_url=$rvm_rubinius_repo_url rvm_ruby_configure="" rvm_ruby_src_path=$rvm_ruby_home rvm_ruby_make="rake" rvm_ruby_make_install="rake install" @@ -357,14 +358,11 @@ *) __rvm_log "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known." esac - if [ ! -z "$ruby_options" ] ; then - RUBYOPT=$ruby_options ; export RUBYOPT - fi - + if [ ! -z "$ruby_options" ] ; then RUBYOPT=$ruby_options ; export RUBYOPT ; fi } # TODO: DRY up __rvm_remove and __rvm_uninstall function __rvm_remove { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi @@ -404,28 +402,28 @@ done ; unset dir rm -rf $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version*/ else __rvm_log "fail" "Cannot uninstall unknown package '$rvm_ruby_package_name'" fi - } function __rvm_post_install { - for binary in gem irb erb ri rdoc testrb rake ; do - if [ -f $rvm_ruby_home/bin/$binary -o -f $rvm_ruby_src_path/bin/$binary ] ; then - if [ "$rvm_ruby_src_path" != "$rvm_ruby_home" -a $rvm_ruby_src_path/bin/$binary] ; then + if [ -e $rvm_ruby_home/bin/$binary -o -e $rvm_ruby_src_path/bin/$binary ] ; then + if [ "$rvm_ruby_src_path" != "$rvm_ruby_home" -a -f $rvm_ruby_src_path/bin/$binary ] ; then cp -f $rvm_ruby_src_path/bin/$binary $rvm_ruby_home/bin/$binary elif [ -f "$rvm_gem_home/bin/$binary" ] ; then cp -f $rvm_gem_home/bin/$binary $rvm_ruby_home/bin/$binary fi - string="ENV['GEM_HOME']=ENV['GEM_HOME'] || '$rvm_gem_home'\nENV['GEM_PATH']=ENV['GEM_PATH'] || '$rvm_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_gem_home/bin:' + ENV['PATH']" - awk "NR==2 {print \"$string\"} {print}" $rvm_ruby_home/bin/$binary > $rvm_ruby_home/bin/$binary.new - mv $rvm_ruby_home/bin/$binary.new $rvm_ruby_home/bin/$binary + if [ -f $rvm_ruby_home/bin/$binary ] ; then + string="ENV['GEM_HOME']=ENV['GEM_HOME'] || '$rvm_gem_home'\nENV['GEM_PATH']=ENV['GEM_PATH'] || '$rvm_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_gem_home/bin:' + ENV['PATH']" + awk "NR==2 {print \"$string\"} {print}" $rvm_ruby_home/bin/$binary > $rvm_ruby_home/bin/$binary.new + mv $rvm_ruby_home/bin/$binary.new $rvm_ruby_home/bin/$binary + else + __rvm_log "info" "Skipping $rvm_ruby_src_path/bin/$binary, it is an executable not a script." + fi chmod +x $rvm_ruby_home/bin/$binary - else - __rvm_log "warn" "$rvm_ruby_src_path/bin/$binary is missing" fi done __rvm_log "info" "Installing gems for $rvm_ruby_package_name." @@ -439,23 +437,17 @@ binary=rake if [ -x $rvm_gem_home/bin/$binary ] ; then if [ "$rvm_gem_home" != "$rvm_ruby_home" ] ; then cp $rvm_gem_home/bin/$binary $rvm_ruby_home/bin/$binary fi - # TODO: Account for rubygem installed rake vs system rake - string="ENV['GEM_HOME']=ENV['GEM_HOME'] || '$rvm_gem_home'\nENV['GEM_PATH']=ENV['GEM_PATH'] || '$rvm_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_gem_home/bin:' + ENV['PATH']" - awk "NR==2 {print \"$string\"} {print}" $rvm_ruby_home/bin/$binary > $rvm_ruby_home/bin/$binary.new - mv $rvm_ruby_home/bin/$binary.new $rvm_ruby_home/bin/$binary - chmod +x $rvm_ruby_home/bin/$binary - else - __rvm_log "warn" "$rvm_gem_home/bin/$binary is missing" + __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary" fi unset binary } function __rvm_rubygems_setup { - if [ "`echo $rvm_ruby_version | awk '{print substr($1, 0, 3)}'`" != "1.9" ] ; then + if [ -z "`echo $rvm_ruby_version | awk '/^1\.9/'`" ] ; then __rvm_log "info" "\tInstalling rubygems dedicated to $rvm_ruby_package_name..." rvm_gem_package_name="rubygems-1.3.5" rvm_gem_url="http://rubyforge.org/frs/download.php/60718/$rvm_gem_package_name.tgz" if [ -d $rvm_source_path/$rvm_gem_package_name ] ; then cd $rvm_source_path/$rvm_gem_package_name @@ -467,16 +459,31 @@ __rvm_run "rubygems.install" GEM_PATH=$rvm_gem_path GEM_HOME=$rvm_gem_home $rvm_ruby_home/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb result=$? if [ $result -eq 0 ] ; then __rvm_log "info" "Installation of rubygems $rvm_ruby_package_name completed successfully." fi + + __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/gem" else - # 1.9 has it's own built gem command, let's adjust the shebang line. - mv $rvm_ruby_src_path/bin/gem $rvm_ruby_src_path/bin/gem.orig - cat $rvm_ruby_src_path/bin/gem.orig | sed -e "s=!# */usr/bin/env ruby=!#/usr/bin/$rvm_ruby_home/bin/ruby=" > $rvm_ruby_src_path/bin/gem - chmod +x $rvm_ruby_home/bin/gem + # 1.9 has it's own built-in gem command + __rvm_inject_ruby_shebang "$rvm_ruby_src_path/bin/gem" + cp $rvm_ruby_src_path/bin/gem $rvm_ruby_home/bin/gem __rvm_run "rubygems.update" $rvm_ruby_home/bin/gem update --system fi - return $result +} + +function __rvm_inject_ruby_shebang { + if [ -f $1 ] ; then + cat $1 | sed -e "s=#!/usr/bin/env ruby=#!$rvm_ruby_home/bin/ruby=" > $1.new + mv $1.new $1 ; chmod +x $1 + fi +} + +function __rvm_inject_gem_env { + if [ -f $1 ] ; then + string="ENV['GEM_HOME']=ENV['GEM_HOME'] || '$rvm_gem_home'\nENV['GEM_PATH']=ENV['GEM_PATH'] || '$rvm_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_gem_home/bin:' + ENV['PATH']" + awk "NR==2 {print \"$string\"} {print}" $1 > $1.new + mv $1.new $1 ; chmod +x $1 + fi }