scripts/manage in rvm-0.1.41 vs scripts/manage in rvm-0.1.42
- old
+ new
@@ -4,10 +4,17 @@
original_ruby_string=$rvm_ruby_string
source "$rvm_scripts_path/base"
source "$rvm_scripts_path/patches"
+__rvm_check_for_clang() {
+ if [[ -n "$rvm_clang_flag" ]] && ! command -v clang >/dev/null ; then
+ $rvm_scripts_path/log "fail" "You passed the --clang option and clang isn't in your path. Please try again / don't use --clang"
+ return 1
+ fi
+}
+
# Checks for bison, returns zero iff it is found
__rvm_check_for_bison() {
if [[ "$rvm_head_flag" -gt 0 ]]; then
if ! command -v bison >/dev/null ; then
$rvm_scripts_path/log "fail" "bison is not available in your path. Please ensure it exists before compiling from head."
@@ -58,11 +65,11 @@
__rvm_install_source() {
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
$rvm_scripts_path/log "info" "Installing Ruby from source to: $rvm_ruby_home"
__rvm_pushpop "$rvm_src_path"
- if [[ ! -z "$rvm_force_flag" ]] ; then rm -rf "$rvm_ruby_home" "$rvm_ruby_src_path" ; fi
+ if [[ -n "$rvm_force_flag" ]] ; then rm -rf "$rvm_ruby_home" "$rvm_ruby_src_path" ; fi
result=0
__rvm_fetch_ruby
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error fetching the ruby interpreter. Aborting the installation." ; __rvm_pushpop ; return $result
@@ -89,21 +96,23 @@
else
result=$? ; $rvm_scripts_path/log "fail" "rvm requires autoconf to install the selected ruby interpreter however autoconf was not found in the PATH." ; return $result
fi
fi
- if [[ ! -z "$rvm_ruby_configure" ]] ; then
+ if [[ -n "$rvm_ruby_configure" ]] ; then
__rvm_run "configure" "$rvm_ruby_configure"
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while configuring. Aborting the installation." ; __rvm_pushpop ; return $result
fi
elif [[ -s ./configure ]] ; then
# REE stores configure flags differently for head vs. the distributed release.
if [[ "ree" != "$rvm_ruby_interpreter" ]]; then
__rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
fi
- __rvm_run "configure" "./configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_ruby_configure_flags $configure_parameters" "Configuring $rvm_ruby_string, this may take a while depending on your cpu(s)..."
+
+ local configure_command="./configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_ruby_configure_flags $configure_parameters"
+ __rvm_run "configure" "$configure_command" "Configuring $rvm_ruby_string, this may take a while depending on your cpu(s)..."
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while running configure. Aborting the installation." ; __rvm_pushpop ; return $result
fi ; unset configure_parameters db_configure_flags
else
$rvm_scripts_path/log "error" "Skipping configure step, 'configure' does not exist, did autoconf not run successfully?"
@@ -138,17 +147,22 @@
__rvm_install_ruby() {
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
- if [[ ! -z "$RUBYOPT" ]] ; then ruby_options="$RUBYOPT" ; unset RUBYOPT ; fi
+ if [[ -n "$RUBYOPT" ]] ; then ruby_options="$RUBYOPT" ; unset RUBYOPT ; fi
+
+ # Check for clang if the flag is set
+ __rvm_check_for_clang
+ local result="$?"
+ [[ "$result" -gt 0 ]] && return $result
case "$rvm_ruby_interpreter" in
macruby)
if [[ "Darwin" = "$(uname)" ]] ; then
if [[ "$rvm_head_flag" = 1 ]] ; then
- if [[ ! -z "$rvm_llvm_flag" ]] ; then
+ if [[ -n "$rvm_llvm_flag" ]] ; then
$rvm_scripts_path/package llvm install
fi
macruby_path="/usr/local/bin"
# TODO: configure & make variables should be set here.
rvm_ruby_configure=" true "
@@ -215,11 +229,11 @@
$rvm_scripts_path/log "fail" "MacRuby can only be installed on a Darwin OS."
fi
;;
ree)
- if [[ ! -z "$(echo $rvm_ruby_version | awk '/^1\.8/')" ]] && [[ -z "$rvm_head_flag" ]] ; then
+ if [[ -n "$(echo $rvm_ruby_version | awk '/^1\.8/')" ]] && [[ -z "$rvm_head_flag" ]] ; then
rvm_url="$(__rvm_db "ree_${rvm_ruby_version}_url")/$rvm_ruby_package_file.tar.gz"
$rvm_scripts_path/log "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home"
__rvm_pushpop "$rvm_src_path"
if [[ -z "$rvm_force_flag" ]] && [[ -d "$rvm_ruby_src_path" ]] && [[ ! -x "$rvm_ruby_src_path/installer" ]] ; then
$rvm_scripts_path/log "It appears that the archive has already been extracted. Skipping extract (use --force to force re-download and extract)."
@@ -240,11 +254,11 @@
mv "$rvm_src_path/$rvm_ruby_package_file" "$rvm_ruby_src_path"
fi
builtin cd "$rvm_ruby_src_path"
mkdir -p "${rvm_ruby_home}/lib/ruby/gems/1.8/gems"
- if [[ ! -z "$rvm_ruby_configure_flags" ]] ; then
+ if [[ -n "$rvm_ruby_configure_flags" ]] ; then
rvm_ruby_configure_flags="$(echo $rvm_ruby_configure_flags | sed 's#--#-c --#g')"
fi
if [[ "Darwin" = "$(uname)" ]] && [[ "1.8.6" = "$rvm_ruby_version" ]] && [[ -z "$rvm_ree_options" ]] ; then
rvm_ree_options="${rvm_ree_options} --no-tcmalloc"
@@ -304,11 +318,13 @@
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to extract the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
- mv $rvm_src_path/rubinius-${rvm_ruby_version} ${rvm_ruby_src_path}
+ # Remove the left over folder first.
+ rm -rf "$rvm_ruby_src_path"
+ mv "$rvm_src_path/rubinius-${rvm_ruby_version}" "$rvm_ruby_src_path"
else
__rvm_db "rubinius_repo_url" "rvm_ruby_repo_url"
#rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_interpreter-$rvm_ruby_version"
__rvm_fetch_from_github "rbx"
result=$? ; if [[ "$result" -gt 0 ]] ; then
@@ -386,11 +402,11 @@
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to fetch the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
builtin cd "$rvm_ruby_src_path"
- if [[ ! -z "$rvm_head_flag" ]] ; then __rvm_run "ant.dist" "ant dist" "Running 'ant dist' (this could take a few minutes) ..." ; fi
+ if [[ -n "$rvm_head_flag" ]] ; then __rvm_run "ant.dist" "ant dist" "Running 'ant dist' (this could take a few minutes) ..." ; fi
mkdir -p "$rvm_ruby_home/bin/"
if $rvm_scripts_path/match "$rvm_ruby_version" "1\.3" || $rvm_scripts_path/match "$rvm_ruby_version" "1\.2" ; then
__rvm_run "nailgun" "builtin cd \"$rvm_ruby_src_path/tool/nailgun\" && make $rvm_make_flags" "Building Nailgun"
else
@@ -442,19 +458,19 @@
$rvm_scripts_path/log "error" "Prerequisite checks have failed. Aborting the installation." ; __rvm_pushpop ; return $result
fi
__rvm_pushpop $rvm_src_path
- if [[ ! -d "$rvm_src_path/$rvm_ruby_string" ]] || [[ ! -z "$rvm_force_flag" ]] ; then
+ if [[ ! -d "$rvm_src_path/$rvm_ruby_string" ]] || [[ -n "$rvm_force_flag" ]] ; then
rm -rf "$rvm_src_path/$rvm_ruby_string/" "$rvm_src_path/$rvm_ruby_string/"
__rvm_fetch_ruby
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to fetch the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
fi
- if [[ ! -z "$rvm_head_flag" ]] ; then
+ if [[ -n "$rvm_head_flag" ]] ; then
builtin cd $rvm_ruby_src_path
rvm_gemstone_package_file="GemStone-$(grep ^GEMSTONE version.txt | cut -f2 -d-).$(uname -sm | tr ' ' '-')"
rvm_gemstone_url="${rvm_gemstone_url:-"$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"}"
fi
@@ -495,11 +511,11 @@
for binary in maglev-ruby maglev-irb maglev-gem ; do
__rvm_inject_gem_env $rvm_ruby_home/bin/$binary
done ; unset binary
builtin cd "$rvm_ruby_home"
- if [[ ! -z "$rvm_head_flag" ]] ; then
+ if [[ -n "$rvm_head_flag" ]] ; then
git submodule update --init
$rvm_ruby_home/bin/maglev force-reload
ln -sf maglev.demo.key-$(uname -sm | tr ' ' '-') etc/maglev.demo.key
fi
@@ -630,18 +646,19 @@
fi
fi
if [[ -s ./Makefile ]] && [[ -z "$rvm_reconfigure_flag" ]] ; then
(($rvm_debug_flag)) && $rvm_scripts_path/log "debug" "Skipping configure step, Makefile exists so configure must have already been run."
- elif [[ ! -z "$rvm_ruby_configure" ]] ; then
+ elif [[ -n "$rvm_ruby_configure" ]] ; then
__rvm_run "configure" "$rvm_ruby_configure"
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to configure the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
elif [[ -s ./configure ]] ; then
- __rvm_run "configure" "./configure --prefix=$rvm_ruby_home $rvm_ruby_configure_flags" "Configuring $rvm_ruby_string using $rvm_ruby_configure_flags, this may take a while depending on your cpu(s)..."
+ local configure_command="./configure --prefix=$rvm_ruby_home $rvm_ruby_configure_flags"
+ __rvm_run "configure" "" "Configuring $rvm_ruby_string using $rvm_ruby_configure_flags, this may take a while depending on your cpu(s)..."
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to configure the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
else
$rvm_scripts_path/log "error" "Skipping configure step, 'configure' script does not exist, did autoconf not run successfully?"
@@ -688,11 +705,11 @@
esac
rvm_hook="after_install" ; source $rvm_scripts_path/hook
- if [[ ! -z "$ruby_options" ]] ; then RUBYOPT=$ruby_options ; export RUBYOPT ; fi
+ if [[ -n "$ruby_options" ]] ; then RUBYOPT=$ruby_options ; export RUBYOPT ; fi
}
__rvm_fetch_from_github() {
rm -rf "$rvm_ruby_src_path"
if [[ ! -d "$rvm_ruby_repo_path/.git" ]] ; then
@@ -733,11 +750,11 @@
$rvm_scripts_path/log "error" "There has been an error while trying to fetch the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
fi
# Only re-extract if forced.
- if [[ ! -d "$rvm_src_path/$rvm_ruby_string" ]] || [[ ! -z "$rvm_force_flag" ]] ; then
+ if [[ ! -d "$rvm_src_path/$rvm_ruby_string" ]] || [[ -n "$rvm_force_flag" ]] ; then
if [[ "tar.gz" = "$rvm_archive_extension" ]] || [[ "tgz" = "$rvm_archive_extension" ]] ; then
__rvm_run "extract" "cat $rvm_archives_path/$rvm_ruby_package_file.$rvm_archive_extension | gunzip | tar xf - -C $rvm_src_path" "Extracting $rvm_ruby_package_file ..."
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to extract the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
@@ -750,11 +767,11 @@
else
$rvm_scripts_path/log "info" "$rvm_ruby_src_path has already been extracted." ; __rvm_pushpop ; return 0
fi
else
mkdir -p "$rvm_repo_path"
- if [[ ! -z "$(echo $rvm_url | awk '/^git/')" ]] ; then
+ if [[ -n "$(echo $rvm_url | awk '/^git/')" ]] ; then
if [[ -d "$rvm_ruby_repo_path/.git" ]] ; then
builtin cd $rvm_ruby_repo_path
if [[ -z "$rvm_ruby_revision" ]] ; then
$rvm_scripts_path/log "info" "Pulling from $rvm_ruby_repo_url, this may take a while depending on your connection..."
git pull origin master --force
@@ -778,14 +795,14 @@
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to fetch the repository. Aborting the installation." ; __rvm_pushpop ; return $result
fi
fi
else
- if [[ ! -z "$rvm_ruby_tag" ]] ; then
+ if [[ -n "$rvm_ruby_tag" ]] ; then
# TODO: Check if tag v is valid
rvm_url="${rvm_url:-"$rvm_ruby_repo_url/tags/$(echo $rvm_ruby_tag | sed 's/^t//')"}"
- elif [[ -z "$rvm_ruby_version" ]] && [[ ! -z "$rvm_head_flag" ]] ; then
+ elif [[ -z "$rvm_ruby_version" ]] && [[ -n "$rvm_head_flag" ]] ; then
rvm_url="${rvm_url:-"$rvm_ruby_repo_url/trunk"}"
elif [[ "$rvm_major_version" = "9" ]] ; then
if [[ -z "$rvm_minor_version" ]] || [[ "$rvm_minor_version" = 3 ]] ; then
rvm_url="${rvm_url:-"$rvm_ruby_repo_url/trunk"}"
else
@@ -796,20 +813,20 @@
else
rvm_url="${rvm_url:-"$rvm_ruby_repo_url/branches/ruby_${rvm_release_version}_${rvm_major_version}_${rvm_minor_version}"}"
fi
rvm_rev=""
- if [ ! -z "$rvm_ruby_revision" ] ; then
+ if [ -n "$rvm_ruby_revision" ] ; then
rvm_rev="-$rvm_ruby_revision"
fi
if [[ -d "$rvm_ruby_repo_path/.svn" ]] ; then
builtin cd $rvm_ruby_repo_path
$rvm_scripts_path/log "info" "Updating ruby from $rvm_url"
__rvm_run "svn.switch" "svn switch $rvm_url"
__rvm_run "svn.update" "svn update"
- if [[ ! -z "$rvm_rev" ]] ; then
+ if [[ -n "$rvm_rev" ]] ; then
$rvm_scripts_path/log "info" "Checking out revision ${rvm_rev/-r/-r } from $rvm_url"
__rvm_run "svn.checkout" "svn update -q ${rvm_rev/-r/-r }"
fi
else
rm -rf $rvm_ruby_repo_path
@@ -836,11 +853,11 @@
}
__rvm_uninstall_ruby() {
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
- if [[ ! -z "$rvm_ruby_string" ]] ; then
+ if [[ -n "$rvm_ruby_string" ]] ; then
for dir in $rvm_rubies_path ; do
if [[ -d $dir/$rvm_ruby_string ]] ; then
$rvm_scripts_path/log "info" "Removing $dir/$rvm_ruby_string..."
rm -rf $dir/$rvm_ruby_string
else
@@ -860,11 +877,11 @@
}
__rvm_remove_ruby() {
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
- if [[ ! -z "$rvm_ruby_string" ]] ; then
+ if [[ -n "$rvm_ruby_string" ]] ; then
for dir in $rvm_src_path $rvm_rubies_path ; do
if [[ -d $dir/$rvm_ruby_string ]] ; then
$rvm_scripts_path/log "info" "Removing $dir/$rvm_ruby_string..."
rm -rf $dir/$rvm_ruby_string
else
@@ -888,11 +905,11 @@
$rvm_scripts_path/log "fail" "Cannot remove unknown package '$rvm_ruby_string'"
fi ; unset rvm_remove_flag
}
__rvm_remove_gemsets() {
- if [[ ! -z "$rvm_gems_flag" ]] ; then
+ if [[ -n "$rvm_gems_flag" ]] ; then
$rvm_scripts_path/log "info" "Removing $rvm_ruby_string gemsets..."
gemsets="$rvm_gems_path/$rvm_ruby_string $(\ls -d "${rvm_gems_path}"/* | awk '/'$rvm_ruby_string'@/')"
for gemset in $gemsets ; do
if [[ -d "$gemset" ]] ; then
rm -rf "$gemset"
@@ -925,11 +942,11 @@
$rvm_scripts_path/alias delete "$alias_name" >/dev/null 2>&1
done ; unset alias_name aliases
}
__rvm_remove_archives() {
- if [[ ! -z "$rvm_archive_flag" ]] ; then
+ if [[ -n "$rvm_archive_flag" ]] ; then
$rvm_scripts_path/log "info" "Removing $rvm_ruby_string archives..."
rm -f $rvm_archives_path/${rvm_ruby_package_file}.${rvm_archive_extension}
fi
}
@@ -985,11 +1002,11 @@
__rvm_run_with_env "docs.generate" "$rvm_ruby_string" "rvm docs generate-ri" "Attempting to generate ri documentation..."
fi
}
__rvm_rubygems_setup() {
- if [[ ! -z "$(echo $rvm_ruby_version | awk '/^1\.9/')" ]] || [[ ! -z "$(echo $rvm_ruby_interpreter | awk '/^mput/')" ]] ; then
+ if [[ -n "$(echo $rvm_ruby_version | awk '/^1\.9/')" ]] || [[ -n "$(echo $rvm_ruby_interpreter | awk '/^mput/')" ]] ; then
install=0
elif [[ "$rvm_ruby_string" = "ruby-head" ]] ; then
install=0
else
install=1
@@ -1026,13 +1043,13 @@
fi
else
ruby_lib_gem_path="${directory_name}/${version_number}"
fi
unset directory_name version_number
- elif [[ ! -z "$(echo $rvm_ruby_interpreter | awk '/^rbx|jruby/')" ]] ; then
+ elif [[ -n "$(echo $rvm_ruby_interpreter | awk '/^rbx|jruby/')" ]] ; then
# Hands off rubygems for rbx & jruby
- if [[ ! -z "$rvm_debug_flag" ]] ; then $rvm_scripts_path/log "debug" "Skipping rubygems update for $rvm_ruby_version" ; fi
+ if [[ -n "$rvm_debug_flag" ]] ; then $rvm_scripts_path/log "debug" "Skipping rubygems update for $rvm_ruby_version" ; fi
ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/jruby"
else
$rvm_scripts_path/log "info" "Installing rubygems dedicated to $rvm_ruby_string..."
rvm_rubygems_version="$(__rvm_db "${rvm_ruby_interpreter}_rubygems_version")"
rvm_rubygems_version="${rvm_rubygems_version:-"$(__rvm_db "rubygems_version")"}"
@@ -1065,11 +1082,11 @@
$rvm_scripts_path/log "warning" "Installation of rubygems $rvm_ruby_package_name did not complete successfully."
fi
__rvm_inject_ruby_shebang "$rvm_ruby_home/bin/gem"
- if [[ ! -z "$rvm_major_version" ]] ; then
+ if [[ -n "$rvm_major_version" ]] ; then
ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/${rvm_release_version}.$rvm_major_version"
else
ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/$interpreter"
fi
fi
@@ -1102,16 +1119,16 @@
}
__rvm_inject_gem_env() {
__rvm_actual_file $1
if [[ -f "$actual_file" ]] ; then
- if [[ ! -z "$(head -n 1 $actual_file | awk '/[j]*ruby/')" ]] ; then
+ if [[ -n "$(head -n 1 $actual_file | awk '/[j]*ruby/')" ]] ; then
string="ENV['GEM_HOME']=ENV['GEM_HOME'] || '$rvm_ruby_gem_home'\nENV['GEM_PATH']=ENV['GEM_PATH'] || '$rvm_ruby_gem_path'\nENV['PATH']='$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin:$rvm_ruby_home/bin:' + ENV['PATH']\nENV['BUNDLE_PATH']=ENV['BUNDLE_PATH'] || '$rvm_ruby_gem_home'\n"
- elif [[ ! -z "$(head -n 1 $actual_file | awk '/bash/')" ]] ; then
+ elif [[ -n "$(head -n 1 $actual_file | awk '/bash/')" ]] ; then
string="GEM_HOME=\${GEM_HOME:-'$rvm_ruby_gem_home'}\nGEM_PATH=\${GEM_PATH:-'$rvm_ruby_gem_path'}\nPATH=$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin:$rvm_ruby_home/bin:\$PATH\nBUNDLE_PATH=\${BUNDLE_PATH:-'$rvm_ruby_gem_home'}\n"
fi
- if [[ ! -z "$string" ]] ; then
+ if [[ -n "$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
@@ -1131,11 +1148,11 @@
rvm_ruby_gem_home=$(echo $rvm_ruby_gem_home | awk -F${rvm_gemset_separator} '{print $1}')
rvm_ruby_string=$(echo $rvm_ruby_string | awk -F${rvm_gemset_separator} '{print $1}')
local manage_result=0
- if [[ ! -z "$rubies_string" ]] ;then
- for rvm_ruby_string in $(echo $rubies_string | tr ',' ' ') ; do
+ if [[ -n "$rubies_string" ]] ;then
+ for rvm_ruby_string in $(echo "$rubies_string" | tr ',' ' ') ; do
eval "__rvm_${rvm_action}_ruby"
__rvm_unset_ruby_variables
done
else # all
if [[ "$rvm_action" != "install" ]] ; then