scripts/rvm-ruby-installer in rvm-0.0.47 vs scripts/rvm-ruby-installer in rvm-0.0.48
- old
+ new
@@ -1,9 +1,8 @@
#!/bin/bash
function __rvm_install_source {
-
if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
result=0
__rvm_log "info" "Installing Ruby from source to: $rvm_ruby_home"
mkdir -p $rvm_ruby_log_path
@@ -124,35 +123,10 @@
__rvm_run "chmod.bin" chmod +x $rvm_ruby_home/bin/*
__rvm_post_install
__rvm_pushpop
}
-function __rvm_install {
-# TODO: Extract the outer looping mechanism with ruby_do's
- rubies=() ; successes=() ; errors=() ; statuses=()
- # TODO: Extract the common functionality out of the if below
- if [ ! -z "$(echo "$rvm_ruby_version" | awk '/,/')" ] ; then
- rvm_ruby_versions=`echo $rvm_ruby_version | tr ',' ' '`
- for rvm_ruby_string in $rvm_ruby_versions ; do
- unset rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install rvm_ruby_rev rvm_ruby_tag rvm_major_version rvm_minor_version rvm_gem_set_name rvm_gem_home rvm_ruby_binary rvm_ruby_package_name rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_selected
- if [ ! -z "$(echo $rvm_ruby_selector | awk '/^[0-9]/')" ] ; then
- rvm_ruby_interpreter="ruby"
- rvm_ruby_version="$rvm_ruby_selector"
- else
- rvm_ruby_interpreter="$rvm_ruby_selector"
- unset rvm_ruby_version
- fi
- __rvm_log "debug" $rvm_ruby_string
- __rvm_select
- __rvm_install_ruby
- done
- else
- __rvm_select
- __rvm_install_ruby
- fi
-}
-
function __rvm_install_ruby {
if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
if [ ! -z "$RUBYOPT" ] ; then ruby_options=$RUBYOPT ; unset RUBYOPT ; fi
@@ -299,12 +273,11 @@
__rvm_pushpop $rvm_source_path
if [ ! -z "$rvm_ruby_rev" ] ; then
if [ ! -d $rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version -o ! -d $rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git ] ; then
git clone --depth 1 $rvm_jruby_repo_url $rvm_ruby_src_path
- # TODO: Test if 'ant' is installed, if not throw error.
- cd $rvm_ruby_src_path && ant
+ cd $rvm_ruby_src_path && ant # TODO: Test if 'ant' is installed, if not throw error.
fi
else
if [ -d $rvm_ruby_src_path ] ; then
cd $rvm_ruby_src_path
else
@@ -323,37 +296,36 @@
fi
cd $rvm_ruby_src_path
fi
fi
+ for binary in jirb jruby jgem ; do
+ cp -f $rvm_ruby_src_path/bin/$binary $rvm_ruby_src_path/bin/${binary#j}
+ done ; unset binary
+
__rvm_log "info" "Installing $rvm_ruby_package_name..."
mkdir -p $rvm_ruby_home/bin/
- __rvm_run "sync" rsync -ag $rvm_ruby_src_path/ $rvm_ruby_home/
__rvm_run "nailgun" "cd $rvm_ruby_src_path/tool/nailgun && make $rvm_make_flags"
__rvm_pushpop
chmod +x $rvm_ruby_home/bin/*
+ if [ -z "$rvm_ruby_home" -o "$rvm_ruby_home" = "/" ] ; then echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000 ; fi
+ rm -rf $rvm_ruby_home
+ __rvm_run "sync" "/bin/cp -Rf $rvm_ruby_src_path $rvm_ruby_home"
- for binary in jirb jruby jgem ; do
- ln -fs $rvm_ruby_home/bin/$binary $rvm_ruby_home/bin/${binary#j}
- done ; unset binary
-
for binary in rake rdoc ri spec autospec ; do
__rvm_inject_ruby_shebang $rvm_ruby_home/bin/$binary
__rvm_inject_gem_env $rvm_ruby_home/bin/$binary
chmod +x $rvm_ruby_home/bin/$binary
done ; unset binary
-
+ __rvm_rubygems_setup
__rvm_irbrc
__rvm_bin_script
- ln -fs $rvm_ruby_home/bin/ruby $rvm_path/bin/$rvm_ruby_package_name # Is this necessary?
-
- __rvm_use
for rvm_gem_name in jruby-openssl ; do
__rvm_log "info" "Installing $rvm_gem_name"
- __rvm_run "gems" gem install $rvm_gem_name --no-rdoc --no-ri -q
+ __rvm_run "gems" $rvm_ruby_home/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q
done ; unset rvm_gem_name
;;
ruby)
@@ -372,21 +344,53 @@
esac
if [ ! -z "$ruby_options" ] ; then RUBYOPT=$ruby_options ; export RUBYOPT ; fi
}
-# TODO: DRY up __rvm_remove and __rvm_uninstall
-function __rvm_remove {
+function __rvm_manage_rubies {
+ rubies=() ; successes=() ; errors=() ; statuses=()
+ # TODO: Extract the common functionality out of the if below
+ if [ ! -z "$rvm_ruby_string" ] ; then
+ unset rvm_ruby_interpreter rvm_ruby_version
+ __rvm_${rvm_action}_ruby
+ elif [ ! -z "$rvm_ruby_version" ] ;then
+ for rvm_ruby_selector in `echo $rvm_ruby_version | tr ',' ' '` ; do
+ unset rvm_ruby_string
+ __rvm_${rvm_action}_ruby
+ __rvm_unset_ruby_variables
+ done
+ elif [ ! -z "$rvm_ruby_interpreter" ] ; then
+ unset rvm_ruby_string rvm_ruby_version
+ __rvm_${rvm_action}_ruby
+ else # all
+ if [ "$rvm_action" != "install" ] ; then
+ while read bin_line # Question: Should we prompt here? ;)
+ do # Keep this on second line damnit!
+ if [ -x $bin_line ] ; then
+ rvm_ruby_string="`dirname $bin_line | xargs dirname | xargs basename`"
+ __rvm_${rvm_action}_ruby
+ __rvm_unset_ruby_variables
+ fi
+ done < <(/bin/ls $rvm_path/*/bin/ruby 2> /dev/null)
+ fi
+ 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
+}
+
+function __rvm_uninstall_ruby {
if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
if [ ! -z "$rvm_ruby_package_name" ] ; then
- for dir in $rvm_source_path $rvm_path ; do
+ for dir in $rvm_path ; do
if [ -d $dir/$rvm_ruby_package_name ] ; then
__rvm_log "info" "Removing $dir/$rvm_ruby_package_name..."
rm -rf $dir/$rvm_ruby_package_name
else
- __rvm_log "info" "it seems that $dir/$rvm_ruby_package_name is already non existent."
+ __rvm_log "info" "$dir/$rvm_ruby_package_name has already been removed."
fi
if [ -e $rvm_bin_path/$rvm_ruby_package_name ] ; then
rm -f $rvm_bin_path/$rvm_ruby_package_name
fi
done ; unset dir
@@ -394,15 +398,15 @@
else
__rvm_log "fail" "Cannot uninstall unknown package '$rvm_ruby_package_name'"
fi
}
-function __rvm_uninstall {
+function __rvm_remove_ruby {
if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
if [ ! -z "$rvm_ruby_package_name" ] ; then
- for dir in $rvm_path ; do
+ for dir in $rvm_source_path $rvm_path ; do
if [ -d $dir/$rvm_ruby_package_name ] ; then
__rvm_log "info" "Removing $dir/$rvm_ruby_package_name..."
rm -rf $dir/$rvm_ruby_package_name
else
__rvm_log "info" "it seems that $dir/$rvm_ruby_package_name is already non existent."
@@ -465,11 +469,10 @@
__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-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
@@ -487,19 +490,20 @@
}
function __rvm_inject_gem_env {
__rvm_actual_file $1
if [ -f $actual_file ] ; then
- set -x
if [ ! -z "`head -n 1 $actual_file | awk '/[j]*ruby/'`" ] ; 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']"
elif [ ! -z "`head -n 1 $actual_file | awk '/bash/'`" ] ; then
string="GEM_HOME=\${GEM_HOME:-'$rvm_gem_home'}\nGEM_PATH=\${GEM_PATH:-'$rvm_gem_home'}\nPATH=$rvm_ruby_home/bin:$rvm_gem_home/bin:\$PATH"
fi
- set +x
- awk "NR==2 {print \"$string\"} {print}" $actual_file > $actual_file.new
- mv $actual_file.new $actual_file ; chmod +x $actual_file
- fi ; unset string actual_file
+ if [ ! -z "$string" ] ; then
+ awk "NR==2 {print \"$string\"} {print}" $actual_file > $actual_file.new
+ mv $actual_file.new $actual_file ; chmod +x $actual_file
+ unset string
+ fi
+ fi ; unset actual_file
}
function __rvm_actual_file {
if [ -L $1 ] ; then # If the file is a symlink,
actual_file=`readlink $1` # read the link target so we can preserve it.