scripts/rvm-ruby-installer in rvm-0.0.46 vs scripts/rvm-ruby-installer in rvm-0.0.47
- old
+ new
@@ -16,20 +16,20 @@
fi
if [ -z "$rvm_ruby_tag" -a -z "$rvm_ruby_rev" ] ; then
if [ ! -d $rvm_ruby_src_path ] ; then
rvm_url="${rvm_url:-"ftp://ftp.ruby-lang.org/pub/ruby/1.$rvm_major_version/$rvm_ruby_package_name.tar.gz"}"
- __rvm_log "info" "\tDownloading $rvm_ruby_package_name, this may take a while depending on your connection..."
+ __rvm_log "info" "Downloading $rvm_ruby_package_name, this may take a while depending on your connection..."
__rvm_fetch $rvm_url
if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
- __rvm_log "info" "\tExtracting $rvm_ruby_package_name ..."
+ __rvm_log "info" "Extracting $rvm_ruby_package_name ..."
mkdir -p $rvm_ruby_src_path # Is this line necessary considering -C below? v
__rvm_run "extract" tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path
if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
fi
else
- __rvm_log "info" "\tRetrieving Ruby from $rvm_url"
+ __rvm_log "info" "Retrieving Ruby from $rvm_url"
if [ ! -z "`echo $rvm_url | grep '^git'`" ] ; then
if [ -d "$rvm_ruby_src_path/.git" ] ; then
cd $rvm_ruby_src_path
if [ -z "$rvm_ruby_rev" ] ; then
git pull origin master
@@ -80,36 +80,36 @@
__rvm_run "autoconf" $rvm_autoconf
if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
fi
if [ -s ./Makefile -a -z "$rvm_reconfigure_flag" ] ; then
- __rvm_log "warn" "\tSkipping configure step, Makefile exists so configure must have already been run."
+ __rvm_log "warn" "Skipping configure step, Makefile exists so configure must have already been run."
elif [ -s ./configure ] ; then
- __rvm_log "info" "\tConfiguring $rvm_ruby_package_name using $rvm_ruby_configure, this may take a while depending on your cpu(s)..."
+ __rvm_log "info" "Configuring $rvm_ruby_package_name using $rvm_ruby_configure, this may take a while depending on your cpu(s)..."
if [ -d $rvm_path/usr/include/readline/ ] ; then
configure_parameters="$configure_parameters --with-readline-dir=$rvm_path/usr/include/readline/"
fi
if [ -d $rvm_path/usr/include/iconv/ ] ; then
configure_parameters="$configure_parameters --with-iconv-dir=$rvm_path/usr/include/iconv/"
fi
__rvm_run "configure" "./configure --prefix=$rvm_ruby_home $rvm_ruby_configure $configure_parameters"
unset configure_parameters
if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
else
- __rvm_log "error" "\tSkipping configure step, 'configure' script does not exist, did autoconf not run successfully?"
+ __rvm_log "error" "Skipping configure step, 'configure' script does not exist, did autoconf not run successfully?"
fi
- __rvm_log "info" "\tCompiling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..."
+ __rvm_log "info" "Compiling $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_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"
+ __rvm_log "info" "Installing $rvm_ruby_package_name"
__rvm_run "install" make install
else
__rvm_run "install" $rvm_ruby_make_install
fi
if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
@@ -199,20 +199,20 @@
__rvm_log "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home"
__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_log "info" "Downloading $rvm_ruby_package_name, this may take a while depending on your connection..."
__rvm_fetch $rvm_url
if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
- __rvm_log "info" "\tExtracting $rvm_ruby_package_name..."
+ __rvm_log "info" "Extracting $rvm_ruby_package_name..."
mkdir -p $rvm_ruby_src_path
__rvm_run "extract" tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path
if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
fi
- __rvm_log "info" "\tInstalling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..."
+ __rvm_log "info" "Installing $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..."
mkdir -p $rvm_ruby_log_path
cd $rvm_ruby_src_path
mkdir -p $rvm_ruby_home/lib/ruby/gems/1.8/gems
if [ ! -z "$rvm_ruby_configure" ] ; then rvm_ruby_configure="-c $rvm_ruby_configure"; fi
@@ -251,19 +251,18 @@
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.
+ echo `rvm install 1.8.6` # This should install if missing.
+ echo `rvm 1.8.6 -m rbx ; 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 $rake186rbx build
else
__rvm_run "build" $rake186rbx build
- fi
- unset rake186rbx
+ 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
@@ -300,51 +299,63 @@
__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
fi
else
if [ -d $rvm_ruby_src_path ] ; then
cd $rvm_ruby_src_path
else
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."
+ __rvm_log "info" "It 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_log "info" "Downloading $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_log "info" "Extracting $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."
+ __rvm_log "error" "'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
__rvm_run "extract" unzip -q $rvm_archives_path/$rvm_package_file.zip -d $rvm_source_path
fi
cd $rvm_ruby_src_path
fi
fi
- __rvm_log "info" "\tInstalling $rvm_ruby_package_name..."
+ __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_run "nailgun" "cd $rvm_ruby_src_path/tool/nailgun && make $rvm_make_flags"
__rvm_pushpop
chmod +x $rvm_ruby_home/bin/*
- for binary in jruby jgem jirb ; do
+
+
+ for binary in jirb jruby jgem ; do
ln -fs $rvm_ruby_home/bin/$binary $rvm_ruby_home/bin/${binary#j}
- done
+ 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_irbrc
- __rvm_bin_scripts
+ __rvm_bin_script
- ln -fs $rvm_ruby_home/bin/ruby $rvm_path/bin/$rvm_ruby_package_name
+ 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" $rvm_ruby_home/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q
- done
+ __rvm_run "gems" gem install $rvm_gem_name --no-rdoc --no-ri -q
+ done ; unset rvm_gem_name
+
;;
ruby)
# Merge configure options with user specified options
rvm_ruby_configure="--enable-shared=true --enable-pthread $rvm_ruby_configure "
@@ -412,43 +423,38 @@
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
- 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
+ __rvm_inject_gem_env $rvm_ruby_home/bin/$binary
+ __rvm_inject_ruby_shebang $rvm_ruby_home/bin/$binary
chmod +x $rvm_ruby_home/bin/$binary
fi
- done
+ done ; unset binary
__rvm_log "info" "Installing gems for $rvm_ruby_package_name."
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
+ done ; unset rvm_gem_name
__rvm_log "info" "Installation of gems for $rvm_ruby_package_name is complete."
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
+ __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/$binary"
__rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
- fi
- unset binary
+ fi ; unset binary
}
function __rvm_rubygems_setup {
if [ -z "`echo $rvm_ruby_version | awk '/^1\.9/'`" ] ; then
- __rvm_log "info" "\tInstalling rubygems dedicated to $rvm_ruby_package_name..."
+ __rvm_log "info" "Installing 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
else
@@ -471,19 +477,35 @@
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
+ __rvm_actual_file $1
+ if [ -f $actual_file ] ; then
+ sed -i.orig -e "s=#\!/usr/bin/env [j]*ruby=#\!$rvm_ruby_home/bin/ruby=" $actual_file
+ rm -f $actual_file.orig ; chmod +x $actual_file
+ fi ; unset actual_file
}
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
+ __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
+}
+
+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.
+ else
+ actual_file="$1"
fi
}