scripts/rvm in rvm-0.0.30 vs scripts/rvm in rvm-0.0.31

- old
+ new

@@ -9,12 +9,12 @@ # function __rvm_meta { rvm_meta_author="Wayne E. Seguin" rvm_meta_author_email="wayneeseguin@gmail.com" rvm_meta_website="http://rvm.beginrescueend.com/" - rvm_meta_version="0.0.30" - rvm_meta_updated="2009.09.02" + rvm_meta_version="0.0.31" + rvm_meta_updated="2009.09.03" } function __rvm_version { __rvm_meta ; echo "rvm $rvm_meta_version ($rvm_meta_updated) [$rvm_meta_website]" ; } function __rvm_usage { @@ -41,14 +41,16 @@ (highly expiramental) Example: rvm gemdup ~/.gem/ruby/1.8/ install - Install a ruby version, default is from source uninstall - Uninstall a ruby version reset - Remove default and current settings, exit the shell. (If you experience odd behavior try this first) - reload - Reload rvm source itself (useful after changing rvm source) rubydo - Used with -f to run a ruby file against specified or all rubies debug - Emit environment & configuration information for *current* ruby + + reload - Reload rvm source itself (useful after changing rvm source) implode - Removes all ruby installations it manages, everything in ~/.rvm + update - Upgrades rvm to the latest version. Implementation: * ruby - MRI/YARV Ruby (The Standard), defaults to 1.8.6 jruby - jRuby @@ -61,11 +63,11 @@ -v|--version - Ruby Package Version, defaults to 'latest' -l|--level - Patch level for the specified Ruby version -p|--prefix - Package and source directory prefix, with trailing slash! Default is a users home directory and /usr/local/ for root - -c|--configure - Options for source compile (default: --enable-shared) + -c|--configure - Options for source compile (default: --enable-shared=true) -a|--archives - Directory to place downladed files into (~/.rvm/archives/) -n|--nice - Niceness level (default: 0) -m|--gem-set - Named gem set for switching between different gem sets --rm-gem-set - Removes a named gemset. @@ -85,10 +87,11 @@ -n|--nice - Specify a process niceness (for slow computers) -f|--file - Specify a ruby file to run with 'rubydo' command -h|--help - Emit this output and exit -d|--default - Set the default Ruby to a specified version -m|--gem-set - Use a named gem set instead of the default set. + --all - Used with 'rvm list' to list "most" installable versions. --rm-gem-set - Remove a named gem set --jit - Enable JIT for the Rubinius build --force - Force install, removes old install & source directories. --set-prompt - Set prompt to have the selected ruby prepended. --debug|--trace - Toggle debug mode on for very verbose output. @@ -107,24 +110,22 @@ case "$1" in debug) shift ; echo -e "\n\033[0;35m <d> $* \033[0m" ;; info) shift ; echo -e "\n\033[0;32m <i> $* \033[0m" ;; warn) shift ; echo -e "\n\033[0;33m <w> $* \033[0m" ;; - fail) shift ; echo -e "\n\033[0;31m <e> $* \033[0m" ; return 1 ;; + fail) shift ; echo -e "\n\033[0;31m <e> $* \033[0m" ; popd 2> /dev/null ; return 1 ;; *) echo -e "$*" esac } function __rvm_clean-path { - PATH=`echo $PATH | tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | tr -s '\n' ':'` - PATH="${PATH%:}" + PATH=`echo $PATH | tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | tr -s '\n' ':' | sed 's/:$//'` export PATH } function __rvm_remove-from-path { - PATH=`echo $PATH | tr -s ':' '\n' | grep -v "\.rvm" | tr -s '\n' ':'` - PATH="${PATH%:}" + PATH=`echo $PATH | tr -s ':' '\n' | grep -v "\.rvm" | tr -s '\n' ':' | sed 's/:$//'` export PATH } function __rvm_gi { gem install -q --no-rdoc --no-ri $* ; } function __rvm_gems-install { for gem in $* ; do __rvm_gi $gem ; done } @@ -181,15 +182,20 @@ } function __rvm_initialize { - rvm_curl=`which curl` + rvm_fetch=`which curl` if [ $? -ne 0 ] ; then - __rvm_log "fail" "rvm expects that curl is available, which curl shows no curl :(" + rvm_fetch=`which wget` + if [ $? -ne 0 ] ; then + rvm_fetch="wget -q -c " + else + __rvm_log "fail" "rvm expects either curl or wget, neither seem to be in your path :(" + fi else - rvm_curl="$rvm_curl -O -L -s -C - " + rvm_fetch="$rvm_fetch -O -L -s -C - " fi rvm_niceness=${rvm_niceness:-0} # TODO: Sanitize user input, ensure that there is a / a the end... @@ -225,107 +231,109 @@ fi mkdir -p $rvm_source_path $rvm_bin_path $rvm_archives_path } -function __rvm_curl { +function __rvm_fetch { pushd $rvm_archives_path > /dev/null - eval $rvm_curl "$1" - popd > /dev/null + eval $rvm_fetch "$1" + popd 2> /dev/null } function __rvm_install-source { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi - __rvm_log "info" "Installing Ruby from source to: $rvm_install_path/$rvm_ruby_package_name" - mkdir -p $rvm_log_path/$rvm_ruby_package_name + __rvm_log "info" "Installing Ruby from source to: $rvm_ruby_home" + mkdir -p $rvm_ruby_log_path pushd $rvm_source_path > /dev/null if [ ! -z "$rvm_force" ] ; then - rm -rf $rvm_install_path/$rvm_ruby_package_name - rm -rf $rvm_source_path/$rvm_ruby_package_name + rm -rf $rvm_ruby_home + rm -rf $rvm_ruby_src_path fi if [ -z "$rvm_ruby_tag" -a -z "$rvm_ruby_rev" ] ; then - if [ ! -d $rvm_source_path/$rvm_ruby_package_name ] ; 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_curl $rvm_url - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + __rvm_fetch $rvm_url + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi __rvm_log "info" "\tExtracting $rvm_ruby_package_name ..." - mkdir -p $rvm_source_path/$rvm_ruby_package_name + mkdir -p $rvm_ruby_src_path nice -n $rvm_niceness tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path fi else - if [ -z "$rvm_ruby_rev" ] ; then - # TODO: Check if tag v is valid - rvm_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag - rvm_rev="" - else - if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then - rvm_url=$rvm_ruby_repo_url/branches/ruby_1_${rvm_major_version}_${rvm_minor_version} - rvm_rev="" - else - rvm_url=$rvm_ruby_repo_url/branches/ruby_1_${rvm_major_version}_${rvm_minor_version} - rvm_rev="-r $rvm_ruby_rev" - fi - fi - __rvm_log "info" "\tRetrieving Ruby from $rvm_url" if [ ! -z "`echo $rvm_url | grep '^git'`" ] ; then - if [ -d "$rvm_source_path/$rvm_ruby_package_name/.git" ] ; then - cd $rvm_source_path/$rvm_ruby_package_name + if [ -d "$rvm_ruby_src_path/.git" ] ; then + cd $rvm_ruby_src_path if [ -z "$rvm_ruby_rev" ] ; then git pull origin master else git checkout ${rvm_ruby_rev:-HEAD} fi else - git clone --depth 1 $rvm_ruby_repo_url $rvm_source_path/$rvm_ruby_package_name + git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_src_path fi else - if [ -d "$rvm_source_path/$rvm_ruby_package_name/.svn" ] ; then - cd $rvm_source_path/$rvm_ruby_package_name + if [ -z "$rvm_ruby_rev" ] ; then + # TODO: Check if tag v is valid + rvm_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag + rvm_rev="" + else + if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then + rvm_url=$rvm_ruby_repo_url/branches/ruby_1_${rvm_major_version}_${rvm_minor_version} + rvm_rev="" + else + rvm_url=$rvm_ruby_repo_url/branches/ruby_1_${rvm_major_version}_${rvm_minor_version} + rvm_rev="-r $rvm_ruby_rev" + fi + fi + + if [ -d "$rvm_ruby_src_path/.svn" ] ; then + cd $rvm_ruby_src_path svn checkout -q $rvm_rev else - svn checkout -q $rvm_rev --force $rvm_url $rvm_source_path/$rvm_ruby_package_name + svn checkout -q $rvm_rev --force $rvm_url $rvm_ruby_src_path fi fi fi - cd $rvm_source_path/$rvm_ruby_package_name - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi - if [ ! -s $rvm_source_path/$rvm_ruby_package_name/Makefile -a "$rvm_ruby_interpreter" = "ruby" ] ; then autoconf ; fi - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + cd $rvm_ruby_src_path + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi + if [ ! -s $rvm_ruby_src_path/Makefile -a "$rvm_ruby_interpreter" = "ruby" ] ; then autoconf ; fi + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi if [ -s ./configure ] ; then - __rvm_log "info" "\tConfiguring $rvm_ruby_package_name using ${rvm_ruby_configure:-"--enable-shared"}, this may take a while depending on your cpu(s)..." - nice -n $rvm_niceness ./configure --prefix=$rvm_install_path/$rvm_ruby_package_name ${rvm_ruby_configure:-"--enable-shared"} > $rvm_log_path/$rvm_ruby_package_name/configure.log 2> $rvm_log_path/$rvm_ruby_package_name/configure.error.log - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + __rvm_log "info" "\tConfiguring $rvm_ruby_package_name using $rvm_ruby_configure, this may take a while depending on your cpu(s)..." + # command="nice -n $rvm_niceness ./configure --prefix=$rvm_ruby_home $rvm_ruby_configure" + # eval $command > $rvm_ruby_log_path/configure.log 2> $rvm_ruby_log_path/configure.error.log + __rvm_run "configure" ./configure --prefix=$rvm_ruby_home $rvm_ruby_configure + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi else __rvm_log "warn" "\tSkipping configure step, ./configure file does not exist." fi __rvm_log "info" "\tCompiling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..." if [ -z "$rvm_ruby_make" ] ; then - nice -n $rvm_niceness make > $rvm_log_path/$rvm_ruby_package_name/make.log 2> $rvm_log_path/$rvm_ruby_package_name/make.error.log + nice -n $rvm_niceness make > $rvm_ruby_log_path/make.log 2> $rvm_ruby_log_path/make.error.log else - nice -n $rvm_niceness $rvm_ruby_make > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log + nice -n $rvm_niceness $rvm_ruby_make > $rvm_ruby_log_path/install.log 2> $rvm_ruby_log_path/install.error.log fi - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi if [ -z "$rvm_ruby_make" ] ; then __rvm_log "info" "\tInstalling $rvm_ruby_package_name" - nice -n $rvm_niceness make install > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log + nice -n $rvm_niceness make install > $rvm_ruby_log_path/install.log 2> $rvm_ruby_log_path/install.error.log else - nice -n $rvm_niceness $rvm_ruby_make_install > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log + nice -n $rvm_niceness $rvm_ruby_make_install > $rvm_ruby_log_path/install.log 2> $rvm_ruby_log_path/install.error.log fi - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi - chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/* + chmod +x $rvm_ruby_home/bin/* ruby_wrapper=$(cat <<-RubyWrapper #!/bin/bash GEM_HOME=$rvm_gem_home ; export GEM_HOME MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME @@ -343,42 +351,52 @@ 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 - __rvm_curl $rvm_gem_url - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + __rvm_fetch $rvm_gem_url + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi mkdir -p $rvm_source_path/$rvm_gem_package_name nice -n $rvm_niceness tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path fi # Well this is fun... fix nil error on require_paths: sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb - nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log - popd > /dev/null + nice -n $rvm_niceness $rvm_ruby_home/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_ruby_log_path/rubygems.install.log 2> $rvm_ruby_log_path/rubygems.install.error.log + popd 2> /dev/null - for binary in gem irb erb ri rdoc testrb ; do - sed -i.orig "2i\\ - ENV[\"GEM_HOME\"]=\"$rvm_gem_home\" - ENV[\"PATH\"]=\"$rvm_ruby_home/bin:$rvm_gem_home/bin:\" -" $rvm_install_path/$rvm_ruby_package_name/bin/$binary - done - - __rvm_log "info" "Installation of rubygems for $rvm_ruby_package_name is complete." - for rvm_gem_name in rake ; do __rvm_log "info" "Installing $rvm_gem_name" - nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log + nice -n $rvm_niceness $rvm_ruby_home/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_ruby_log_path/gems.install.log 2> $rvm_ruby_log_path/gems.error.log done - sed -i.orig "2i\\ - ENV[\"GEM_HOME\"]=\"$rvm_gem_home\" - ENV[\"PATH\"]=\"$rvm_ruby_home/bin:$rvm_gem_home/bin:\" + for binary in gem irb erb ri rdoc testrb rake ; do + if [ -x $rvm_ruby_home/bin/$binary ] ; then + string="ENV['GEM_HOME']='$rvm_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_gem_home/bin'" + 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_ruby_home/bin/$binary is missing" + fi + done -" $rvm_gem_home/bin/rake + __rvm_log "info" "Installation of rubygems for $rvm_ruby_package_name is complete." + if [ -x $rvm_gem_home/bin/$binary ] ; then + string="ENV['GEM_HOME']='$rvm_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_gem_home/bin'" + mv $rvm_gem_home/bin/$binary $rvm_gem_home/bin/$binary.orig + awk "NR==2 {print \"$string\"} {print}" $rvm_gem_home/bin/$binary.orig > $rvm_gem_home/bin/$binary + chmod +x $rvm_gem_home/bin/$binary + else + __rvm_log "warn" "$rvm_gem_home/bin/$binary is missing" + fi + binary=rake + mv $rvm_gem_home/bin/$binary $rvm_gem_home/bin/$binary.orig + awk "NR==2 {print \"$string\"} {print}" $rvm_gem_home/bin/$binary.orig > $rvm_gem_home/bin/$binary + unset binary } function __rvm_install-ruby { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi @@ -393,21 +411,21 @@ rvm_ruby_configure="" rvm_ruby_make="rake macruby:build framework_instdir=$rvm_install_path/macruby-head framework_name=/macruby-head --trace" rvm_ruby_make_install="rake framework:install framework_instdir=$rvm_install_path/macruby-head framework_name=/macruby-head --trace" rvm_ruby_rev="${rvm_ruby_rev:-head}" # Hard coding this for now - DESTDIR="$rvm_install_path/$rvm_ruby_package_name" ; export DESTDIR + DESTDIR="$rvm_ruby_home" ; export DESTDIR if [ -z "$rvm_ruby_rev" ] ; then # TODO: Check if tag v is valid - rvm_ruby_repo_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag - rvm_ruby_rev="" + #rvm_ruby_repo_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag + rvm_ruby_rev="head" # For now, until nightly release are available. else if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then - rvm_ruby_repo_url=$rvm_ruby_repo_url/trunk - rvm_ruby_rev="" + #rvm_ruby_repo_url=$rvm_ruby_repo_url/trunk + rvm_ruby_rev="head" else - rvm_ruby_repo_url=$rvm_ruby_repo_url/trunk + #rvm_ruby_repo_url=$rvm_ruby_repo_url/trunk rvm_ruby_rev="-r $rvm_ruby_rev" fi fi __rvm_install-source unset DESTDIR @@ -416,60 +434,61 @@ fi ;; ruby-enterprise|ree) 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_install_path/$rvm_ruby_package_name" + __rvm_log "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home" pushd $rvm_source_path > /dev/null - if [ -d $rvm_source_path/$rvm_ruby_package_name ] ; then - cd $rvm_source_path/$rvm_ruby_package_name + 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_curl $rvm_url - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + __rvm_fetch $rvm_url + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi __rvm_log "info" "\tExtracting $rvm_ruby_package_name..." - mkdir -p $rvm_source_path/$rvm_ruby_package_name + mkdir -p $rvm_ruby_src_path nice -n $rvm_niceness tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path fi - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi __rvm_log "info" "\tInstalling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..." - mkdir -p $rvm_log_path/$rvm_ruby_package_name + mkdir -p $rvm_ruby_log_path - cd $rvm_source_path/$rvm_ruby_package_name - nice -n $rvm_niceness ./installer -a $rvm_install_path/ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level --dont-install-useful-gems --no-tcmalloc > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi - chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/* + cd $rvm_ruby_src_path + nice -n $rvm_niceness ./installer -a $rvm_install_path/ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level --dont-install-useful-gems --no-tcmalloc > $rvm_ruby_log_path/install.log 2> $rvm_ruby_log_path/install.error.log + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi + chmod +x $rvm_ruby_home/bin/* - ln -fs $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name + ln -fs $rvm_ruby_home/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name __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 else - __rvm_curl $rvm_gem_url - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + __rvm_fetch $rvm_gem_url + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi mkdir -p $rvm_source_path/$rvm_gem_package_name nice -n $rvm_niceness tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path fi - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi # Well this is fun... fix nil error on require_paths: - sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb > $rvm_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log + sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb > $rvm_ruby_log_path/rubygems.install.log 2> $rvm_ruby_log_path/rubygems.install.error.log - nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log + nice -n $rvm_niceness $rvm_ruby_home/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_ruby_log_path/rubygems.install.log 2> $rvm_ruby_log_path/rubygems.install.error.log __rvm_log "info" "Installation of $rvm_ruby_package_name complete." - popd > /dev/null + popd 2> /dev/null for rvm_gem_name in rake ; do __rvm_log "info" "Installing $rvm_gem_name" - nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log + nice -n $rvm_niceness $rvm_ruby_home/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_ruby_log_path/gems.install.log 2> $rvm_ruby_log_path/gems.error.log done ;; rbx|rubinius) + __rvm_reset # Requires 1.8 to install due to parsetree. TOOD: Check for 1.8 + parse-tree rvm_ruby_repo_url=$rvm_rubinius_repo_url rvm_ruby_configure="" rvm_ruby_make="rake" rvm_ruby_make_install="rake install" #rvm_ruby_rev="head" @@ -477,64 +496,65 @@ if [ ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version -o ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git ] ; then rm -rf $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version git clone --depth 1 $rvm_ruby_repo_url $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version fi cd $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version && $rvm_rubinius_jit rake build - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi for binary in ruby irb ; do ln -fs $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/bin/rbx $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/bin/$binary done ;; 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_install_path/$rvm_ruby_package_name" - mkdir -p $rvm_log_path/$rvm_ruby_package_name + __rvm_log "info" "Installing jRuby to: $rvm_ruby_home" + mkdir -p $rvm_ruby_log_path pushd $rvm_source_path > /dev/null if [ ! -z "$rvm_ruby_rev" ] ; then if [ ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version -o ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git ] ; then - git clone --depth 1 $rvm_jruby_repo_url $rvm_source_path/$rvm_ruby_package_name - cd $rvm_source_path/$rvm_ruby_package_name && ant + git clone --depth 1 $rvm_jruby_repo_url $rvm_ruby_src_path + cd $rvm_ruby_src_path && ant fi else - if [ -d $rvm_source_path/$rvm_ruby_package_name ] ; then - cd $rvm_source_path/$rvm_ruby_package_name + 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_curl $rvm_url + __rvm_fetch $rvm_url __rvm_log "info" "\tExtracting $rvm_package_file..." nice -n $rvm_niceness unzip -q $rvm_archives_path/$rvm_package_file.zip -d $rvm_source_path - cd $rvm_source_path/$rvm_ruby_package_name + cd $rvm_ruby_src_path fi fi - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi __rvm_log "info" "\tInstalling $rvm_ruby_package_name..." - mkdir -p $rvm_install_path/$rvm_ruby_package_name/bin/ - rsync -ag $rvm_source_path/$rvm_ruby_package_name/ $rvm_install_path/$rvm_ruby_package_name/ - if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_ruby_package_name/*.error.log" ; return 1 ; fi - cd $rvm_source_path/$rvm_ruby_package_name/tool/nailgun && make > $rvm_log_path/$rvm_ruby_package_name/install.nailgun.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.nailgun.log - popd > /dev/null - chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/* + mkdir -p $rvm_ruby_home/bin/ + rsync -ag $rvm_ruby_src_path/ $rvm_ruby_home/ + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi + cd $rvm_ruby_src_path/tool/nailgun && make > $rvm_ruby_log_path/install.nailgun.log 2> $rvm_ruby_log_path/install.error.nailgun.log + popd 2> /dev/null + chmod +x $rvm_ruby_home/bin/* for binary in jruby jgem jirb ; do - ln -fs $rvm_install_path/$rvm_ruby_package_name/bin/$binary $rvm_install_path/$rvm_ruby_package_name/bin/${binary#j} + ln -fs $rvm_ruby_home/bin/$binary $rvm_ruby_home/bin/${binary#j} done - ln -fs $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name + ln -fs $rvm_ruby_home/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name for rvm_gem_name in rake jruby-openssl ; do __rvm_log "info" "Installing $rvm_gem_name" - nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/jgem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log + nice -n $rvm_niceness $rvm_ruby_home/bin/jgem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_ruby_log_path/gems.install.log 2> $rvm_ruby_log_path/gems.error.log done ;; ruby) + if [ -z "rvm_ruby_configure" ] ; then rvm_ruby_configure="--enable-shared=true" ; fi __rvm_install-source $* ;; default) __rvm_log "fail" "please specify a ruby implementation to install." @@ -690,12 +710,14 @@ rvm_ruby_home="${rvm_ruby_home:-"$rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version"}" else rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}" rvm_ruby_home="${rvm_ruby_home:-"$rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}" fi - rvm_ruby_irbrc="$rvm_ruby_home/.irbrc" + rvm_ruby_log_path="$rvm_log_path/$rvm_ruby_package_name" + rvm_ruby_src_path="$rvm_source_path/$rvm_ruby_package_name" rvm_ruby_binary="$rvm_ruby_home/bin/ruby" + rvm_ruby_irbrc="$rvm_ruby_home/.irbrc" rvm_selected=1 else unset rvm_selected fi @@ -781,15 +803,27 @@ } function __rvm_list { - echo -e "\nruby:\n$(/bin/ls -l $rvm_install_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }')\n" - echo -e "jruby:\n$(/bin/ls -l $rvm_install_path/ | awk '/jruby-.*/ { print " - " $NF }')\n" - echo -e "ree:\n$(/bin/ls $rvm_install_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }')\n" - echo -e "system:\n - ($($default_system_ruby -v))\n" + if [ "$rvm_all" ] ; then + svn list http://svn.ruby-lang.org/repos/ruby/tags/ | grep 'v1_[8|9]' | sed 's/^v1_//' | sed 's/\/$//' | awk -F'_' '{print "1."$1"."$2 " -l "$3}' | sed 's/p$//' + echo "jruby 1.2.0" + echo "jruby 1.3.0" + echo "jruby 1.3.1" + echo "jruby head" + echo "rubinius head" + echo "rbx head" + echo "ree 20090610" + else + echo -e "\nruby:\n$(/bin/ls -l $rvm_install_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }')\n" + echo -e "jruby:\n$(/bin/ls -l $rvm_install_path/ | awk '/jruby-.*/ { print " - " $NF }')\n" + echo -e "ree:\n$(/bin/ls $rvm_install_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }')\n" + echo -e "system:\n - ($($default_system_ruby -v))\n" + fi + } function __rvm_reset { PATH="$rvm_install_path/bin:$rvm_default_path" ; export PATH @@ -830,16 +864,14 @@ function __rvm_src-dir { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi - if [ "$rvm_ruby_interpreter" -a "$rvm_ruby_version" ] ; then - rvm_ruby_source_dir="$rvm_source_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level" - mkdir -p $rvm_ruby_source_dir - echo "$rvm_ruby_source_dir" - else + if [ -z "$rvm_ruby_src_path" ] ; then __rvm_log "fail" "No source directory exists for the default implementation." + else + echo "$rvm_ruby_src_path" fi } # clones from source implementation/version to current @@ -868,13 +900,17 @@ __rvm_log "fail" "Unknown $rvm_ruby_interpreter version: $rvm_ruby_version" fi } -function __rvm_execute { - if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi - $rvm_ruby_home/bin/ruby $rvm_ruby_args +function __rvm_run { + log_file="1" ; shift + command="$*" + if [ $rvm_debug ] ; then __rvm_log "debug" "Executing: $command" ; fi + eval "nice -n $rvm_niceness $command" > $rvm_ruby_log_path/log_file.log 2> $rvm_ruby_log_path/log_file.error.log + if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/log_file.error.log" ; popd 2> /dev/null ; return 1 ; fi + unset log_file command } function __rvm_cache { rvm_cache_file="$rvm_config_path/cache" touch $rvm_cache_file @@ -899,11 +935,11 @@ fi fi } function __rvm_cleanup-variables { - unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_install_path rvm_debug rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message IRBRC rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_delete_flag rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_make_install rvm_config_path rvm_bin_path rvm_force rvm_set_prompt + unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_install_path rvm_debug rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message IRBRC rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_delete_flag rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_make_install rvm_config_path rvm_bin_path rvm_force rvm_set_prompt rvm_all } function __rvm_get-user-defaults { # NOW load defaults settings. TODO: root user loads /etc/rvmrc if [ -s ~/.rvmrc ] ; then source ~/.rvmrc ; fi @@ -911,17 +947,19 @@ function __rvm_parse-args { while [ $# -gt 0 ] ; do rvm_token="$1" ; shift case "$rvm_token" in - install|uninstall|path|info|setup|version|srcdir|list|symlinks|reset|debug|reload|usage|help|implode) + install|uninstall|path|info|setup|version|srcdir|list|symlinks|reset|debug|reload|usage|help|implode|update) rvm_action=$rvm_token ;; use) rvm_action=$rvm_token - if [ "$1" = "default" -o -z "$1" ] ; then + if [ "$1" = "default" ] ; then rvm_ruby_interpreter="system" ; shift + elif [ -z "$1" ] ; then + rvm_ruby_interpreter="system" fi ;; ruby|jruby|ree|macruby|rbx|rubinius|default|all) rvm_ruby_interpreter="$rvm_token" @@ -1007,11 +1045,11 @@ -S|--source) rvm_source_path="$1" ; shift ;; -A|--archive) rvm_archives_path="$1" ; shift ;; -G|--gems) rvm_gem_path="$1" ; shift ;; -C|--configure) if [ ! -z "$1" ] ; then - rvm_ruby_configure="$(echo $1 | tr ',-' ' -')" + rvm_ruby_configure="$(echo $1 | tr ',' ' ')" shift else rvm_action="error" rvm_error_message="--configure *must* be followed by configure flags." break; @@ -1022,13 +1060,15 @@ -l|--level) rvm_ruby_patch_level="$1" ; shift ;; -n|--nice) rvm_niceness="$1" ; shift ;; -f|--file) rvm_ruby_args="$1" ; shift ;; -h|--help) rvm_action=help ; shift ;; -d|--default) rvm_set_default=1 ;; + --head) rvm_ruby_rev="head" ;; --trace|--debug) rvm_debug=1 ;; --force) rvm_force=1 ;; --set-prompt) rvm_set_prompt=1 ;; + --all) rvm_all=1 ; shift ;; -m|--gem-set) rvm_gem_set_name="$1" ; shift ;; --rm-gem-set) rvm_gem_set_name_rm="$1" ; shift ;; --jit) rvm_rubinius_jit="RBX_LLVM=1" ;; default|system) @@ -1041,11 +1081,11 @@ break; esac if [ ! -z "$rvm_ruby_args" -o ! -z "$rvm_error_message" ] ; then break; fi done - if [ ! -z "$rvm_error_message" ] ; then return 1 ; fi + if [ ! -z "$rvm_error_message" ] ; then popd 2> /dev/null ; return 1 ; fi if [ -z "$rvm_debug" ] ; then set +x ; else set -x ; fi } function rvm { @@ -1098,10 +1138,23 @@ ;; reset) __rvm_reset ;; # TODO: how can we use bin_path here for reload, default file? reload) source ~/.rvm/scripts/rvm ;; implode) __rvm_implode ;; - error) __rvm_log "fail" "$rvm_error_message ( see: rvm usage )" ; return 1; ;; + update) + if [ "$rvm_ruby_rev" = "head" ] ; then + if [ -d $rvm_source_path/rvm/.git ] ; then + cd $rvm_source_path/rvm/ && git pull origin master + else + cd $rvm_source_path && git clone git://github.com/wayneeseguin/rvm.git && cd rvm/ + fi + ./scripts/rvm-update + else + # TODO: rvm_install_path: + gem install rvm --no-rdoc --no-ri -q && rvm-update && source ~/.rvm/scripts/rvm + fi + ;; + error) __rvm_log "fail" "$rvm_error_message ( see: rvm usage )" ; popd 2> /dev/null ; return 1; ;; info|debug) __rvm_version cat <<-Info ruby: