/
install
executable file
·191 lines (166 loc) · 7.21 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env bash
unset rvm_auto_flag
install_source_path=$(dirname $0)
if [[ -d "$install_source_path/scripts" ]] && [[ -s "$install_source_path/scripts/utility" ]] ; then
builtin cd $install_source_path
fi
source scripts/version
source scripts/utility
usage() {
echo -e "
Usage:
${0} <options>
Options:
--auto : Automatically update shell profile files.
--prefix : Installation prefix directory.
--help : Display help/usage (this) message
--version : display rvm package version
"
}
if echo "$*" | grep -q 'trace' ; then echo "$*" ; env | grep '^rvm_' ; set -x ; fi
while [[ $# -gt 0 ]] ; do
token="$1" ; shift
case "$token" in
--auto) rvm_auto_flag=1 ;;
--prefix) prefix_path="$1" ; shift ;;
--version) rvm_path="$(pwd)" ; __rvm_version ; unset rvm_path ; exit ;;
--help|*) usage ;;
esac
done
if [[ -z "$rvm_prefix" ]] ; then
__rvm_load_rvmrc
if [[ "root" = "$(whoami)" ]] ; then
rvm_prefix="/usr/local/"
else
rvm_prefix="$HOME/."
fi
fi
if [[ -z "$rvm_path" ]] ; then rvm_path="${rvm_prefix}rvm" ; fi
source scripts/initialize
__rvm_initialize
#
# Setup
#
item="$(tput setaf 2)* $(tput sgr0)"
question="\n$(tput setaf 2)<?>$(tput sgr0)"
cwd=$(pwd)
source_path="${source_path:-$cwd}"
# State what is required to use rvm
echo -e "\nInstalling rvm to $rvm_path/ ..."
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_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"}"
rvm_symlink_path="${rvm_symlink_path:-$rvm_prefix/bin}"
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 $rvm_symlink_path $HOME/.gem/cache
for file in README LICENCE ; do
cp -f "$source_path/$file" "$rvm_path/"
done
#
# Scripts
#
for dir_name in config scripts examples lib hooks ; do
mkdir -p "$rvm_path/$dir_name"
if [[ -d "$source_path/$dir_name" ]] ; then
cp -Rf "$source_path/$dir_name" "$rvm_path"
fi
done ; unset dir_name
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
#
# Bin Scripts
#
# Cleanse and purge...
for file in rvm-prompt rvm rvmsudo ; do
rm -f "$rvm_bin_path/$file"
cp -f "$source_path/binscripts/$file" $rvm_bin_path/
done
chmod +x $rvm_bin_path/*
#
# RC Files
#
if [[ ! -z "$rvm_auto_flag" ]] ; then
echo -e "Checking rc files... ($rvm_rc_files)"
if [[ "$rvm_loaded_flag" != "1" ]] ; then
for rcfile in $(echo $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."
echo -e "\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."
echo -e "\n# rvm-install added:\nif [[ -s $rvm_scripts_path/rvm ]] ; then source $rvm_scripts_path/rvm ; fi\n" >> $rcfile
fi
done
fi
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 -i -e '1,1s=.*=#!'"$new_path/bin/ruby=" "$new_path/bin/$file"
rm -f "$new_path/bin/$file.orig"
chmod +x "$new_path/bin/$file"
fi
done
fi
done
#
# End of migration.
#
if [[ "root" = "$(whoami)" ]] ; then
echo -e "\n Symlinking rvm to $rvm_symlink_path/rvm ..."
mkdir -p $rvm_symlink_path
ln -nfs $rvm_bin_path/rvm $rvm_symlink_path/rvm
ln -nfs $rvm_bin_path/rvmsudo $rvm_symlink_path/rvmsudo
chmod +x $rvm_symlink_path/rvm
chmod +x $rvm_symlink_path/rvmsudo
fi
echo -e "\n$(tput setaf 2)rvm$(tput sgr0) - shell scripts that allows a user to manage multiple ruby versions in their own account."
./scripts/notes
echo -e "$(tput setaf 2)RTFM: $(tput sgr0) http://rvm.beginrescueend.com/"
echo -e "\n$(tput setaf 2)HELP: $(tput sgr0) http://webchat.freenode.net/?channels=rvm "
echo -e "\n********************************************************************************"
name="$(awk -F= '/^[[:space:]]*name/{print $2}' ~/.gitconfig 2>/dev/null)"
echo -e "\n${name:-"$(whoami)"},\n"
echo -e "\nThank you for using rvm. I hope that it makes your work easier and more enjoyable."
echo -e "If you have any questions, issues and/or ideas for improvement please hop in #rvm on irc.freenode.net and let me know."
echo -e "My irc nickname is 'wayneeseguin' and I hang out from ~09:00-17:00EST and again from ~21:00EST-~00:00EST."
echo -e "If I do not respond right away, please hang around after asking your question, I will respond as soon as I am back."
echo -e "Be sure to get head often as rvm development happens fast, you can do this by typing 'rvm update --head'."
echo -e "\n w$(tput setaf 2)⦿‿⦿$(tput sgr0)t!"
echo -e "\n ~ Wayne"
echo -e "\n********************************************************************************"
if [[ "root" != "$(whoami)" ]] ; then
echo -e "\n$(tput setaf 1)You must now finish the install manually:$(tput sgr0)"
echo -e "\n1) Place the folowing line at the end of your shell's loading files(.bashrc and then .bash_profile for bash and .zshrc for zsh), after all path/variable settings:"
echo -e "\n if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi"
echo -e "\n2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly)."
echo -e "\n This means that if you see '[ -z "$PS1" ] && return' then you must remove it and split your .bashrc"
echo -e "\n Put everything *except the return code line(s)* into your .bash_profile, and everything above that code in your .bashrc."
echo -e "\n Be *sure* to REMOVE the '&& return' statement line."
echo -e "\n If you wish to DRY up your config you can 'source ~/.bashrc' at the top of your .bash_profile."
echo -e "\n4) Then $(tput setaf 1)CLOSE THIS SHELL$(tput sgr0) and open a new one in order to use rvm.\n"
fi
if grep '&& return' ~/.bashrc ; then
echo -e "\n\nWARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc. Please remove it and refactor your profiles to be correct. If you have questions about this please visit #rvm on irc.freenode.net.\n\n"
fi
exit 0