scripts/manage in rvm-1.0.11 vs scripts/manage in rvm-1.0.13

- old
+ new

@@ -4,19 +4,21 @@ original_ruby_string=${rvm_ruby_string:-""} source "$rvm_path/scripts/base" source "$rvm_path/scripts/patches" -__rvm_check_for_clang() { +__rvm_check_for_clang() +{ if [[ -n "${rvm_clang_flag:-""}" ]] && ! command -v clang >/dev/null ; then "$rvm_path/scripts/log" "fail" "\nYou passed the --clang option and clang is not in your path. \nPlease try again or do not use --clang.\n" return 1 fi } # Checks for bison, returns zero iff it is found -__rvm_check_for_bison() { +__rvm_check_for_bison() +{ if [[ ${rvm_head_flag:-0} -gt 0 ]]; then command -v bison > /dev/null result=$? if [[ $? -gt 0 ]] ; then "$rvm_path/scripts/log" "fail" \ @@ -27,11 +29,12 @@ return ${result:-0} } # Emits a number of patches to STDOUT, each on a new name # Expands patchsets etc. -__rvm_current_patch_names() { +__rvm_current_patch_names() +{ # TODO: Lookup default patches on rvm_ruby_string heirarchy. local separator patches level name separator="%" patches="${rvm_patch_names:-""} default" @@ -53,12 +56,12 @@ done return 0 } -__rvm_apply_patches() { - +__rvm_apply_patches() +{ local patches patch_name patch_level_separator patch_fuzziness patch_level source_directory full_patch_path result=0 patch_level_separator="%" patch_fuzziness="25" @@ -90,11 +93,13 @@ # Expand paths, and for those we found we then apply the patches. if [[ -n "${full_patch_path:-""}" ]]; then if [[ -f "$full_patch_path" ]] ; then - __rvm_run "patch.apply.${patch_name/*\/}" "patch -F$patch_fuzziness -p$patch_level -f <\"$full_patch_path\"" "Applying patch '$patch_name' (located at $full_patch_path)" + __rvm_run "patch.apply.${patch_name/*\/}" \ + "patch -F$patch_fuzziness -p$patch_level -f <\"$full_patch_path\"" \ + "Applying patch '$patch_name' (located at $full_patch_path)" [[ $? -gt 0 ]] && result=1 # Detect failed patches fi else @@ -106,18 +111,18 @@ ) return ${result:-0} } -__rvm_install_source() { - +__rvm_install_source() +{ local directory configure_parameters db_configure_flags [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] && __rvm_select case ${rvm_ruby_string:-""} in - *-head) __rvm_ensure_has_18_compat_ruby || return 1 ;; + ruby-head|1.9.*-head) __rvm_ensure_has_18_compat_ruby || return 1 ;; esac "$rvm_path/scripts/log" "info" \ "Installing Ruby from source to: $rvm_ruby_home, this may take a while depending on your cpu(s)...\n" @@ -166,11 +171,12 @@ "$rvm_path/scripts/log" "fail" \ "There has been an error applying the specified patches. Halting the installation." return $result fi - if [[ -z "${rvm_ruby_configure:-""}" && ! -s "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/configure" ]] ; then + if [[ -z "${rvm_ruby_configure:-""}" \ + && ! -s "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/configure" ]] ; then if command -v autoconf > /dev/null ; then __rvm_run "autoconf" "autoconf" "Running autoconf" @@ -270,15 +276,16 @@ "Install of $rvm_ruby_string - #complete " return ${result:-0} } -__rvm_install_ruby() { - +__rvm_install_ruby() +{ if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi if [[ -n "${RUBYOPT:-""}" ]] ; then ruby_options="$RUBYOPT" ; fi + unset RUBYOPT # Check for clang if the flag is set __rvm_check_for_clang result="$?" @@ -308,11 +315,12 @@ __rvm_install_source $* result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to install from source. Halting the installation." + "There has been an error while trying to install from source. \ + \nHalting the installation." return $result fi elif [[ "nightly" = "$rvm_ruby_version" ]] ; then macruby_path="/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/bin" @@ -323,17 +331,20 @@ "$rvm_path/scripts/fetch" "$rvm_ruby_url" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to fetch the source. Halting the installation." + "There has been an error while trying to fetch the source. \ + \nHalting the installation." return $result fi - mv "${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly-latest.pkg" "$rvm_archives_path/macruby_nightly.pkg" + mv "${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly-latest.pkg" \ + "$rvm_archives_path/macruby_nightly.pkg" - __rvm_run "macruby/extract" "sudo /usr/sbin/installer -pkg '${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly.pkg' -target '/'" + __rvm_run "macruby/extract" \ + "sudo /usr/sbin/installer -pkg '${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly.pkg' -target '/'" mkdir -p "$rvm_ruby_home/bin" else macruby_path="/Library/Frameworks/MacRuby.framework/Versions/${rvm_ruby_version}/usr/bin" @@ -355,11 +366,12 @@ unzip -o -j "${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file" "MacRuby ${rvm_ruby_version}/MacRuby ${rvm_ruby_version}.pkg" -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" mv "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/MacRuby ${rvm_ruby_version}.pkg" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/$rvm_ruby_string.pkg" - __rvm_run "macruby/extract" "sudo /usr/sbin/installer -pkg '${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/$rvm_ruby_string.pkg' -target '/'" + __rvm_run "macruby/extract" \ + "sudo /usr/sbin/installer -pkg '${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/$rvm_ruby_string.pkg' -target '/'" mkdir -p "$rvm_ruby_home/bin" fi binaries=(erb gem irb rake rdoc ri ruby testrb) @@ -388,11 +400,12 @@ if [[ -f "$file_name" ]] ; then chmod +x $file_name fi if [[ "$binary_name" = "ruby" ]] ; then - echo "$ruby_wrapper" > "${rvm_bin_path:-"$rvm_bin_path/bin"}/$rvm_ruby_string" + echo "$ruby_wrapper" \ + > "${rvm_bin_path:-"$rvm_bin_path/bin"}/$rvm_ruby_string" fi done ; unset binaries __rvm_irbrc @@ -401,19 +414,23 @@ "MacRuby can only be installed on a Darwin OS." fi ;; ree) - if [[ -n "$(echo "$rvm_ruby_version" | awk '/^1\.8/')" ]] && [[ $rvm_head_flag -eq 0 ]] ; then + if [[ -n "$(echo "$rvm_ruby_version" | awk '/^1\.8/')" \ + && $rvm_head_flag -eq 0 ]] ; then rvm_ruby_url="$(__rvm_db "ree_${rvm_ruby_version}_url")/$rvm_ruby_package_file.tar.gz" - "$rvm_path/scripts/log" "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home" + "$rvm_path/scripts/log" "info" \ + "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home" builtin cd "${rvm_src_path:-"$rvm_path/src"}" - if [[ ${rvm_force_flag:-0} -eq 0 && -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" && ! -x "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/installer" ]] ; then + if [[ ${rvm_force_flag:-0} -eq 0 \ + && -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \ + && ! -x "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/installer" ]] ; then "$rvm_path/scripts/log" \ "It appears that the archive has already been extracted. Skipping extract (use --force to force re-download and extract)." else @@ -424,26 +441,30 @@ "$rvm_ruby_url" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to fetch the source. Halting the installation." + "There has been an error while trying to fetch the source. \ + \nHalting the installation." return $result fi rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" - __rvm_run "extract" "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" + __rvm_run "extract" \ + "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \ + "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ "There has been an error while trying to extract the source. Halting the installation." return $result fi - mv "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_package_file" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" + mv "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_package_file" \ + "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" fi builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" # wait, what? v v v TODO: Investigate line smell. @@ -451,26 +472,30 @@ if [[ -n "$rvm_configure_flags" ]] ; then rvm_configure_flags="${rvm_configure_flags//--/-c --}" fi - if [[ "Darwin" = "$(uname)" && "1.8.6" = "$rvm_ruby_version" && -z "$rvm_ree_options" ]] ; then + if [[ "Darwin" = "$(uname)" && "1.8.6" = "$rvm_ruby_version" \ + && -z "$rvm_ree_options" ]] ; then rvm_ree_options="${rvm_ree_options} --no-tcmalloc" fi __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags" __rvm_apply_patches "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/source" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to apply patches to ree. Halting the installation." + "There has been an error while trying to apply patches to ree. \ + \nHalting the installation." return $result fi - __rvm_run "install" "./installer -a $rvm_path/rubies/$rvm_ruby_string $rvm_ree_options $db_configure_flags $rvm_configure_flags" "$rvm_ruby_string - #installing " + __rvm_run "install" \ + "./installer -a $rvm_path/rubies/$rvm_ruby_string $rvm_ree_options $db_configure_flags $rvm_configure_flags" "$rvm_ruby_string - #installing " + result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ "There has been an error while trying to run the ree installer. Halting the installation." @@ -486,11 +511,12 @@ else __rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_repo_url" "rvm_ruby_url" if [[ -z "$rvm_ruby_url" ]] ; then - "$rvm_path/scripts/log" "fail" "rvm does not know the rvm repo url for '${rvm_ruby_interpreter}_${rvm_ruby_version}'" + "$rvm_path/scripts/log" "fail" \ + "rvm does not know the rvm repo url for '${rvm_ruby_interpreter}_${rvm_ruby_version}'" result=1 else rvm_ruby_repo_url="$rvm_ruby_url" if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi @@ -515,45 +541,51 @@ __rvm_conditionally_add_bin_path ; export PATH builtin hash -r - if [[ -n "$(echo $rvm_ruby_version | awk '/^1\.0/')" ]] && [[ $rvm_head_flag -eq 0 ]] ; then + if [[ -n "$(printf $rvm_ruby_version | awk '/^1\./')" \ + && ${rvm_head_flag:-0} -eq 0 ]] ; then - "$rvm_path/scripts/log" "info" "$rvm_ruby_string #downloading ($rvm_ruby_package_file), this may take a while depending on your connection..." + "$rvm_path/scripts/log" "info" \ + "$rvm_ruby_string #downloading ($rvm_ruby_package_file), this may take a while depending on your connection..." "$rvm_path/scripts/fetch" "$rvm_ruby_url" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ "There has been an error while trying to fetch the source. Halting the installation." return $result fi __rvm_run "extract" \ - "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$(basename $rvm_ruby_package_file)\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" "Extracting $rvm_ruby_package_file ..." + "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$(basename $rvm_ruby_package_file)\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \ + "$rvm_ruby_string - #extracting" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to extract the source. Halting the installation." + "There has been an error while trying to extract the source. \ + \nHalting the installation." return $result fi # Remove the left over folder first. rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" - mv "${rvm_src_path:-"$rvm_path/src"}/rubinius-${rvm_ruby_version}" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" + mv "${rvm_src_path:-"$rvm_path/src"}/rubinius-${rvm_ruby_version}" \ + "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" else __rvm_db "rubinius_repo_url" "rvm_ruby_repo_url" #rvm_ruby_home="$rvm_path/rubies/$rvm_ruby_interpreter-$rvm_ruby_version" __rvm_fetch_from_github "rbx" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while fetching the rbx git repo. Halting the installation." + "There has been an error while fetching the rbx git repo. \ + \nHalting the installation." return $result fi fi builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" @@ -563,21 +595,23 @@ __rvm_apply_patches result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to apply patches to rubinius. Halting the installation." + "There has been an error while trying to apply patches to rubinius. \ + \nHalting the installation." return $result fi __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags" export ruby="$(__rvm_18_compat_ruby)" rvm_configure_flags="${rvm_configure_flags:-"--skip-system"}" - rvm_ruby_configure="$rvm_path/wrappers/$ruby/ruby ./configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_configure_flags" ; message="Configuring rbx" + rvm_ruby_configure="$rvm_path/wrappers/$ruby/ruby ./configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_configure_flags" + message="$rvm_ruby_string - #configuring" if [[ "$rvm_llvm_flag" = "0" ]] ; then rvm_ruby_configure="$rvm_ruby_configure --disable-llvm" else @@ -589,26 +623,30 @@ __rvm_run "configure" "$rvm_ruby_configure" "$message" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while running '$rvm_ruby_configure'. Halting the installation." + "There has been an error while running '$rvm_ruby_configure'. \ + \nHalting the installation." return $result fi if [[ "$rvm_trace_flag" -eq 1 ]] ; then - rvm_ruby_make="$rvm_path/wrappers/$ruby/rake install --trace" ; message="Compiling rbx (with --trace)" + rvm_ruby_make="$rvm_path/wrappers/$ruby/rake install --trace" + message="$rvm_ruby_string - #compiling (with --trace)" else - rvm_ruby_make="$rvm_path/wrappers/$ruby/rake install" ; message="Compiling rbx" + rvm_ruby_make="$rvm_path/wrappers/$ruby/rake install" + message="$rvm_ruby_string - #compiling" fi __rvm_run "rake" "$rvm_ruby_make" "$message" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while running '$rvm_ruby_configure'. Halting the installation." + "There has been an error while running '$rvm_ruby_configure'. \ + \nHalting the installation." return $result fi ; unset ruby # Symlink rubinius wrappers ln -fs "$rvm_ruby_home/bin/rbx" "$rvm_ruby_home/bin/ruby" @@ -647,21 +685,23 @@ ;; jruby) if ! command -v java > /dev/null; then - printf "java must be installed and in your path in order to install JRuby." ; return 1 + printf "java must be installed and in PATH in order to install JRuby." + return 1 fi builtin cd "${rvm_src_path:-"$rvm_path/src"}" __rvm_fetch_ruby result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to fetch the source. Halting the installation." + "There has been an error while trying to fetch the source. \ + \nHalting the installation." return $result fi builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" @@ -676,25 +716,28 @@ mkdir -p "$rvm_ruby_home/bin/" case "$rvm_ruby_version" in 1.3|1.2) __rvm_run "nailgun" \ - "builtin cd \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/tool/nailgun\" && make $rvm_make_flags" "Building Nailgun" + "builtin cd \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/tool/nailgun\" && make $rvm_make_flags" \ + "Building Nailgun" ;; *) __rvm_run "nailgun" \ - "builtin cd \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/tool/nailgun\" && ./configure --prefix=$rvm_ruby_home && make $rvm_make_flags" "Building Nailgun" + "builtin cd \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/tool/nailgun\" && ./configure --prefix=$rvm_ruby_home && make $rvm_make_flags" \ + "Building Nailgun" ;; esac if [[ -z "${rvm_ruby_home:-""}" || "$rvm_ruby_home" = "/" ]] ; then echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000 fi rm -rf "$rvm_ruby_home" - __rvm_run "install" "/bin/cp -Rf ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string $rvm_ruby_home" "$rvm_ruby_string - #installing to $rvm_ruby_home" + __rvm_run "install" \ + "/bin/cp -Rf ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string $rvm_ruby_home" "$rvm_ruby_string - #installing to $rvm_ruby_home" ( builtin cd "$rvm_ruby_home/bin/" for binary in jirb jruby jgem ; do ln -nfs "$binary" "${binary#j}" @@ -705,10 +748,11 @@ #sed -e 's#^JAVA_VM=-client#JAVA_VM=-server#' $rvm_ruby_home/bin/jruby > $rvm_ruby_home/bin/jruby.new && # mv $rvm_ruby_home/bin/jruby.new $rvm_ruby_home/bin/jruby chmod +x "$rvm_ruby_home/bin/jruby" binaries=(jrubyc jirb_swing jirb jgem rdoc ri spec autospec testrb ast generate_yaml_index.rb) + for binary in "${binaries[@]}" ; do __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary" done __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/rake" @@ -747,20 +791,23 @@ return $result fi builtin cd "${rvm_src_path:-"$rvm_path/src"}" - if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" || ${rvm_force_flag:-0} -eq 1 ]] ; then + if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \ + || ${rvm_force_flag:-0} -eq 1 ]] ; then - rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/" + rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/" \ + "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/" __rvm_fetch_ruby result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to fetch the source. Halting the installation." + "There has been an error while trying to fetch the source. \ + \nHalting the installation." return $result fi fi if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then @@ -770,18 +817,20 @@ 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 - "$rvm_path/scripts/log" "info" "Downloading the GemStone package, this may take a while depending on your connection..." + "$rvm_path/scripts/log" "info" \ + "Downloading the GemStone package, this may take a while depending on your connection..." "$rvm_path/scripts/fetch" "$rvm_gemstone_url" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to fetch the GemStone package. Halting the installation." + "There has been an error while trying to fetch the GemStone package. \ + \nHalting the installation." return $result fi builtin cd "${rvm_src_path:-"$rvm_path/src"}" @@ -789,16 +838,18 @@ mv "$rvm_ruby_package_file" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" fi builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" - __rvm_run "gemstone.extract" "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/${rvm_gemstone_package_file}.${rvm_archive_extension}\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" + __rvm_run "gemstone.extract" \ + "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/${rvm_gemstone_package_file}.${rvm_archive_extension}\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to extract the GemStone package. Halting the installation." + "There has been an error while trying to extract the GemStone package. \ + \nHalting the installation." return $result fi chmod -R 777 "$rvm_gemstone_package_file" # for now. # WTF?! Crack.smoke!(:huff) @@ -808,11 +859,13 @@ echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000 else rm -rf $rvm_ruby_home fi - __rvm_run "install" "/bin/cp -Rf ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string $rvm_ruby_home" "Installing maglev to $rvm_ruby_home" + __rvm_run "install" \ + "/bin/cp -Rf ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string $rvm_ruby_home" \ + "Installing maglev to $rvm_ruby_home" ( builtin cd "$rvm_ruby_home/bin/" for binary in maglev-irb maglev-ruby maglev-gem ; do @@ -880,11 +933,12 @@ mono_major_ver="$(echo "$mono_version" | cut -d '.' -f1)" mono_minor_ver="$(echo "$mono_version" | cut -d '.' -f2)" - if [[ $mono_major_ver -lt 2 ]] || ( [[ $mono_major_ver -eq 2 && $mono_minor_ver -lt 6 ]] ) ; then + if [[ $mono_major_ver -lt 2 ]] \ + || ( [[ $mono_major_ver -eq 2 && $mono_minor_ver -lt 6 ]] ) ; then printf "Mono 2.6 (or greater) must be installed and in your path in order to build IronRuby from the repository." printf "Version detected: ${mono_version}" return 1 fi else @@ -909,11 +963,12 @@ __rvm_run "rake" "$rvm_ruby_make" "Building IronRuby..." unset compatible_ruby if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi rm -rf "$rvm_ruby_home"/* - mkdir -p "$rvm_ruby_home/bin" "$rvm_ruby_home/lib" "$rvm_ruby_home/lib/ruby" "$rvm_ruby_home/lib/IronRuby" + mkdir -p "$rvm_ruby_home/bin" "$rvm_ruby_home/lib" \ + "$rvm_ruby_home/lib/ruby" "$rvm_ruby_home/lib/IronRuby" cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Bin/mono_release"/* "$rvm_ruby_home/bin/" cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Languages/Ruby/Scripts/bin"/* "$rvm_ruby_home/bin/" cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby"/* "$rvm_ruby_home/lib/ruby" cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Languages/Ruby/Libs"/* "$rvm_ruby_home/lib/IronRuby" @@ -940,11 +995,12 @@ result=$? if [[ "$result" -gt 1 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to extract $rvm_ruby_package_file. Halting the installation." + "There has been an error while trying to extract $rvm_ruby_package_file. \ + \nHalting the installation." return $result fi for dir in bin lib silverlight ; do @@ -966,11 +1022,12 @@ chmod +x "$rvm_ruby_home/bin/$binary_name" fi done ; unset binaries - sed -e '1,1s=.*=#!'"/usr/bin/env bash=" "$rvm_ruby_home/bin/ir" | \tr -d '\r' > "$rvm_ruby_home/bin/ir.new" + sed -e '1,1s=.*=#!'"/usr/bin/env bash=" "$rvm_ruby_home/bin/ir" \ + | \tr -d '\r' > "$rvm_ruby_home/bin/ir.new" mv -f "$rvm_ruby_home/bin/ir.new" "$rvm_ruby_home/bin/ir" chmod +x "$rvm_ruby_home/bin/ir" @@ -1001,11 +1058,12 @@ __rvm_apply_patches ; result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to apply patches to mput. Halting the installation." + "There has been an error while trying to apply patches to mput. \ + \nHalting the installation." return $result fi if [[ ! -s "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/configure" ]] ; then @@ -1013,11 +1071,12 @@ __rvm_run "autoconf" "autoconf" "Running autoconf" else "$rvm_path/scripts/log" "fail" \ - "rvm expects autoconf to install this ruby interpreter, autoconf was not found in PATH. Halting installation." + "rvm expects autoconf to install this ruby interpreter, autoconf was not found in PATH. \ + \nHalting installation." return $result fi fi if [[ -s ./Makefile ]] && [[ -z "$rvm_reconfigure_flag" ]] ; then @@ -1032,11 +1091,12 @@ __rvm_run "configure" "$rvm_ruby_configure" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to configure the source. Halting the installation." + "There has been an error while trying to configure the source. \ + \nHalting the installation." return $result fi elif [[ -s ./configure ]] ; then local configure_command="./configure --prefix=$rvm_ruby_home $rvm_configure_flags" @@ -1045,11 +1105,12 @@ "Configuring $rvm_ruby_string using $rvm_configure_flags, this may take a while depending on your cpu(s)..." result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to configure the source. Halting the installation." + "There has been an error while trying to configure the source.\ + \nHalting the installation." return $result fi else "$rvm_path/scripts/log" "error" \ @@ -1062,22 +1123,24 @@ "Compiling $rvm_ruby_string, this may take a while depending on your cpu(s)..." result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to run make. Halting the installation." + "There has been an error while trying to run make.\ + \nHalting the installation." return $result fi rvm_ruby_make_install=${rvm_ruby_make_install:-"make install"} __rvm_run "install" "$rvm_ruby_make_install" "Installing $rvm_ruby_string" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to run make install. Halting the installation." + "There has been an error while trying to run make install. \ + \nHalting the installation." return $result fi "$rvm_path/scripts/log" "info" \ "Installation of $rvm_ruby_string is complete." @@ -1124,20 +1187,23 @@ fi return ${result:-0} } -__rvm_fetch_from_github() { +__rvm_fetch_from_github() +{ rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" if [[ ! -d "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string/.git" ]] ; then rm -rf "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" builtin cd "$rvm_home" - __rvm_run "$1.repo" "git clone --depth 1 $rvm_ruby_repo_url ${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" "Cloning $rvm_ruby_repo_url" + __rvm_run "$1.repo" \ + "git clone --depth 1 $rvm_ruby_repo_url ${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" \ + "Cloning $rvm_ruby_repo_url" result=$? if [[ "$result" -gt 0 ]] ; then rvm_ruby_repo_http_url="${rvm_ruby_repo_url//git:/http:}" @@ -1158,12 +1224,12 @@ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" return ${result:-0} } -__rvm_fetch_ruby() { - +__rvm_fetch_ruby() +{ [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] && __rvm_select "$rvm_path/scripts/log" "info" "$rvm_ruby_string - #fetching " if [[ ${rvm_head_flag:-0} -eq 0 && -z "${rvm_ruby_tag:-""}" && -z "${rvm_ruby_revision:-""}" ]] ; then @@ -1204,19 +1270,22 @@ "$rvm_path/scripts/fetch" "${rvm_ruby_url}" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to fetch the source. Halting the installation." + "There has been an error while trying to fetch the source. \ + \nHalting the installation." return $result fi fi - if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" || ${rvm_force_flag:-0} -eq 1 ]] ; then + if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \ + || ${rvm_force_flag:-0} -eq 1 ]] ; then if [[ -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" ]] ; then - rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" # Especially when forced, we want to ensure the destination is missing. + # Especially when forced, we want to ensure the destination is missing. + rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" fi mkdir -p "/tmp/rvm_src_$$" case "$rvm_archive_extension" in @@ -1224,37 +1293,41 @@ __rvm_run "extract" "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C /tmp/rvm_src_$$" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to extract the source. Halting the installation." + "There has been an error while trying to extract the source. \ + \nHalting the installation." return $result fi ;; zip) __rvm_run "extract" "unzip -q -o ${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file -d /tmp/rvm_src_$$" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to extract $rvm_ruby_package_file. Halting the installation." + "There has been an error while trying to extract $rvm_ruby_package_file. \ + \nHalting the installation." return $result fi ;; tar.bz2) __rvm_run "extract" "bunzip2 < '${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension' | tar xf - -C /tmp/rvm_src_$$" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to extract the source. Halting the installation." + "There has been an error while trying to extract the source. \ + \nHalting the installation." return $result fi ;; *) "$rvm_path/scripts/log" "error" \ - "Unknown archive format extension '$rvm_archive_extension'. Halting the installation." + "Unknown archive format extension '$rvm_archive_extension'. \ + \nHalting the installation." return 1 ;; esac mv "/tmp/rvm_src_$$/$(builtin cd /tmp/rvm_src_$$ ; ls)" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" ; rm -rf "/tmp/rvm_src_$$" @@ -1291,11 +1364,12 @@ result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to update the source from the remote repository. Halting the installation." + "There has been an error while trying to update the source from the remote repository. \ + \nHalting the installation." return $result fi else if [[ -z "${rvm_ruby_sha:-""}" ]] ; then @@ -1305,11 +1379,12 @@ fi result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to checkout the source branch. Halting the installation." + "There has been an error while trying to checkout the source branch. \ + \nHalting the installation." return $result fi fi else @@ -1318,23 +1393,26 @@ rvm_ruby_repo_http_url="${rvm_ruby_repo_url//git:/http:/}" "$rvm_path/scripts/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_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" + git clone --depth 1 "$rvm_ruby_repo_url" \ + "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "info" \ "cloning from $rvm_ruby_repo_url failed, now attempting to clone from $rvm_ruby_repo_http_url, this may take a while depending on your connection..." - git clone "$rvm_ruby_repo_http_url" "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" + git clone "$rvm_ruby_repo_http_url" \ + "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to fetch the repository. Halting the installation." + "There has been an error while trying to fetch the repository. \ + \nHalting the installation." return $result fi fi fi @@ -1392,11 +1470,12 @@ fi result=$? if [[ "$result" -gt 0 ]] ; then "$rvm_path/scripts/log" "error" \ - "There has been an error while trying to fetch / update the source. Halting the installation." + "There has been an error while trying to fetch / update the source. \ + \nHalting the installation." return $result fi fi "$rvm_path/scripts/log" "info" "Copying from repo to src path..." @@ -1407,12 +1486,12 @@ fi return ${result:-0} } -__rvm_check_default() { - +__rvm_check_default() +{ local default_ruby_interpreter current_ruby_interpreter default_ruby_interpreter="$(rvm alias show default 2>/dev/null | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')" current_ruby_interpreter="$(echo "$rvm_ruby_string" | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')" @@ -1424,12 +1503,12 @@ fi return $? } -__rvm_uninstall_ruby() { - +__rvm_uninstall_ruby() +{ local dir if [[ ${rvm_ruby_selected_flag} -eq 0 ]] ; then __rvm_select ; fi if [[ -n "${rvm_ruby_string:-""}" ]] ; then @@ -1473,12 +1552,12 @@ unset rvm_uninstall_flag return 0 } -__rvm_remove_ruby() { - +__rvm_remove_ruby() +{ local dir if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi if [[ -n "${rvm_ruby_string:-""}" ]] ; then @@ -1527,39 +1606,52 @@ unset rvm_remove_flag return 0 } -__rvm_remove_gemsets() { +__rvm_remove_gemsets() +{ + local gemset gemsets + if [[ ${rvm_gems_flag:-0} -eq 1 ]] ; then + "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string gemsets..." gemsets=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}"/ ; find . -maxdepth 1 -mindepth 1 -type d)) for gemset in "${gemsets[@]//.\/}" ; do + if [[ -d "$gemset" ]] ; then + rm -rf "$gemset" + fi - done ; unset gemset gemsets + + done + fi } -__rvm_remove_wrappers() { +__rvm_remove_wrappers() +{ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string wrappers..." local wrapper wrappers wrappers=($(find "$rvm_path/wrappers" -maxdepth 1 -mindepth 1 -type d -iname "*$rvm_ruby_string*" 2>/dev/null)) for wrapper in "${wrappers[@]}" ; do + rm -rf "$wrapper" + done return 0 } -__rvm_remove_environments() { +__rvm_remove_environments() +{ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string environments..." local environments environment environments=($(find "$rvm_path/environments" -maxdepth 1 -mindepth 1 -type f -iname "*$rvm_ruby_string*" )) @@ -1571,11 +1663,12 @@ done return 0 } -__rvm_remove_aliases() { +__rvm_remove_aliases() +{ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string aliases..." local alias_name aliases aliases=($(awk '/'$rvm_ruby_string'/' "$rvm_path/config/alias" | sed 's/=.*//')) @@ -1584,20 +1677,22 @@ # Remove from alias key-value store "$rvm_path/scripts/alias" delete "$alias_name" >/dev/null 2>&1 done } -__rvm_remove_archives() { +__rvm_remove_archives() +{ if [[ ${rvm_archive_flag:-0} -eq 1 ]] ; then "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string archives..." rm -f "${rvm_archives_path:-"$rvm_path/archives"}/${rvm_ruby_package_file}.${rvm_archive_extension}" fi } -__rvm_remove_binaries() { +__rvm_remove_binaries() +{ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string binaries..." # Iterate over all binaries and check for symlinked wrappers etc. local binary_name binaries full_patch_path @@ -1605,20 +1700,21 @@ for binary_name in "${binaries[@]}" ; do full_binary_path="${rvm_bin_path:-"$rvm_path/bin"}/$binary_name" - if [[ -L "$full_binary_path" ]] && "$rvm_path/scripts/match" "$(readlink "$full_binary_path")" "$rvm_ruby_string"; then + if [[ -L "$full_binary_path" ]] \ + && "$rvm_path/scripts/match" "$(readlink "$full_binary_path")" "$rvm_ruby_string"; then rm -f "$full_binary_path" fi done ; unset binaries return 0 } -__rvm_post_install() { - +__rvm_post_install() +{ local rvm_ruby_aliases ruby_alias binary if [[ "$rvm_ruby_interpreter" != "jruby" ]] ; then if [[ ${#binaries[@]} -lt 1 ]] ; then @@ -1674,24 +1770,25 @@ done < <(echo "$rvm_ruby_string" | \tr ' ' '\n' | sort -u) fi } -__rvm_generate_default_docs() { - +__rvm_generate_default_docs() +{ if [[ "$rvm_docs_flag" = "1" && "$rvm_ruby_interpreter" != "macruby" ]]; then __rvm_run_with_env "docs.generate" "$rvm_ruby_string" \ "rvm docs generate-ri" "Attempting to generate ri documentation..." fi } -__rvm_rubygems_setup() { - +__rvm_rubygems_setup() +{ local home path dir directory_name version_number ruby_lib_gem_path - if [[ -n "$(echo "$rvm_ruby_version" | awk '/^1\.9/')" || -n "$(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 @@ -1732,11 +1829,13 @@ version_number="${rvm_ruby_release_version}.${rvm_ruby_major_version}" if [[ "$version_number" == "." ]]; then # TODO: Investigate this if statement, something feels not quite right. - version_number="$(builtin cd "$directory_name" ; find . -maxdepth 1 -mindepth 1 -type f | \grep '^[[:digit:]].[[:digit:]]\(.[[:digit:]]\)\?' | head -n1)" + version_number="$(builtin cd "$directory_name" ; \ + find . -maxdepth 1 -mindepth 1 -type f \ + | \grep '^[[:digit:]].[[:digit:]]\(.[[:digit:]]\)\?' | head -n1)" version_number="${version_number//.\/}" if [[ -n "$version_number" ]]; then ruby_lib_gem_path="${directory_name}/${version_number}" else @@ -1789,11 +1888,12 @@ if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name" ]] ; then mkdir -p "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name" fi __rvm_run "rubygems.extract" \ - "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_gem_package_name.tgz\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" "Extracting $rvm_gem_package_name ..." + "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_gem_package_name.tgz\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \ + "Extracting $rvm_gem_package_name ..." fi builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name" __rvm_run "rubygems.install" \ @@ -1836,12 +1936,12 @@ fi return ${result:-0} } -__rvm_inject_ruby_shebang() { - +__rvm_inject_ruby_shebang() +{ local actual_file __rvm_actual_file $1 if [[ -f "$actual_file" ]] ; then @@ -1849,12 +1949,12 @@ mv "${actual_file}.new" "${actual_file}" ; chmod +x "$actual_file" fi } -__rvm_inject_gem_env() { - +__rvm_inject_gem_env() +{ local actual_file string __rvm_actual_file $1 if [[ -s "$actual_file" ]] ; then @@ -1869,22 +1969,23 @@ fi if [[ -n "$string" ]] ; then - awk "NR==2 {print \"$string\"} {print}" "$actual_file" > "$actual_file.new" + awk "NR==2 {print \"$string\"} {print}" "$actual_file" \ + > "$actual_file.new" mv $actual_file.new $actual_file ; chmod +x "$actual_file" fi fi return 0 } -__rvm_actual_file() { - +__rvm_actual_file() +{ if [[ -L "$1" ]] ; then # If the file is a symlink, actual_file="$(readlink $1)" # read the link target so we can preserve it. else @@ -1894,12 +1995,12 @@ fi return 0 } -__rvm_manage_rubies() { - +__rvm_manage_rubies() +{ local manage_result bin_line manage_result=0 rvm_gemset_name="" @@ -1930,11 +2031,12 @@ __rvm_unset_ruby_variables done else # all - if [[ "$action" != "install" && "$action" != "remove" && "$action" != "uninstall" ]] ; then + if [[ "$action" != "install" && "$action" != "remove" \ + && "$action" != "uninstall" ]] ; then local ruby_string while read -r ruby_string do # Keep this on second line damnit! @@ -1954,10 +2056,11 @@ __rvm_record_install "$ruby_string" fi __rvm_unset_ruby_variables fi - done < <(builtin cd "$rvm_path/rubies" ; find . -maxdepth 1 -mindepth 1 -type d 2> /dev/null | sed -e 's#./##g') + done < <(builtin cd "$rvm_path/rubies" ; \ + find . -maxdepth 1 -mindepth 1 -type d 2> /dev/null | sed -e 's#./##g') else "$rvm_path/scripts/log" "warn" \ 'Really? '"$action"' all? See "rvm list known" and limit the selection to something more sane please :)' fi