scripts/manage in rvm-0.1.38 vs scripts/manage in rvm-0.1.39
- old
+ new
@@ -53,22 +53,37 @@
__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
- __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
+ # 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)..."
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?"
fi
if [[ ! -z "$rvm_ruby_patch" ]] ; then
for patch in $(echo $rvm_ruby_patch | tr ',' ' ') ; do
- __rvm_run "patch" "patch -p0 -f < $patch" "Applying patch '$patch'..."
+ # detecting patch prefix (see '-p' option desc for 'patch')
+ # patch prefix is separated from patch path with '%' symbol
+ patch_prefix_separator='%'
+ # default prefix is 0
+ rvm_patch_prefix=0
+ # checking, if the patch file path has a prefix separator
+ patch_has_prefix=$(echo $patch | grep -q ${patch_prefix_separator}; echo $?)
+ if [[ "x${patch_has_prefix}" = "x0" ]]; then
+ # so, if it has...
+ rvm_patch_prefix=$(echo $patch | cut -d ${patch_prefix_separator} -f 2)
+ patch=$(echo $patch | cut -d ${patch_prefix_separator} -f 1)
+ fi
+ __rvm_run "patch" "patch -p${rvm_patch_prefix} -f < $patch" "Applying patch '$patch'..."
if [[ $? -gt 0 ]] ; then
$rvm_scripts_path/log "error" "Patch $patch did not apply cleanly... back to the patching board :(" ; exit 1
fi
done
fi
@@ -99,11 +114,11 @@
__rvm_post_install
__rvm_pushpop
}
__rvm_install_ruby() {
-
+
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
if [[ ! -z "$RUBYOPT" ]] ; then ruby_options="$RUBYOPT" ; unset RUBYOPT ; fi
case "$rvm_ruby_interpreter" in
@@ -269,31 +284,24 @@
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"
- if [[ ! -d "$rvm_ruby_repo_path" ]] || [[ ! -d "$rvm_ruby_repo_path/.git" ]] ; then
- rm -rf "$rvm_ruby_repo_path" "$rvm_ruby_src_path"
- builtin cd "$rvm_home"
- __rvm_run "rbx.repo" "git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_repo_path" "Cloning $rvm_ruby_repo_url"
- __rvm_run "rbx.copy" "cp -R \"$rvm_ruby_repo_path\" \"$rvm_ruby_src_path\"" "Copying from repo to source..."
- builtin cd "$rvm_ruby_src_path"
- else
- builtin cd "$rvm_ruby_src_path"
- __rvm_run "rbx.repo" "git pull origin master" "Pulling from origin master"
- fi
+ __rvm_fetch_from_github "rbx"
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while fetching the rbx git repo. Aborting the installation." ; __rvm_pushpop ; return $result
fi
fi
builtin cd "$rvm_ruby_src_path" ; chmod +x ./configure
__rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
+ export ruby="$rvm_bin_path/ruby-1.8.7-p$(__rvm_db "ruby_1.8.7_patch_level")"
+
rvm_ruby_configure_flags="${rvm_ruby_configure_flags:-"--skip-system"}"
- rvm_ruby_configure="ruby configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_ruby_configure_flags" ; message="Configuring rbx"
+ rvm_ruby_configure="$ruby configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_ruby_configure_flags" ; message="Configuring rbx"
if [[ "$rvm_llvm_flag" = "0" ]] ; then
rvm_ruby_configure="$rvm_ruby_configure --disable-llvm"
else
if [[ "$rvm_ruby_patch_level" = "rc1" ]] ; then
rvm_ruby_configure="$rvm_ruby_configure --enable-llvm"
@@ -303,29 +311,30 @@
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while running '$rvm_ruby_configure'. Aborting the installation." ; __rvm_pushpop ; return $result
fi
if [[ "$rvm_trace_flag" -eq 1 ]] ; then
- rvm_ruby_make="$rvm_bin_path/ruby-1.8.7-p$(__rvm_db "ruby_1.8.7_patch_level") -S rake install --trace" ; message="Compiling rbx (with --trace)"
+ rvm_ruby_make="$ruby -S rake install --trace" ; message="Compiling rbx (with --trace)"
else
- rvm_ruby_make="$rvm_bin_path/ruby-1.8.7-p$(__rvm_db "ruby_1.8.7_patch_level") -S rake install" ; message="Compiling rbx"
+ rvm_ruby_make="$ruby -S rake install" ; message="Compiling rbx"
fi
__rvm_run "rake" "$rvm_ruby_make" "$message"
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while running '$rvm_ruby_configure'. Aborting the installation." ; __rvm_pushpop ; return $result
fi
+ unset ruby
+
# Symlink rubinius wrappers
ln -fs "$rvm_ruby_home/bin/rbx" "$rvm_ruby_home/bin/irb"
ln -fs "$rvm_ruby_home/bin/rbx" "$rvm_ruby_home/bin/ruby"
# Install a wrapper around gem.
file_name="$rvm_ruby_home/bin/gem"
- if [[ ! -f "$file_name" ]]; then
- echo "#!/usr/bin/env bash" > "$file_name"
- echo "exec $rvm_ruby_home/bin/rbx gem \"\$@\"" >> "$file_name"
- [[ -f "$file_name" ]] && chmod +x "$file_name"
- fi
+ cp -f "$rvm_ruby_home/lib/bin/gem.rb" "$file_name"
+
+ __rvm_inject_ruby_shebang "$file_name"
+ [[ -f "$file_name" ]] && chmod +x "$file_name"
unset file_name
binaries="erb ri rdoc"
__rvm_post_install
__rvm_irbrc
@@ -560,22 +569,12 @@
PATH=$(echo $PATH | tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)
PATH=$rvm_bin_path:$PATH ; export PATH
rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_interpreter-$rvm_ruby_version"
- builtin cd $rvm_src_path
+ __rvm_fetch_from_github "mput" "trunk"
- if [[ ! -d "$rvm_ruby_src_path" ]] || [[ ! -d "$rvm_ruby_src_path/.git" ]] ; then
- rm -rf $rvm_ruby_src_path $rvm_ruby_repo_path
- __rvm_run "mput.repo" "git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_repo_path" "Cloning $rvm_ruby_repo_url"
- __rvm_run "mput.copy" "cp -R \"$rvm_ruby_repo_path\" \"$rvm_ruby_src_path\"" "Copying from repo to source..."
- builtin cd $rvm_ruby_src_path
- else
- builtin cd $rvm_ruby_src_path
- __rvm_run "mput.repo" "git pull origin trunk" "Pulling from origin trunk"
- fi
-
if [[ ! -s "$rvm_ruby_src_path/configure" ]] ; then
if command -v autoconf &> /dev/null ; then
__rvm_run "autoconf" "autoconf" "Running autoconf"
else
$rvm_scripts_path/log "fail" "rvm expects autoconf to install this ruby interpreter, autoconf was not found in PATH. Aborting installation." ; result=$? ; return $result
@@ -637,19 +636,31 @@
;;
*) $rvm_scripts_path/log "fail" "Ruby interpreter '$rvm_ruby_interpreter' is not known."
esac
-
- # Import the initial gemsets.
- (source $rvm_scripts_path/rvm; rvm use "$rvm_ruby_string"; $rvm_scripts_path/gemsets initial)
rvm_hook="after_install" ; source $rvm_scripts_path/hook
if [[ ! -z "$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
+ rm -rf "$rvm_ruby_repo_path"
+ builtin cd "$rvm_home"
+ __rvm_run "$1.repo" "git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_repo_path" "Cloning $rvm_ruby_repo_url"
+ else
+ local branch="${2:-"master"}"
+ builtin cd "$rvm_ruby_repo_path"
+ __rvm_run "$1.repo" "git pull origin $branch" "Pulling from origin $branch"
+ fi
+ __rvm_run "$1.copy" "cp -R \"$rvm_ruby_repo_path\" \"$rvm_ruby_src_path\"" "Copying from repo to source..."
+ builtin cd "$rvm_ruby_src_path"
+}
+
__rvm_fetch_ruby() {
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
if [[ -z "$rvm_head_flag" ]] && [[ -z "$rvm_ruby_tag" ]] && [[ -z "$rvm_ruby_revision" ]] ; then
rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_string"}"
@@ -695,11 +706,11 @@
if [[ ! -z "$(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
+ git pull origin master --force
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to update the source from the remote repository. Aborting the installation." ; __rvm_pushpop ; return $result
fi
else
if [[ -z "$rvm_ruby_sha" ]] ; then
@@ -710,12 +721,13 @@
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to checkout the source branch. Aborting the installation." ; __rvm_pushpop ; return $result
fi
fi
else
+ rm -rf "$rvm_ruby_repo_path"
$rvm_scripts_path/log "info" "Cloning from $rvm_ruby_repo_url, this may take a while depending on your connection..."
- git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_repo_path
+ git clone --depth 1 "$rvm_ruby_repo_url" "$rvm_ruby_repo_path"
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
@@ -758,20 +770,20 @@
$rvm_scripts_path/log "error" "There has been an error while trying to fetch / update the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
fi
$rvm_scripts_path/log "info" "Copying from repo to src path..."
- cp -r "$rvm_ruby_repo_path" "$rvm_ruby_src_path"
+ rm -rf "$rvm_ruby_src_path"
+ cp -R "$rvm_ruby_repo_path" "$rvm_ruby_src_path"
fi
}
__rvm_check_default() {
default_ruby_interpreter="$(rvm alias show default 2>/dev/null | awk -F"${rvm_gemset_seperator:-"@"}" '{print $1}')"
current_ruby_interpreter="$(echo "$rvm_ruby_string" | awk -F"${rvm_gemset_seperator:-"@"}" '{print $1}')"
if [[ -n "$current_ruby_interpreter" && "$current_ruby_interpreter" == "$default_ruby_interpreter" ]]; then
- # In a new subshell, set the default interpeter to system.
- (source $rvm_scripts_path/rvm; rvm use system --default)
+ __rvm_run_with_env 'default.restore' 'system' 'rvm use system --default' 'Removing default ruby interpreter'
fi
unset default_ruby_interpreter current_ruby_interpreter
}
__rvm_uninstall_ruby() {
@@ -816,23 +828,63 @@
__rvm_check_default
done ; unset dir
__rvm_remove_gemsets
+ __rvm_remove_archives
+ __rvm_remove_aliases
+ __rvm_remove_wrappers
+ __rvm_remove_environments
else
- $rvm_scripts_path/log "fail" "Cannot uninstall unknown package '$rvm_ruby_string'"
+ $rvm_scripts_path/log "fail" "Cannot remove unknown package '$rvm_ruby_string'"
fi ; unset rvm_remove_flag
}
__rvm_remove_gemsets() {
+ $rvm_scripts_path/log "info" "Removing $rvm_ruby_string gemsets..."
if [[ ! -z "$rvm_gems_flag" ]] ; then
- if [[ -d "$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}${rvm_gemset_name}" ]] ; then
- rm -rf $rvm_gems_path/${rvm_ruby_string}*
- fi
+ 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"
+ fi
+ done ; unset gemset gemsets
fi
}
+__rvm_remove_wrappers() {
+ $rvm_scripts_path/log "info" "Removing $rvm_ruby_string wrappers..."
+ wrappers="$rvm_wrappers_path/$rvm_ruby_string $(ls -d "$rvm_wrappers_path"/* | awk '/'$rvm_ruby_string'@/')"
+ for wrapper in $wrappers ; do
+ rm -rf "$wrapper"
+ done ; unset wrapper wrappers
+}
+__rvm_remove_environments() {
+ $rvm_scripts_path/log "info" "Removing $rvm_ruby_string environments..."
+ environments="$rvm_environments_path/$rvm_ruby_string $(ls -d "$rvm_environments_path"/* | awk '/'$rvm_ruby_string'@/')"
+ for environment in $environments ; do
+ rm -rf "$environment"
+ done ; unset environment environments
+}
+__rvm_remove_aliases() {
+ $rvm_scripts_path/log "info" "Removing $rvm_ruby_string aliases..."
+ aliases=$(awk '/'$rvm_ruby_string'/' $rvm_config_path/alias)
+ for alias_name in $aliases ; do
+ # Remove from alias key-value store
+ $rvm_scripts_path/db $rvm_config_path/alias $alias_name delete
+ # Remove the place holding symlink
+ rm -f $rvm_rubies_path/$alias_name
+ done ; unset alias_name aliases
+}
+
+__rvm_remove_archives() {
+ $rvm_scripts_path/log "info" "Removing $rvm_ruby_string archives..."
+ if [[ ! -z "$rvm_archive_flag" ]] ; then
+ rm -f $rvm_archives_path/${rvm_ruby_package_file}.${rvm_archive_extension}
+ fi
+}
+
__rvm_post_install() {
if [[ "$rvm_ruby_interpreter" != "jruby" ]] ; then
binaries="${binaries:-"gem irb erb ri rdoc testrb rake"}"
$rvm_scripts_path/log "info" "adjusting shebangs for $rvm_ruby_string ($binaries)."
for binary in $(echo $binaries) ; do
@@ -847,29 +899,30 @@
chmod +x "$rvm_ruby_home/bin/$binary"
fi
done ; unset binary binaries
fi
+ # Import the initial gemsets.
+ __rvm_run_with_env "gemsets.initial" "$rvm_ruby_string" 'rvm gemset initial' "Importing initial gems..."
+
__rvm_irbrc
__rvm_generate_default_docs
if [[ -n "$rvm_ruby_aliases" ]]; then
$rvm_scripts_path/log "info" "Setting up aliases for $rvm_ruby_string"
for ruby_alias in $rvm_ruby_aliases; do
- $rvm_scripts_path/log "info" "Aliasing $rvm_ruby_string to $ruby_alias"
+ $rvm_scripts_path/log info "Aliasing $rvm_ruby_string to $ruby_alias"
$rvm_scripts_path/alias delete "$ruby_alias" > /dev/null 2>&1
$rvm_scripts_path/alias create "$ruby_alias" "$rvm_ruby_string" > /dev/null 2>&1
done
unset rvm_ruby_aliases ruby_alias
fi
-
}
__rvm_generate_default_docs() {
if [[ "$rvm_docs_flag" = "1" && "$rvm_ruby_interpreter" != "macruby" ]]; then
- $rvm_scripts_path/log "info" "Attempting to generate ri docs..."
- (source $rvm_scripts_path/rvm; rvm use "$rvm_ruby_string"; rvm docs generate-ri) > ~/rvm-install-docs 2>&1
+ __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
@@ -904,10 +957,11 @@
# 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
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 "rubygems_version")
+ rvm_rubygems_version="$(__rvm_db "${rvm_ruby_interpreter}_rubygems_version")"
+ rvm_rubygems_version="${rvm_rubygems_version:-"$(__rvm_db "rubygems_version")"}"
rvm_rubygems_url=$(__rvm_db "rubygems_${rvm_rubygems_version}_url")
rvm_gem_package_name="rubygems-$rvm_rubygems_version"
rvm_gem_url="$rvm_rubygems_url/$rvm_gem_package_name.tgz"
# Sanity check... If setup.rb is missing from the rubygems source path,