scripts/rvm-ruby-installer in rvm-0.0.44 vs scripts/rvm-ruby-installer in rvm-0.0.45
- old
+ new
@@ -1,16 +1,16 @@
#!/bin/bash
-function __rvm_install-source {
+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
- pushd $rvm_source_path > /dev/null
+ __rvm_pushpop $rvm_source_path
if [ ! -z "$rvm_force_flag" ] ; then
rm -rf $rvm_ruby_home
rm -rf $rvm_ruby_src_path
fi
@@ -70,11 +70,11 @@
if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
fi
fi
cd $rvm_ruby_src_path
- if [ $? -gt 0 ] ; then result=$? ; __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd > /dev/null ; return $result ; fi
+ if [ $? -gt 0 ] ; then result=$? ; __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; __rvm_pushpop ; return $result ; fi
if [ ! -s "$rvm_ruby_src_path/configure" -a "$rvm_ruby_interpreter" = "ruby" ] ; then
rvm_autoconf=`which autoconf`
if [ $? -gt 0 ] ; then __rvm_log "fail" "rvm expects autoconf" ; result=$? ; return $result ; fi
__rvm_run "autoconf" $rvm_autoconf
@@ -120,18 +120,41 @@
GEM_PATH="$rvm_gem_home" ; export GEM_PATH
__rvm_rubygems_setup
__rvm_bin_script
__rvm_run "chmod.bin" chmod +x $rvm_ruby_home/bin/*
-
- popd > /dev/null
-
__rvm_post_install
+ __rvm_pushpop
}
-function __rvm_install-ruby {
+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
case "$rvm_ruby_interpreter" in
@@ -161,22 +184,22 @@
rvm_ruby_rev="-r $rvm_ruby_rev"
fi
fi
#__rvm_fetch $rvm_url
#__rvm_run /usr/sbin/installer -pkg $rvm_ruby_package_name.pkg -target "$rvm_path/$rvm_ruby_package_name/"
- __rvm_install-source
+ __rvm_install_source
unset DESTDIR
else
__rvm_log "fail" "MacRuby can only be installed on a Darwin OS."
fi
+ __rvm_irbrc
;;
ruby-enterprise|ree)
- __rvm_select
rvm_url="http://rubyforge.org/frs/download.php/58677/$rvm_ruby_package_name.tar.gz"
__rvm_log "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home"
- pushd $rvm_source_path > /dev/null
+ __rvm_pushpop $rvm_source_path
if [ -d $rvm_ruby_src_path ] ; then
cd $rvm_ruby_src_path
else
__rvm_log "info" "\tDownloading $rvm_ruby_package_name, this may take a while depending on your connection..."
__rvm_fetch $rvm_url
@@ -202,17 +225,17 @@
for rvm_gem_name in rake ; do
__rvm_log "info" "Installing $rvm_gem_name"
__rvm_run "gems" $rvm_ruby_home/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q
done
+ __rvm_irbrc
__rvm_bin_scripts
-
- popd > /dev/null
+ __rvm_post_install
+ __rvm_pushpop
;;
rbx|rubinius)
- # TODO: check if system is 1.8.X otherwise use rvm's 1.8.X and check for parsetree, install if missing
unset GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
PATH="$rvm_system_path" ; export PATH
rvm_ruby_repo_url=$rvm_rubinius_repo_url
rvm_ruby_configure=""
rvm_ruby_src_path=$rvm_ruby_home
@@ -225,60 +248,73 @@
if [ ! -d $rvm_ruby_home -o ! -d $rvm_ruby_home/.git ] ; then
rm -rf $rvm_ruby_home
git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_home
fi
cd $rvm_ruby_home
+
+ # prereqs, 1.8.6 w/ParseTree & rake. Yes this could all be one line... not pushing our luck.
+ bash -l -c 'rvm 1.8.6 --debug --install' # This should install if missing.
+ bash -l -c 'rvm 1.8.6 -m rbx ; $rvm_ruby_home/bin/gem install --no-rdoc --no-ri rake ParseTree' # This should install if missing.
+ rake186rbx=`rvm 1.8.6 -m rbx ; which rake`
if [ ! -z "$rvm_jit_flag" ]; then
- __rvm_run "build" RBX_LLVM=1 rake build
+ __rvm_run "build" RBX_LLVM=1 $rake186rbx build
else
- __rvm_run "build" rake build
+ __rvm_run "build" $rake186rbx build
fi
+ unset rake186rbx
+
for binary in ruby irb ; do
ln -fs $rvm_ruby_home/bin/rbx $rvm_ruby_home/bin/$binary
done
$rvm_ruby_home/bin/rbx -S gem install rake --no-rdoc --no-ri
- ruby_wrapper=$(cat <<RubyWrapper
+ for binary_name in gem rake ; do
+ ruby_wrapper=$(cat <<RubyWrapper
#!/bin/bash
GEM_HOME="$rvm_gem_home" ; export GEM_HOME
GEM_PATH="$rvm_gem_home" ; export GEM_PATH
MY_RUBY_HOME="$rvm_ruby_home" ; export MY_RUBY_HOME
PATH="$rvm_ruby_home/bin:$rvm_gem_home/bin:\$PATH" ; export PATH
-exec $rvm_ruby_home/bin/rbx -S gem "\$@"
+exec $rvm_ruby_home/bin/rbx -S $binary_name "\$@"
RubyWrapper
)
- echo "$ruby_wrapper" > $rvm_bin_path/gem-$rvm_ruby_package_name
- echo "$ruby_wrapper" > $rvm_ruby_home/bin/gem
- unset ruby_wrapper
- chmod +x $rvm_bin_path/$rvm_ruby_package_name
- chmod +x $rvm_ruby_home/bin/gem
-
+ for file_name in $rvm_bin_path/gem-$rvm_ruby_package_name $rvm_ruby_home/bin/gem ; do
+ echo "$ruby_wrapper" > $file_name
+ if [ -f $file_name ] ; then chmod +x $file_name ; fi
+ done
+ unset ruby_wrapper binary_name file_name
+ done
+ __rvm_irbrc
__rvm_bin_scripts
;;
jruby)
rvm_package_file="$rvm_ruby_interpreter-bin-$rvm_ruby_version"
rvm_url="http://dist.codehaus.org/$rvm_ruby_interpreter/$rvm_ruby_version/$rvm_package_file.zip"
rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
- __rvm_log "info" "Installing jRuby to: $rvm_ruby_home"
+ __rvm_log "info" "Installing JRuby to: $rvm_ruby_home"
mkdir -p $rvm_ruby_log_path
- pushd $rvm_source_path > /dev/null
+ __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
cd $rvm_ruby_src_path && ant
fi
else
if [ -d $rvm_ruby_src_path ] ; then
cd $rvm_ruby_src_path
else
- __rvm_log "info" "\tDownloading $rvm_package_file, this may take a while depending on your connection..."
- __rvm_fetch $rvm_url
+ if [ -z "$rvm_force_flag" -a -f $rvm_package_file -a -s $rvm_package_file ] ; then
+ __rvm_log "info" "\tIt appears that $rvm_package_file has already been downloaded, skipping. Use --force to force re-download."
+ else
+ __rvm_log "info" "\tDownloading $rvm_package_file, this may take a while depending on your connection..."
+ __rvm_fetch $rvm_url
+ fi
__rvm_log "info" "\tExtracting $rvm_package_file..."
rvm_unzip=`which unzip`
if [ $? -ne 0 ] ; then
__rvm_log "error" "\t'unzip' was not found in your PATH. jRuby official release comes as a .zip file, hence 'unzip' is required to extract it. Please install 'unzip' and try again."
else
@@ -290,30 +326,31 @@
__rvm_log "info" "\tInstalling $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
- popd > /dev/null
+ __rvm_pushpop
chmod +x $rvm_ruby_home/bin/*
for binary in jruby jgem jirb ; do
ln -fs $rvm_ruby_home/bin/$binary $rvm_ruby_home/bin/${binary#j}
done
+ __rvm_irbrc
__rvm_bin_scripts
ln -fs $rvm_ruby_home/bin/ruby $rvm_path/bin/$rvm_ruby_package_name
- for rvm_gem_name in rake jruby-openssl ; do
+ for rvm_gem_name in jruby-openssl ; do
__rvm_log "info" "Installing $rvm_gem_name"
__rvm_run "gems" $rvm_ruby_home/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q
done
;;
ruby)
# Merge configure options with user specified options
rvm_ruby_configure="--enable-shared=true --enable-pthread $rvm_ruby_configure "
if [ "`uname`" = "Darwin" ] ; then ARCHFLAGS="-arch x86_64 -arch i386" ; export ARCHFLAGS ; fi
- __rvm_install-source $*
+ __rvm_install_source $*
;;
default)
__rvm_log "fail" "please specify a ruby implementation to install."
;;
@@ -349,11 +386,10 @@
__rvm_log "fail" "Cannot uninstall unknown package '$rvm_ruby_package_name'"
fi
}
function __rvm_uninstall {
-
if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
if [ ! -z "$rvm_ruby_package_name" ] ; then
for dir in $rvm_path ; do
if [ -d $dir/$rvm_ruby_package_name ] ; then
@@ -374,13 +410,15 @@
}
function __rvm_post_install {
for binary in gem irb erb ri rdoc testrb rake ; do
- if [ -f $rvm_ruby_src_path/bin/$binary ] ; then
- if [ "$rvm_ruby_src_path" != "$rvm_ruby_home" ] ; then
- cp $rvm_ruby_src_path/bin/$binary $rvm_ruby_home/bin/$binary
+ 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
+ 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
chmod +x $rvm_ruby_home/bin/$binary
@@ -413,10 +451,9 @@
fi
unset binary
}
function __rvm_rubygems_setup {
-
if [ "`echo $rvm_ruby_version | awk '{print substr($1, 0, 3)}'`" != "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