scripts/rvm-install in rvm-1.0.6 vs scripts/rvm-install in rvm-1.0.7

- old
+ new

@@ -124,11 +124,11 @@ Be sure to get head often as rvm development happens fast, you can do this by running 'rvm update --head' followed by 'rvm reload' or opening a new shell - w⦿‿⦿$ + w⦿‿⦿t ~ Wayne " } @@ -143,11 +143,11 @@ * If you encounter any issues with a ruby 'X' your best bet is to: rvm remove X ; rvm install X * If you wish to have the 'pretty colors' again, set in ~/.rvmrc: - export rvm_pretty_print=1 + export rvm_pretty_print_flag=1 " } if echo "$*" | grep -q 'trace' ; then echo "$*" ; env | grep '^rvm_' ; set -x ; fi @@ -190,10 +190,11 @@ # Setup & Configuration # item="* " question="\n<?>" cwd="$PWD" + source_path="${source_path:-$cwd}" 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"}" @@ -207,188 +208,305 @@ rvm_rc_files="${rvm_rc_files:-"$HOME/.bash_profile $HOME/.bashrc $HOME/.zshenv"}" fi rvm_gems_path="${rvm_gems_path:-"$rvm_path/gems"}" rvm_rubies_path="${rvm_rubies_path:-"$rvm_path/rubies"}" -rvm_scripts_path="${rvm_scripts_path:-"$rvm_path/scripts"}" rvm_config_path="${rvm_config_path:-"$rvm_path/config"}" rvm_hooks_path="${rvm_hooks_path:-"$rvm_path/hooks"}" rvm_tmp_path="${rvm_tmp_path:-"$rvm_path/tmp"}" -export rvm_gemset_separator="@" # TODO: Remove this after a while. - printf " RVM: Shell scripts enabling management of multiple ruby environments. RTFM: http://rvm.beginrescueend.com/ HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net) " if [[ ${upgrade_flag:-0} -eq 1 ]] ;then + printf "\nUpgrading the RVM installation in $rvm_path/" + else - printf "\nInstalling rvm to $rvm_path/" + + printf "\nInstalling RVM to $rvm_path/" + fi -mkdir -p "$rvm_archives_path" "$rvm_src_path" "$rvm_log_path" "$rvm_bin_path" "$rvm_gems_path" "$rvm_rubies_path" "$rvm_config_path" "$rvm_hooks_path" "$rvm_tmp_path" +for directory in "$rvm_archives_path" "$rvm_src_path" "$rvm_log_path" "$rvm_bin_path" "$rvm_gems_path" "$rvm_rubies_path" "$rvm_config_path" "$rvm_hooks_path" "$rvm_tmp_path" ; do + if [[ ! -d "$directory" ]] ; then + + mkdir -p "$directory" + + fi + +done + for file in README LICENCE ; do + cp -f "$source_path/$file" "$rvm_path/" + done # # Scripts # for dir_name in config scripts examples lib hooks help patches; do - mkdir -p "$rvm_path/$dir_name" + if [[ -d "$source_path/$dir_name" ]] ; then + + if [[ ! -d "$rvm_path/$dir_name" ]] ; then + + mkdir -p "$rvm_path/$dir_name" + + fi + cp -Rf "$source_path/$dir_name" "$rvm_path" + fi -done ; unset dir_name +done + if [[ ! -s "$rvm_config_path/user" ]] ; then - mkdir -p "$rvm_config_path/" echo '# Users settings file, overrides db file settings and persists across installs.' >> "$rvm_config_path/user" fi -scripts=("monitor" "match" "log" "install" "color" "db" "fetch" "log" "set" "package") +scripts=(monitor match log install color db fetch log set package) + for script_name in "${scripts[@]}" ; do - chmod +x "$rvm_scripts_path/$script_name" 2>/dev/null # Hide errors. + + chmod +x "$rvm_path/scripts/$script_name" 2>/dev/null # Hide errors. + done # # Bin Scripts # # Cleanse and purge... for file in rvm-prompt rvm rvmsudo rvm-shell rvm-auto-ruby ; do + rm -f "$rvm_bin_path/$file" + cp -f "$source_path/binscripts/$file" $rvm_bin_path/ + done -chmod +x "$rvm_bin_path"/* +chmod +x "$rvm_bin_path"/* # TODO: this is quite suboptimal. + # # RC Files # if [[ -n "$rvm_auto_flag" ]] ; then + printf "Checking rc files... ($rvm_rc_files)" + if [[ "$rvm_loaded_flag" != "1" ]] ; then + for rcfile in $(printf $rvm_rc_files) ; do + if [[ ! -f $rcfile ]] ; then touch $rcfile ; fi + if [[ -s "$HOME/.profile" ]] ; then + if ! grep -q '.profile' "$rcfile" ; then + echo " Adding 'if [[ -s \$HOME/.profile ]] ; then source \$HOME ; fi' to $rcfile." + printf "\n# rvm-install added line:\nif [[ -s \$HOME/.profile ]] ; then source \$HOME/.profile ; fi\n" >> "$rcfile" + fi + fi + if ! grep -q "scripts\/rvm" "$rcfile" ; then - echo " Adding 'if [[ -s $rvm_scripts_path/rvm ]] ; then source $rvm_scripts_path/rvm ; fi' to $rcfile." - printf "\n# rvm-install added:\nif [[ -s $rvm_scripts_path/rvm ]] ; then source $rvm_scripts_path/rvm ; fi\n" >> "$rcfile" + + echo " Adding 'if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi' to $rcfile." + + printf "\n# rvm-install added:\nif [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi\n" >> "$rcfile" + fi + done fi fi # # Initial Interpreter Gemsets. # if [[ -d gemsets/ ]] ; then - mkdir -p "$rvm_gemsets_path" + if [[ ! -d "$rvm_path/gemsets" ]] ; then + + mkdir -p "$rvm_path/gemsets" + + fi + for gemset_file in $(builtin cd gemsets ; find \. -iname '*.gems' | sed 's/^\.\///') ; do - destination="$rvm_gemsets_path/$gemset_file" + + destination="$rvm_path/gemsets/$gemset_file" + destination_path="$(dirname "$destination")" + if [[ ! -s "$destination" ]] ; then + mkdir -p "$destination_path" + cp "gemsets/$gemset_file" "$destination" + fi - done ; unset destination destination_path gemset_file + + done + + unset destination destination_path gemset_file + fi if [[ -d patchsets/ ]] ; then - mkdir -p "$rvm_patchsets_path" - for patchset_file in $(builtin cd patchsets ; find \. -iname '*' | sed 's/^\.\///') ; do - destination="$rvm_patchsets_path/$patchset_file" - destination_path="$(dirname "$destination")" + + if [[ ! -d "$rvm_path/patchsets" ]] ; then + + mkdir -p "$rvm_path/patchsets" + + fi + + patchsets=($(builtin cd patchsets ; find \. -iname '*' | sed 's/^\.\///')) + + for patchset_file in "${patchsets[@]}" ; do + + destination="$rvm_path/patchsets/$patchset_file" + if [[ ! -s "$destination" ]] ; then + + destination_path="$(dirname "$destination")" + mkdir -p "$destination_path" + cp "patchsets/$patchset_file" "$destination" + fi - done ; unset destination destination_path patchset_file + done + fi # # Migrate ~/.rvm/ruby-X,jruby-X,... to ~/.rvm/rubies/ for 0.1.0. # rvm_rubies_path="${rvm_rubies_path:-"$rvm_path/rubies"}" + mkdir -p "$rvm_rubies_path/" + for ruby in $rvm_path/ruby-* $rvm_path/jruby-* $rvm_path/mput-* $rvm_path/rbx-* $rvm_path/maglev-* $rvm_path/ree-* ; do + if [[ -d "$ruby" ]] ; then + mv "$ruby" "$rvm_rubies_path/" + new_path="$rvm_rubies_path/$(basename $ruby)" + for file in gem rake ; do + if [[ -s "$new_path/bin/$file" ]] ; then + sed -e '1,1s=.*=#!'"${new_path}/bin/ruby=" "${new_path}/bin/${file}" > "${new_path}/bin/${file}.new" + mv -f "$new_path/bin/$file.new" "$new_path/bin/$file" + chmod +x "$new_path/bin/$file" + fi + done + fi + done # # End of rubies migration. # # # Migrate old gemset directories to new gemset pattern. # for gemset in "$rvm_path"/gems/*\%* ; do - new_path=${gemset/\%/${rvm_gemset_separator}} + + new_path=${gemset/\%/${rvm_gemset_separator:-"@"}} + if [[ -d "$gemset" ]] && [[ ! -d "$new_path" ]] ; then + printf "\n Renaming $(basename "$gemset") to $(basename "$new_path") for new gemset separator." + mv "$gemset" "$new_path" + fi + done for gemset in "$rvm_path"/gems/*\+* ; do - new_path=${gemset/\+/${rvm_gemset_separator}} + + new_path=${gemset/\+/${rvm_gemset_separator:-"@"}} + if [[ -d "$gemset" && ! -d "$new_path" ]] ; then + printf "\n Renaming $(basename "$gemset") to $(basename "$new_path") for new gemset separator." + mv $gemset $new_path + fi + done for gemset in "$rvm_path"/gems/*\@ ; do + new_path=$(echo $gemset | sed -e 's#\@$##') + if [[ -d "$gemset" && ! -d "$new_path" ]] ; then + printf "\n Fixing: $(basename "$gemset") to $(basename "$new_path") for new gemset separator." + mv "$gemset" "$new_path" + fi + done # Move from legacy defaults to the new, alias based system. if [[ -s "$rvm_config_path/default" ]]; then - original_version="$(basename "$(grep GEM_HOME "$rvm_config_path/default" | awk -F"'" '{print $2}' | sed "s#\%#${rvm_gemset_separator}#")")" + + original_version="$(basename "$(grep GEM_HOME "$rvm_config_path/default" | awk -F"'" '{print $2}' | sed "s#\%#${rvm_gemset_separator:-"@"}#")")" + if [[ -n "$original_version" ]]; then - "$rvm_scripts_path/alias" create default "$original_version" &> /dev/null + + "$rvm_path/scripts/alias" create default "$original_version" &> /dev/null + fi ; unset original_version + rm -rf "$rvm_config_path/default" + fi # # End of gemset migration. # printf "\n Correct permissions for base binaries in $rvm_bin_path..." mkdir -p "$rvm_bin_path" for file in rvm rvmsudo rvm-shell rvm-auto-ruby ; do + [[ -s "$rvm_bin_path/$file" ]] && chmod +x "$rvm_bin_path/$file" -done; unset file + +done + printf "\n Copying manpages into place." -for man_file in $(builtin cd "$install_source_path/man" ; find * -type f -maxdepth 0 -print); do +files=($(builtin cd "$install_source_path/man" ; find . -maxdepth 1 -mindepth 1 -type f -print)) + +for file in "${files[@]//.\/}" ; do + rm -rf "$rvm_man_path/$man_file" + cp -R "$install_source_path/man/$man_file" "$rvm_man_path/" + done [[ "$upgrade_flag" = 0 ]] && ./scripts/notes name="$(awk -F= '/^[[:space:]]*name/{print $2}' ~/.gitconfig 2>/dev/null)" @@ -398,16 +516,22 @@ upgrade_notes check_rubyopt_conditions printf "\nUpgrade of RVM in $rvm_path/ is complete.\n\n" + else + if [[ ${rvm_selfcontained:-0} -eq 1 ]] ; then + installation_complete + fi if [[ -s "$HOME/.bashrc" ]] && grep -q '&& return' "$HOME/.bashrc" ; then + andand_return_warning + fi check_rubyopt_conditions printf "\nInstallation of RVM to $rvm_path/ is complete.\n\n"