scripts/utility in rvm-0.0.82 vs scripts/utility in rvm-0.0.83

- old
+ new

@@ -1,9 +1,10 @@ #!/usr/bin/env bash __rvm_info() { - full_version=$(ruby -v) + if [[ ! -z "$(which ruby 2>/dev/null)" ]] ; then full_version=$(ruby -v) ; fi + cat <<Info system: uname: "$(uname -a)" @@ -18,20 +19,21 @@ homes: gem: "${GEM_HOME:-'not set'}" ruby: "${MY_RUBY_HOME:-'not set'}" binaries: - ruby: "$(which ruby)" - irb: "$(which irb)" - gem: "$(which gem)" - rake: "$(which rake)" + ruby: "$(which ruby 2>/dev/null)" + irb: "$(which irb 2>/dev/null)" + gem: "$(which gem 2>/dev/null)" + rake: "$(which rake 2>/dev/null)" environment: GEM_HOME: "$GEM_HOME" MY_RUBY_HOME: "$MY_RUBY_HOME" IRBRC: "$IRBRC" Info + unset full_version } __rvm_debug() { $rvm_scripts_path/log "debug" "PATH:\n$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')" @@ -107,11 +109,11 @@ unset log_file command } __rvm_cleanup_variables() { __rvm_unset_ruby_variables - 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 + 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 } __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 rvm_ruby_mode } @@ -164,27 +166,29 @@ done fi rvm_system_ruby=$($rvm_scripts_path/db "$rvm_config_path/db" "system_ruby") if [[ ! -z "$rvm_system_ruby" ]] ; then - rvm_system_ruby=$(which ruby) + rvm_system_ruby=$(which ruby 2>/dev/null) if [[ $? -ne 0 ]] ; then - $rvm_scripts_path/log "info" "System ruby not found, no db will be stored." + $rvm_scripts_path/log "info" "System ruby not found, no system default will be stored." else $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_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_scripts_path/db "$rvm_config_path/db" "system_user_gem_path" "$rvm_system_user_gem_path" + if [[ ! -z "$(which gem 2>/dev/null)" ]] ; then + 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_scripts_path/db "$rvm_config_path/db" "system_user_gem_path" "$rvm_system_user_gem_path" + fi + 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_scripts_path/db "$rvm_config_path/db" "system_gem_path" "$rvm_system_gem_path" + fi fi - 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_scripts_path/db "$rvm_config_path/db" "system_gem_path" "$rvm_system_gem_path" - fi fi fi } __rvm_reset() { @@ -254,11 +258,15 @@ echo -e "mput(-head) # shyouhei head, the default mput" if [[ "Darwin" = "$(uname)" ]] ; then echo -e "macruby(-nightly) # the default macruby\nmacruby-head # Build from the macruby git repository" fi else - current_ruby="$(which ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null)" + ruby=$(which ruby 2>/dev/null) ; current_ruby="" + if [[ ! -z "$ruby" ]] && [[ ! -z "$(echo $ruby | awk '/rvm/')" ]] ; then + current_ruby="$(echo $ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null)" + fi + for version in $(\ls -l $rvm_path/ 2> /dev/null | awk '/ ruby-[1-2].*/ { print $NF }') ; do string=$($rvm_path/$version/bin/ruby -v) if [[ "$version" = "$current_ruby" ]] ; then echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" selected="1" @@ -334,17 +342,19 @@ echo -e " $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" fi fi ; unset version fi - system_version=$(rvm system ; ruby -v 2> /dev/null) + system_version=$(rvm system ; which ruby 2>/dev/null && ruby -v 2> /dev/null) if [[ ! -z "$system_version" ]] ; then if [[ "$($(which ruby) -v)" = "$system_version" ]] ; then echo -e "=> $(tput setaf 2)system$(tput sgr0) ( ruby -v # => $system_version )\n" else echo -e " $(tput setaf 2)system$(tput sgr0) ( ruby -v # => $system_version )\n" fi + else + $rvm_scripts_path/log "info" "No system ruby found." fi ; unset current_ruby version selected fi } __rvm_initialize() { @@ -411,12 +421,16 @@ __rvm_select __rvm_use binary="$(echo $rvm_action | sed 's#do$##')" if [[ -x "$rvm_ruby_home/bin/$binary" ]] ; then binary="$rvm_ruby_home/bin/$binary" + elif [[ -x "$rvm_ruby_gem_home/bin/$binary" ]] ; then + binary="$rvm_ruby_gem_home/bin/$binary" elif [[ "system" = "$rvm_ruby_string" ]] && [[ -x "$(which $binary)" ]] ; then - binary="$(which $binary)" + binary="$(which $binary 2>/dev/null)" + #elif [[ "spec" = "$binary" ]] ; then + #binary="$(which $binary 2>/dev/null)" else $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 @@ -440,19 +454,20 @@ rvm_command="$binary $rvm_ruby_mode $rvm_ruby_args --no-rdoc --no-ri" else rvm_command="$binary $rvm_ruby_mode $rvm_ruby_args" fi + mkdir -p ./log/$rvm_ruby_string/ 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 $rvm_ruby_mode | tr "\n" ' ')\033[0m\n" eval "$rvm_command" fi result=$? + if [[ $result -eq 0 ]]; then eval "successes=(${successes[*]} $rvm_ruby_string)" else eval "errors=(${errors[*]} $rvm_ruby_string)" fi @@ -581,14 +596,14 @@ fi } __rvm_state() { if [[ -z "$rvm_state" ]] ; then - if [[ -z "$(which ruby | awk /$(basename $rvm_path)/)" ]] ; then + if [[ -z "$(which ruby 2>/dev/null | awk /$(basename $rvm_path)/)" ]] ; then rvm_state=system else - rvm_state="$(dirname $(which ruby) | xargs dirname | xargs basename)" + rvm_state="$(dirname "$(which ruby 2>/dev/null)" | xargs dirname | xargs basename)" fi else rvm_ruby_string="$rvm_state" __rvm_select __rvm_use @@ -596,128 +611,21 @@ fi } __rvm_inspect() { for binary in $rvm_ruby_args ; do - actual_file=$(which $binary) + actual_file="$(which $binary 2>/dev/null)" $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 if [[ ! -z "$rvm_all_flag" ]] ; then cat $actual_file ; fi done } -# -# ruby supporting libraries: -# -__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_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" - 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 - __rvm_run "$package/configure" "./configure --prefix=$rvm_path/usr --disable-dependency-tracking --disable-static --enable-shared" "Configuring $package" - else - __rvm_run "$package/configure" "./configure --prefix=$rvm_path/usr --disable-dependency-tracking --disable-static --enable-shared" "Configuring $package" - fi - __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_iconv_install() { - __rvm_make_flags - __rvm_pushpop $rvm_src_path - package="libiconv" ; version=1.13.1 ; archive_format="tar.gz" - $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" - 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_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" - 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 $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_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" - 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_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" - 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_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" - 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 -} - __rvm_make_flags() { PATH=${rvm_path}/usr/bin:$PATH ; export PATH # This is only an issue with Darwin :/ if [[ "Darwin" = "$(uname)" ]] ; then # ls /usr/lib/gcc/i686-apple-darwin10 @@ -743,11 +651,11 @@ if [[ ! -z "$rvm_archflags" ]] ; then ARCHFLAGS="$rvm_archflags" ; export ARCHFLAGS # Use the latest sdk available. if [[ -z "$rvm_sdk" ]] ; then rvm_sdk="$(basename -a /Developer/SDKs/* | awk '/^M/' | sort | tail -n 1)" ; fi - CFLAGS="-isysroot /Developer/SDKs/$rvm_sdk $rvm_archflags" ; export CFLAGS - LDFLAGS="-Wl,-syslibroot /Developer/SDKs/$rvm_sdk $rvm_archflags" ; export LDFLAGS + CFLAGS="${CFLAGS:-"-isysroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}" ; export CFLAGS + LDFLAGS="${LDFLAGS:-"-Wl,-syslibroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}" ; export LDFLAGS # CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk " ; export CXXFLAGS fi fi }