scripts/utility in rvm-0.0.80 vs scripts/utility in rvm-0.0.81
- old
+ new
@@ -32,26 +32,26 @@
Info
unset full_version
}
__rvm_debug() {
- __rvm_log "debug" "PATH:\n$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')"
- __rvm_log "debug" "uname -a: $(uname -a)"
+ $rvm_scripts_path/log "debug" "PATH:\n$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')"
+ $rvm_scripts_path/log "debug" "uname -a: $(uname -a)"
if [[ "Darwin" = "$(uname)" ]] ; then
- __rvm_log "debug" "uname -r: $(uname -r)"
- __rvm_log "debug" "uname -m: $(uname -m)"
- __rvm_log "debug" "sw_vers: $(sw_vers | tr "\n" ',')"
- __rvm_log "debug" "ARCHFLAGS: $ARCHFLAGS"
- __rvm_log "debug" "LDFLAGS: $LDFLAGS"
- __rvm_log "debug" "CFLAGS: $CFLAGS"
- __rvm_log "debug" "/Developer/SDKs/*:$(basename -a /Developer/SDKs/* | tr "\n" ',')"
+ $rvm_scripts_path/log "debug" "uname -r: $(uname -r)"
+ $rvm_scripts_path/log "debug" "uname -m: $(uname -m)"
+ $rvm_scripts_path/log "debug" "sw_vers: $(sw_vers | tr "\n" ',')"
+ $rvm_scripts_path/log "debug" "ARCHFLAGS: $ARCHFLAGS"
+ $rvm_scripts_path/log "debug" "LDFLAGS: $LDFLAGS"
+ $rvm_scripts_path/log "debug" "CFLAGS: $CFLAGS"
+ $rvm_scripts_path/log "debug" "/Developer/SDKs/*:$(basename -a /Developer/SDKs/* | tr "\n" ',')"
fi
for file_name in $(echo $rc_files) ; do
if [[ -s "$file_name" ]] ; then
- __rvm_log "debug" "$file_name:\n$(grep 'rvm' $file_name)"
+ $rvm_scripts_path/log "debug" "$file_name:\n$(grep 'rvm' $file_name)"
fi
done
if [[ "root" = "$(whoami)" ]] ; then
debug_files="$rvm_path/default $rvm_path/system $rvm_path/config/db /etc/rvmrc /etc/gemrc"
@@ -59,38 +59,17 @@
debug_files="$rvm_path/default $rvm_path/system $rvm_path/config/db $HOME/.rvmrc $HOME/.gemrc"
fi
for file_name in $(echo $debug_files); do
if [[ -f "$file_name" ]] && [[ -s "$file_name" ]] ; then
- __rvm_log "debug" "$file_name (filtered):\n$(cat $file_name | awk '!/assword|_key/')\n"
+ $rvm_scripts_path/log "debug" "$file_name (filtered):\n$(cat $file_name | awk '!/assword|_key/')\n"
fi
done
- __rvm_log "debug" "gem sources:\n$(gem sources | awk '/gems/')"
-
- if [[ -f "$rvm_path/bin/rvm" ]] ; then
- __rvm_log "error" "rvm script in bin! \n$(\ls -laht $rvm_path/bin/rvm)"
- fi
+ $rvm_scripts_path/log "debug" "gem sources:\n$(gem sources | awk '/gems/')"
}
-# Logging functions based on level
-# TODO: Allow specification of a base file name to output to.
-__rvm_log() {
- if [[ ! -z "$2" ]] ; then level=$1 ; shift ; else level="info" ; fi
- message=$1
- case "$level" in
- debug) shift ;
- ((rvm_debug_flag)) && echo -e "$(tput setaf 5)<d>$(tput sgr0) $message $(tput setaf 5)</d> $(tput sgr0) "
- ;;
- info) shift ; echo -e "$(tput setaf 2)<i>$(tput sgr0) $message $(tput setaf 2)</i> $(tput sgr0) " ;;
- warn) shift ; echo -e "$(tput setaf 3)<w>$(tput sgr0) $message $(tput setaf 3)</w> $(tput sgr0) " ;;
- error) shift ; echo -e "$(tput setaf 1)<e>$(tput sgr0) $message $(tput setaf 1)</e> $(tput sgr0) " ;;
- fail) shift ; echo -e "$(tput setaf 1)<f>$(tput sgr0) $message $(tput setaf 1)</f> $(tput sgr0) " ; __rvm_pushpop ; return 1 ;;
- *) echo -e "$message"
- esac
-}
-
if [[ ! -z "$ZSH_VERSION" ]] ; then __shell_array_start=1 ; else __shell_array_start=0 ; fi
__rvm_push() {
array=$1 ; shift ; item=$2
# TODO: allow loop over more arguments.
eval "index=\$((\${#${array}[*]} + $__shell_array_start))"
@@ -113,30 +92,30 @@
__rvm_run() {
log_file_name="$1" ; command="$2" ; message="$3"
rvm_ruby_log_path="${rvm_ruby_log_path:-$rvm_path/log}"
mkdir -p $(dirname "$rvm_ruby_log_path/$log_file_name.log")
- if [[ ! -z "$message" ]] ; then __rvm_log "info" "$message" ; fi
- __rvm_log "debug" "Executing: $command"
+ if [[ ! -z "$message" ]] ; then $rvm_scripts_path/log "info" "$message" ; fi
+ (( $rvm_debug_flag )) && $rvm_scripts_path/log "debug" "Executing: $command"
touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :(
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | tee "$rvm_ruby_log_path/$log_file_name.log" > "$rvm_ruby_log_path/$log_file_name.error.log"
if [[ -z "$rvm_niceness" ]] || [[ "0" = "$rvm_niceness" ]] ; then
eval "$command" >> "$rvm_ruby_log_path/$log_file_name.log" 2>> "$rvm_ruby_log_path/$log_file_name.error.log"
else
eval "nice -n $rvm_niceness \$($command)" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log
fi
- if [[ $? -gt 0 ]] ; then __rvm_log "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name.error.log" ; __rvm_pushpop ; return 1 ; fi
+ if [[ $? -gt 0 ]] ; then $rvm_scripts_path/log "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name.error.log" ; __rvm_pushpop ; return 1 ; fi
unset log_file command
}
__rvm_cleanup_variables() {
__rvm_unset_ruby_variables
- unset rvm_ruby_selected_flag rvm_action rvm_irbrc_file rvm_src_path rvm_path rvm_prefix_path rvm_gem_path rvm_command rvm_error_message rvm_gem_set_name rvm_url rvm_config_path rvm_bin_path rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_load_flag rvm_dump_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_log_path rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_ruby_configure_flags CFLAGS LDFLAGS ARCHFLAGS
+ unset rvm_ruby_selected_flag rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_gem_set_name rvm_url rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_load_flag rvm_dump_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_ruby_configure_flags CFLAGS LDFLAGS ARCHFLAGS
}
__rvm_unset_ruby_variables() {
- unset rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_ruby_binary rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_string rvm_ruby_string rvm_ruby_src_path rvm_ruby_repo_url rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_head_flag rvm_ruby_configure
+ unset rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_ruby_binary rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_string rvm_ruby_string rvm_ruby_src_path rvm_ruby_repo_url rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_head_flag rvm_ruby_configure rvm_ruby_mode
}
__rvm_load_rvmrc() {
if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi
if [[ -f $HOME/.rvmrc ]] ; then source $HOME/.rvmrc ; fi
@@ -169,66 +148,10 @@
echo "$ruby_wrapper" > $rvm_path/bin/$rvm_ruby_package_name
unset ruby_wrapper
chmod +x $rvm_path/bin/$rvm_ruby_package_name
}
-__rvm_fetch() {
- __rvm_pushpop $rvm_archives_path
- if [[ -z "$1" ]] ; then log "fail" "BUG: __rvm_fetch called without an argument :/" ; return 1 ; fi
- archive=$(basename "$1") ; downlaod=1
- __rvm_log "debug" "Fetching $archive"
- # Check first if we have the correct archive
- if [[ -e "$archive" ]] && [[ -e "$archive.md5" ]] ; then
- __rvm_log "debug" "Found archive and its md5, testing correctness"
- if [[ $(md5sum --status -c "$archive.md5") -gt 0 ]] ; then
- __rvm_log "debug" "Archive is bad, downloading"
- download=1
- else
- __rvm_log "debug" "Archive is good, not downloading"
- download=0
- result=0
- fi
- else
- __rvm_log "debug" "No archive or no MD5, downloading"
- download=1
- fi
- if [[ $download -gt 0 ]] ; then
- eval $rvm_fetch "$1"
- result=$?
- if [[ $result -gt 0 ]] ; then
- retry=0
- if [[ $result -eq 78 ]] ; then
- __rvm_log "error" "The requested url does not exist: '$1'"
- elif [[ $result -eq 18 ]] ; then
- __rvm_log "error" "Partial file. Only a part of the file was transferred. Removing partial and re-trying."
- rm -f "$archive"
- retry=1
- elif [[ $result -eq 33 ]] ; then
- __rvm_log "debug" "Server does not support 'range' command, removing '$archive'"
- rm -f "$archive"
- retry=1
- else
- __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
- fi
-
- if [[ $retry -eq 1 ]] ; then
- eval $rvm_fetch "$1"
- result=$?
- if [[ $result -gt 0 ]] ; then
- __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
- fi
- fi
-
- fi
- __rvm_pushpop
- fi
-
- unset archive
- unset download
- return $result
-}
-
__rvm_load_defaults() {
if [[ ! -s "$rvm_path/system" ]] ; then
for variable in RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME ; do
eval value=\$${variable}
if [[ -z "$value" ]] ; then
@@ -239,28 +162,28 @@
echo "${variable}='$value' ; export ${variable}" >> $rvm_path/system
fi
done
fi
- rvm_system_ruby=$(__rvm_db "system_ruby")
+ rvm_system_ruby=$($rvm_scripts_path/db "$rvm_config_path/db" "system_ruby")
if [[ ! -z "$rvm_system_ruby" ]] ; then
rvm_system_ruby=$(which ruby)
if [[ $? -ne 0 ]] ; then
- __rvm_log "info" "System ruby not found, no db will be stored."
+ $rvm_scripts_path/log "info" "System ruby not found, no db will be stored."
else
- __rvm_db "system_ruby" "$rvm_system_ruby"
+ $rvm_scripts_path/db "$rvm_config_path/db" "system_ruby" "$rvm_system_ruby"
# Now store system system & user gem paths
- rvm_system_user_gem_path=$(__rvm_db "system_user_gem_path")
+ rvm_system_user_gem_path=$($rvm_scripts_path/db "$rvm_config_path/db" "system_user_gem_path")
if [[ -z "$rvm_system_user_gem_path" ]] ; then
rvm_system_user_gem_path=$( rvm system ; gem env gemdir user; )
- __rvm_db "system_user_gem_path" "$rvm_system_user_gem_path"
+ $rvm_scripts_path/db "$rvm_config_path/db" "system_user_gem_path" "$rvm_system_user_gem_path"
fi
- rvm_system_gem_path=$(__rvm_db "system_gem_path")
+ rvm_system_gem_path=$($rvm_scripts_path/db "$rvm_config_path/db" "system_gem_path")
if [[ -z "$rvm_system_gem_path" ]] ; then
rvm_system_gem_path=$( rvm system ; gem env gemdir; )
- __rvm_db "system_gem_path" "$rvm_system_gem_path"
+ $rvm_scripts_path/db "$rvm_config_path/db" "system_gem_path" "$rvm_system_gem_path"
fi
fi
fi
}
@@ -275,112 +198,49 @@
done
rvm_ruby_interpreter="system"
__rvm_select
for system_config in system_ruby system_gem_path system_user_gem_path ; do
- __rvm_db "$system_config" "delete"
+ $rvm_scripts_path/db "$rvm_config_path/db" "$system_config" "delete"
done ; unset system_config variable
rm -f $rvm_path/bin/ruby $rvm_path/bin/gem $rvm_path/bin/rake $rvm_path/bin/irb $rvm_path/bin/default*
}
__rvm_implode() {
while : ; do
- __rvm_log "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
+ $rvm_scripts_path/log "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
read response
if [[ "yes" = "$response" ]] ; then
if [[ "/" = "$rvm_path" ]] ; then
- __rvm_log "error" "remove '/' ?!... NO!"
+ $rvm_scripts_path/log "error" "remove '/' ?!... NO!"
else
if [[ -d "$rvm_path" ]] ; then
- __rvm_log "info" "Hai! Removing $rvm_path"
+ $rvm_scripts_path/log "info" "Hai! Removing $rvm_path"
rm -rf $rvm_path/
- __rvm_log "info" "$rvm_path has been removed."
+ $rvm_scripts_path/log "info" "$rvm_path has been removed."
else
- __rvm_log "info" "It appears that $rvm_path is already non existant."
+ $rvm_scripts_path/log "info" "It appears that $rvm_path is already non existant."
fi
fi
break
elif [[ "no" = "$response" ]] ; then
- __rvm_log "info" "Cancelling implosion, no harm done :)"
+ $rvm_scripts_path/log "info" "Cancelling implosion, no harm done :)"
break
fi
done
}
__rvm_source_dir() {
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
if [[ -z "$rvm_ruby_src_path" ]] ; then
- __rvm_log "fail" "No source directory exists for the default implementation."
+ $rvm_scripts_path/log "fail" "No source directory exists for the default implementation."
else
echo "$rvm_ruby_src_path"
fi
}
-# clones from source implementation/version to default
-# TODO: Merge this into 'rvm sync'
-__rvm_gemdup() {
- if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
- __rvm_log "debug" "$rvm_ruby_interpreter"
- if [[ "default" = "$rvm_ruby_interpreter" ]] ; then
- # TODO: $rvm_path/default first, then system user
- rvm_source_gem_path="$rvm_system_user_gem_path"
- elif [[ "user" = "$rvm_ruby_interpreter" ]] ; then
- rvm_source_gem_path="$rvm_system_user_gem_path"
- elif [[ "system" = "$rvm_ruby_interpreter" ]] ; then
- rvm_source_gem_path="$rvm_system_gem_path"
- else
- # TODO: use selector for this?
- rvm_source_gem_path=${rvm_ruby_gem_home/$rvm_ruby_interpreter/$rvm_ruby_version}
- fi
- __rvm_gem_sync
-}
-
-__rvm_gem_sync() {
- if [[ ! -z "$rvm_source_gem_path" ]] ; then
- for rvm_gem_name_version in $rvm_source_gem_path/gems/* ; do
- rvm_gem_name_version=$(basename $rvm_gem_name_version)
- rvm_gem_name="${rvm_gem_name_version%-*}"
- rvm_gem_version="${rvm_gem_name_version##*-}"
- if [[ -d $GEM_HOME/gems/$rvm_gem_name_version ]] ; then
- echo "$rvm_gem_name_version already installed."
- else
- __rvm_gi "$rvm_source_gem_path/cache/$rvm_gem_name-$rvm_gem_version.gem"
- fi
- done
- unset rvm_gem_name_version rvm_gem_name rvm_gem_version
- else
- __rvm_log "fail" "Unknown ruby selected :("
- result=1
- fi
-}
-
-__rvm_db() {
- rvm_hash_file="$rvm_config_path/db"
- touch $rvm_hash_file
- key="$1" ; shift
-
- if [[ -z "$key" ]] ; then
- __rvm_log "fail" "__rvm_db must be called with at least one argument: __rvm_db key [value]"
- else
- value="$*"
- if [[ "unset" = "$value" ]] || [[ "delete" = "$value" ]] ; then
- sed -i.tmp "s#^$key=.*\$##" $rvm_hash_file
- else
- if [[ -z "$value" ]] ; then # get
- awk -F= '/^'"$key"'=/{print $2}' $rvm_hash_file
- else # set
- if [[ -z "$(awk -F= "/^'"$key"'=/{print $2}" $rvm_hash_file)" ]] ; then # append
- echo "$key=$value" >> $rvm_hash_file
- else # overwrite
- sed -i.tmp "s#^$key=.*\$#$key=$value#" $rvm_hash_file
- fi
- fi
- fi
- fi
-}
-
__rvm_list() {
if [[ ! -z "$rvm_all_flag" ]] ; then
while read -r tag
do
prefix="$(echo ${tag/\//} | sed 's#^v1_##' | awk -F'_' '{print "(ruby-)1."$1"."$2}' | sed 's#p$##')"
@@ -486,54 +346,15 @@
fi ; unset current_ruby version selected
fi
}
__rvm_initialize() {
- # TODO: Sanitize user input, ensure that there is a / a the end...
- if [[ "root" = "$(whoami)" ]] ; then
- rvm_prefix_path="${rvm_prefix_path:-/usr/local/}"
- rc_files="/etc/profile /etc/zshenv"
- else
- if [[ -f "$HOME/.rvm/scripts/rvm" ]] ; then
- rvm_prefix_path="${rvm_prefix_path:-"$HOME/."}"
- else
- rvm_prefix_path="${rvm_prefix_path:-"/usr/local/"}"
- fi
- rc_files="$HOME/.bash_profile $HOME/.bashrc $HOME/.zshrc"
- fi
-
- if [[ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '.' ]] || [[ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '/' ]] ; then
- rvm_path="${rvm_prefix_path}rvm"
- else
- rvm_path="${rvm_prefix_path}/rvm"
- fi
-
- rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
- rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
- rvm_log_path="${rvm_log_path:-"$rvm_path/log"}"
- rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
- rvm_gem_path="${rvm_gem_path:-"$rvm_path/gems"}"
- rvm_config_path="${rvm_config_path:-"$rvm_path/config"}"
- rvm_temp_path="${rvm_temp_path:-"$rvm_path/tmp"}"
-
- rvm_ruby_repo_url="${rvm_ruby_repo_url:-"http://svn.ruby-lang.org/repos/ruby"}"
- # Rubinius sha1's will be available after RC1.
- rvm_rubinius_repo_url="${rvm_rubinius_repo_url:-"git://github.com/evanphx/rubinius.git"}"
- rvm_shyouhei_repo_url="${rvm_shyouhei_repo_url:-"git://github.com/shyouhei/ruby.git"}"
- rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
rvm_ruby_load_path="."
rvm_ruby_require=""
__rvm_clean_path
- rvm_fetch=$(which curl)
- if [[ $? -ne 0 ]] ; then
- __rvm_log "fail" "rvm requires curl, which does not seem to exist in your path :("
- else
- rvm_fetch="$rvm_fetch -O -L --create-dirs -C - " # -s for silent
- fi
-
rvm_result=$(echo $PATH | grep 'rvm\/bin:')
if [[ -z "$rvm_result" ]] ; then
PATH=$rvm_bin_path:$PATH ; export PATH
fi
@@ -552,38 +373,38 @@
__rvm_update_rvm() {
mkdir -p "$rvm_src_path"
__rvm_pushpop "$rvm_src_path"
if [[ "head" = "$rvm_ruby_revision" ]] ; then
if [[ -d "$rvm_src_path/rvm/.git" ]] ; then
- cd $rvm_src_path/rvm/ && git pull origin master && ./scripts/install
+ builtin cd $rvm_src_path/rvm/ && git pull origin master && ./scripts/install
else
- cd $rvm_src_path && git clone git://github.com/wayneeseguin/rvm.git && cd rvm/ && ./install
+ builtin cd $rvm_src_path && git clone git://github.com/wayneeseguin/rvm.git && builtin cd rvm/ && ./install
fi
else
# TODO: rvm_install_path:
gem install rvm --no-rdoc --no-ri -q rvm && $(gem env gemdir user)/bin/rvm-install && source $rvm_path/scripts/rvm
fi
__rvm_pushpop
}
__rvm_reboot() {
- __rvm_log "warn" "Do you wish to reset rvm? ('yes', or 'no')"
+ $rvm_scripts_path/log "warn" "Do you wish to reset rvm? ('yes', or 'no')"
read response
if [[ "yes" = "$response" ]] ; then
- cd $rvm_path
+ builtin cd $rvm_path
__rvm_reset
mv $rvm_path/archives ~/.archives
if [[ "/" = "$rvm_path" ]] ; then
- __rvm_log "error" "remove '/' ?!... NO!"
+ $rvm_scripts_path/log "error" "remove '/' ?!... NO!"
else
if [[ -d "$rvm_path" ]] ; then rm -rf "$rvm_path/" ; fi
fi
gem install rvm --no-rdoc --no-ri -q
__rvm_update_rvm
source $rvm_path/scripts/rvm
else
- __rvm_log "info" "Carry on then..."
+ $rvm_scripts_path/log "info" "Carry on then..."
fi ; unset response
}
__rvm_ruby_do() {
__rvm_select
@@ -592,37 +413,42 @@
if [[ -x "$rvm_ruby_home/bin/$binary" ]] ; then
binary="$rvm_ruby_home/bin/$binary"
elif [[ "system" = "$rvm_ruby_string" ]] && [[ -x "$(which $binary)" ]] ; then
binary="$(which $binary)"
else
- __rvm_log "warn" "'$binary not found for $rvm_ruby_string' either does not exist or is not executable? :("
+ $rvm_scripts_path/log "warn" "'$binary not found for $rvm_ruby_string' either does not exist or is not executable? :("
__rvm_unset_ruby_variables
return 1
fi
+ if [[ ! -z "$rvm_ruby_mode" ]] ; then
+ rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_mode"
+ rvm_ruby_mode="--$(echo $rvm_ruby_mode | sed 's/^m//')"
+ fi
+
load_path="$rvm_ruby_home/bin:$rvm_ruby_load_path"
# TODO: the else case below should be run if $rvm_ruby_args =~ /\.rb$/
if [[ "ruby" = "$binary" ]] && [[ "$rvm_benchmark_flag" -ne 1 ]] ; then
- if match "$rvm_ruby_args" "\.rb$" ; then
+ if $rvm_scripts_path/match "$rvm_ruby_args" "\.rb$" ; then
if [[ -z "$prefix" ]] ; then prefix="-S" ; fi
- if ! match "$rvm_ruby_args" "$prefix" ; then
+ if ! $rvm_scripts_path/match "$rvm_ruby_args" "$prefix" ; then
rvm_ruby_args="$prefix $rvm_ruby_args"
fi
fi
- rvm_command="$binary $rvm_ruby_require -I$load_path $rvm_ruby_args"
+ rvm_command="$binary $rvm_ruby_mode $rvm_ruby_require -I$load_path $rvm_ruby_args"
elif [[ "gem" = "$binary" ]] && match "$rvm_ruby_args" '^install' ; then
- rvm_command="$binary $rvm_ruby_args --no-rdoc --no-ri"
+ rvm_command="$binary $rvm_ruby_mode $rvm_ruby_args --no-rdoc --no-ri"
else
- rvm_command="$binary $rvm_ruby_args"
+ rvm_command="$binary $rvm_ruby_mode $rvm_ruby_args"
fi
if [[ ! -z "$rvm_json_flag" ]] || [[ ! -z "$rvm_yaml_flag" ]] || [[ ! -z "$rvm_summary_flag" ]] ; then
mkdir -p ./log/$rvm_ruby_string/
touch ./log/$rvm_ruby_string/$rvm_action.log ./log/$rvm_ruby_string/$rvm_action.error.log
eval "$rvm_command" >> ./log/$rvm_ruby_string/$rvm_action.log 2>> ./log/$rvm_ruby_string/$rvm_action.error.log
else
- echo -e "\n\n\033[0;32m$rvm_ruby_string: $($rvm_ruby_home/bin/ruby -v | tr "\n" ' ')\033[0m\n"
+ echo -e "\n\n\033[0;32m$rvm_ruby_string: $($rvm_ruby_home/bin/ruby -v $rvm_ruby_mode | tr "\n" ' ')\033[0m\n"
eval "$rvm_command"
fi
result=$?
if [[ $result -eq 0 ]]; then
eval "successes=(${successes[*]} $rvm_ruby_string)"
@@ -691,11 +517,11 @@
for var in ${errors[*]} ; do yaml="$yaml\n - $var" ; done
yaml="$yaml\nrubies:"
total=${#rubies[*]}
if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi
for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do
- __rvm_log "debug" "${rubies[$index]}: ${statuses[$index]}"
+ (( $rvm_debug_flag )) && $rvm_scripts_path/log "debug" "${rubies[$index]}: ${statuses[$index]}"
yaml="$yaml\n \"${rubies[$index]}\": ${statuses[$index]}"
done ; unset index array_start
mkdir -p log
echo -e "$yaml" | tee -a log/summary.yaml
@@ -710,11 +536,11 @@
json="$json\n \"rubies\": {"
total=${#rubies[*]}
if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi
for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do
- __rvm_log "debug" "${rubies[$index]}: ${statuses[$index]}"
+ (( $rvm_debug_flag )) && $rvm_scripts_path/log "debug" "${rubies[$index]}: ${statuses[$index]}"
json="$json\n {\"${rubies[$index]}\": ${statuses[$index]}}"
if (( $index + 1 < $total + $array_start )) ; then json="$json, " ; fi
done ; unset index array_start
json="$json\n }\n}"
@@ -768,11 +594,11 @@
}
__rvm_inspect() {
for binary in $rvm_ruby_args ; do
actual_file=$(which $binary)
- __rvm_log "info" "$actual_file:"
+ $rvm_scripts_path/log "info" "$actual_file:"
if [[ ! -z "$rvm_shebang_flag" ]] ; then cat $actual_file | head -n 1 ; fi
if [[ ! -z "$rvm_env_flag" ]] ; then cat $actual_file | awk '/ENV/' ; fi
if [[ ! -z "$rvm_path_flag" ]] ; then cat $actual_file | awk '/PATH/' ; fi
if [[ ! -z "$rvm_head_flag" ]] ; then cat $actual_file | head -n 5 ; fi
if [[ ! -z "$rvm_tail_flag" ]] ; then cat $actual_file | tail -n 5 ; fi
@@ -786,14 +612,15 @@
__rvm_readline_install() {
__rvm_make_flags
__rvm_pushpop $rvm_src_path
package="readline" ; version="5.2" ; archive_format="tar.gz"
# TODO: Figure out how to list, grab and apply the patches
- __rvm_log "info" "Retrieving $package-$version.$archive_format"
- __rvm_fetch "ftp://ftp.gnu.org/gnu/readline/$package-$version.$archive_format"
+ $rvm_scripts_path/log "info" "Retrieving $package-$version.$archive_format"
+ $rvm_scripts_path/fetch "ftp://ftp.gnu.org/gnu/readline/$package-$version.$archive_format"
+ result=$? ; if [[ "$result" -gt 0 ]] ; then return $result ; fi
__rvm_run "$package/extract" "tar zxf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path" "Extracting $package-$version.$archive_format"
- cd "$rvm_src_path/$package-$version"
+ builtin cd "$rvm_src_path/$package-$version"
if [[ "Darwin" = "$(uname)" ]] ; then
#sdk=$(\ls -t /Developer/SDKs/ | head -n 1)
#CFLAGS="-isysroot /Developer/SDKs/$sdk -arch i386 -arch x86_64"
#LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/$sdk -arch i386 -arch x86_64"
#export CFLAGS LDFLAGS
@@ -808,76 +635,80 @@
__rvm_iconv_install() {
__rvm_make_flags
__rvm_pushpop $rvm_src_path
package="libiconv" ; version=1.13.1 ; archive_format="tar.gz"
- __rvm_log "info" "Retrieving $package-$version.$archive_format"
- __rvm_fetch "http://ftp.gnu.org/pub/gnu/libiconv/$package-$version.$archive_format"
+ $rvm_scripts_path/log "info" "Retrieving $package-$version.$archive_format"
+ $rvm_scripts_path/fetch "http://ftp.gnu.org/pub/gnu/libiconv/$package-$version.$archive_format"
+ result=$? ; if [[ "$result" -gt 0 ]] ; then return $result ; fi
__rvm_run "$package/extract" "tar zxf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path" "Extracting $package-$version.$archive_format"
- cd "$rvm_src_path/$package-$version"
+ builtin cd "$rvm_src_path/$package-$version"
__rvm_run "$package/configure" "./configure --prefix=$rvm_path/usr" "Configuring $package."
__rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package"
__rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr"
__rvm_pushpop
}
__rvm_curl_install() {
__rvm_make_flags
__rvm_pushpop $rvm_src_path
package="curl" ; version=7.19.7 ; archive_format="tar.gz"
- __rvm_log "info" "Retrieving $package-$version.$archive_format"
- __rvm_fetch "http://curl.haxx.se/download/$package-$version.$archive_format"
+ $rvm_scripts_path/log "info" "Retrieving $package-$version.$archive_format"
+ $rvm_scripts_path/fetch "http://curl.haxx.se/download/$package-$version.$archive_format"
+ result=$? ; if [[ "$result" -gt 0 ]] ; then return $result ; fi
__rvm_run "$package/extract" "tar zxf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path" "Extracting $package-$version.$archive_format"
- cd "$rvm_src_path/$package-$version"
+ builtin cd "$rvm_src_path/$package-$version"
__rvm_run "$package/configure" "./configure --prefix=$rvm_path/usr" "Configuring $package."
__rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package"
__rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr"
__rvm_pushpop
}
-
__rvm_openssl_install() {
__rvm_make_flags
- if match "$rvm_archflags" "x86_64" ; then
+ if $rvm_scripts_path/match "$rvm_archflags" "x86_64" ; then
openssl_os="os/compiler darwin64-x86_64-cc"
else
openssl_os="os/compiler darwin-i386-cc"
fi
__rvm_pushpop $rvm_src_path
package="openssl" ; version="0.9.8k" ; archive_format="tar.gz"
- __rvm_log "info" "Retrieving $package-$version.$archive_format"
- __rvm_fetch "http://www.openssl.org/source/$package-$version.tar.gz"
+ $rvm_scripts_path/log "info" "Retrieving $package-$version.$archive_format"
+ $rvm_scripts_path/fetch "http://www.openssl.org/source/$package-$version.tar.gz"
+ result=$? ; if [[ "$result" -gt 0 ]] ; then return $result ; fi
__rvm_run "$package/extract" "tar zxf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path" "Extracting $package-$version.$archive_format"
- cd "$rvm_src_path/$package-$version"
+ builtin cd "$rvm_src_path/$package-$version"
__rvm_run "$package/config" "./config --prefix=$rvm_path/usr zlib no-asm no-krb5 shared" "Configuring $package."
__rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package"
__rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr"
__rvm_pushpop
}
__rvm_zlib_install() {
__rvm_make_flags
__rvm_pushpop $rvm_src_path
package="zlib" ; version="1.2.3" ; archive_format="tar.gz"
- __rvm_log "info" "Retrieving $package-$version.$archive_format"
- __rvm_fetch "http://www.zlib.net/$package-$version.tar.gz"
+ $rvm_scripts_path/log "info" "Retrieving $package-$version.$archive_format"
+ $rvm_scripts_path/fetch "http://www.zlib.net/$package-$version.tar.gz"
+ result=$? ; if [[ "$result" -gt 0 ]] ; then return $result ; fi
__rvm_run "$package/extract" "tar zxf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path" "Extracting $package-$version.$archive_format"
- cd "$rvm_src_path/$package-$version"
+ builtin cd "$rvm_src_path/$package-$version"
__rvm_run "$package/configure" "./configure --prefix=$rvm_path/usr" "Configuring $package."
__rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package"
__rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr"
__rvm_pushpop
}
__rvm_ncurses_install() {
__rvm_make_flags
__rvm_pushpop $rvm_src_path
package="ncurses" ; version="5.7" ; archive_format="tar.gz"
- __rvm_log "info" "Retrieving $package"
- __rvm_fetch "ftp://invisible-island.net/ncurses/ncurses.tar.gz"
+ $rvm_scripts_path/log "info" "Retrieving $package"
+ $rvm_scripts_path/fetch "ftp://invisible-island.net/ncurses/ncurses.tar.gz"
+ result=$? ; if [[ "$result" -gt 0 ]] ; then return $result ; fi
__rvm_run "$package/extract" "tar zxf $rvm_archives_path/$package.$archive_format -C $rvm_src_path" "Extracting $package.$archive_format"
- cd "$rvm_src_path/$package-$version"
+ builtin cd "$rvm_src_path/$package-$version"
__rvm_run "$package/configure" "./configure --prefix=$rvm_path/usr --with-shared --disable-rpath --without-debug --without-ada --enable-safe-sprintf --enable-sigwinch --without-progs" "Configuring $package."
__rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package"
__rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr"
__rvm_pushpop
}
@@ -978,20 +809,5 @@
array=$1 ; shift ; item=$2
# TODO: allow loop over more arguments.
eval "index=\$((\${#${array}[*]} + $__array_start))"
eval "${array}[${index}]=${item}"
}
-
-match() {
- #if [[ ! -z "$BASH_VERSION" ]] && [[ ${BASH_VERSION:0:1} -gt 2 ]] && [[ ${BASH_VERSION:2:1} -ge 1 ]] ; then
- #[[ "$1" =~ $2 ]] ; return $?
- # elif [[ ! -z "$ZSH_VERSION"]] && [[ ${ZSH_VERSION:0:1} -gt 3 ]] && [[ ${ZSH_VERSION:2:1} -ge 2 ]] && [[ ${ZSH_VERSION:4:1} -ge 4 ]] ; then
- # return [[ "$1" =~ "$2" ]]
- #else
- if [ ! -z "$(echo "$1" | awk "/${2}/")" ] ; then
- return 0
- else
- return 1
- fi
- #fi
-}
-