wayneeseguin-rvm 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
data/bin/rvm-install CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # Hot potato!!! Bash it!
4
- exec "bash -l -c 'cd #{File.dirname(File.dirname(__FILE__))} && ./bash/rvm-install #{ARGV.join(' ')} && source ~/.rvm/bin/rvm'"
4
+ exec "bash -l -c 'cd #{File.dirname(File.dirname(__FILE__))} && ./scripts/rvm-install #{ARGV.join(' ')} && source ~/.rvm/scripts/rvm'"
5
5
 
data/bin/rvm-update CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # Hot potato!!! Bash it!
4
- exec "bash -l -c 'cd #{File.dirname(File.dirname(__FILE__))} && ./bash/rvm-update #{ARGV.join(' ')} && source ~/.rvm/bin/rvm'"
4
+ exec "bash -l -c 'cd #{File.dirname(File.dirname(__FILE__))} && ./scripts/rvm-update #{ARGV.join(' ')} && source ~/.rvm/scripts/rvm'"
5
5
 
data/config/cache ADDED
@@ -0,0 +1,23 @@
1
+ rvm_niceness=0
2
+ rvm_archives_path=$rvm_install_path/archives
3
+ rvm_source_path=$rvm_install_path/src
4
+ rvm_log_path=$rvm_install_path/log
5
+ rvm_bin_path=$rvm_install_path/bin
6
+ rvm_gem_path=$rvm_install_path/gems
7
+ rvm_config_path=$rvm_install_path/config
8
+ rvm_ruby_repo_url=http://svn.ruby-lang.org/repos/ruby
9
+ rvm_rubinius_repo_url=git://github.com/evanphx/rubinius.git
10
+ rvm_macruby_repo_url=http://svn.macosforge.org/repository/ruby/MacRuby
11
+ rvm_jruby_repo_url=git://kenai.com/jruby~main
12
+ rvm_ruby_configure=--enable-shared
13
+ rvm_ruby_interpreter=ruby
14
+ rvm_jruby_version=1.3.1
15
+ rvm_ree_version=1.8.6
16
+ rvm_ree_patch_level=20090610
17
+ rvm_ruby_version=1.8.6
18
+ rvm_ruby_1.9.1_patch_level=p243
19
+ rvm_ruby_1.9.2_patch_level=preview1
20
+ rvm_ruby_1.8.5_patch_level=p115
21
+ rvm_ruby_1.8.6_patch_level=p369
22
+ rvm_ruby_1.8.7_patch_level=p174
23
+
@@ -28,3 +28,5 @@
28
28
  # Default Log Path
29
29
  #rvm_log_path="${rvm_install_path}/log"
30
30
 
31
+ # Default gems directory
32
+ # rvm_gem_path="$HOME/.gem"
data/rvm.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rvm}
8
- s.version = "0.0.24"
8
+ s.version = "0.0.25"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wayne E. Seguin"]
12
- s.date = %q{2009-08-27}
12
+ s.date = %q{2009-08-30}
13
13
  s.description = %q{Manages Ruby interpreter installations and switching between them.}
14
14
  s.email = %q{wayneeseguin@gmail.com}
15
15
  s.executables = ["rvm-install", "rvm-update"]
@@ -20,12 +20,13 @@ Gem::Specification.new do |s|
20
20
  "INSTALL",
21
21
  "LICENCE",
22
22
  "README",
23
- "bash/rvm",
24
- "bash/rvm-install",
25
- "bash/rvm-update",
26
- "bash/rvmrc.sample",
23
+ "config/cache",
24
+ "examples/rvmrc",
27
25
  "lib/rvm.rb",
28
- "rvm.gemspec"
26
+ "rvm.gemspec",
27
+ "scripts/rvm",
28
+ "scripts/rvm-install",
29
+ "scripts/rvm-update"
29
30
  ]
30
31
  s.homepage = %q{http://github.com/wayneeseguin/rvm}
31
32
  s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
data/scripts/rvm ADDED
@@ -0,0 +1,1064 @@
1
+ #!/bin/bash
2
+
3
+ #
4
+ # License: See LICENSE
5
+ #
6
+
7
+ #
8
+ # Functions
9
+ #
10
+ function rvm-meta {
11
+ rvm_meta_author="Wayne E. Seguin"
12
+ rvm_meta_author_email="wayneeseguin@gmail.com"
13
+ rvm_meta_website="http://rvm.beginrescueend.com/"
14
+ rvm_meta_version="0.0.25"
15
+ rvm_meta_updated="2009.08.25"
16
+ }
17
+
18
+ function rvm-version { rvm-meta ; echo "rvm $rvm_meta_version ($rvm_meta_updated) [$rvm_meta_website]" ; }
19
+
20
+ function rvm-usage {
21
+
22
+ rvm-meta
23
+
24
+ cat <<-Usage
25
+
26
+ About:
27
+
28
+ rvm ${rvm_meta_version} ${rvm_meta_website}
29
+
30
+ by ${rvm_meta_author} (${rvm_meta_author_email})
31
+
32
+ Installation:
33
+
34
+ $ gem install rvm # Install the rvm gem
35
+ $ rvm-install # Install rvm, adds hooks for bash & zsh
36
+
37
+ Usage:
38
+
39
+ rvm Action [Implementation] [Options]
40
+
41
+ Action:
42
+
43
+ * usage - Show this usage information
44
+ use - Switch to using a specific ruby version (new login shell)
45
+ info - Show information for current ruby
46
+ list - Show currently installed versions
47
+ gemdir - Switch to gem directory for installation (new login shell)
48
+ srcdir - Switch to src directory for the current ruby installation
49
+ gemdup - Clone source version gems to current version
50
+ (highly expiramental) Example: rvm gemdup ~/.gem/ruby/1.8/
51
+ install - Install a ruby version, default is from source
52
+ uninstall - Uninstall a ruby version
53
+ reset - Remove default and current settings, exit the shell.
54
+ (If you experience odd behavior try this first)
55
+ reload - Reload rvm source itself (useful after changing rvm source)
56
+ debug - Emit environment & configuration information for *current* ruby
57
+
58
+ Implementation:
59
+
60
+ * ruby - MRI/YARV Ruby (The Standard), defaults to 1.8.6
61
+ jruby - jRuby
62
+ ree - Ruby Enterprise Edition
63
+ default - Resets to the default system ruby
64
+ all - Used with install, installs all latest known versions
65
+
66
+ Options:
67
+
68
+ -v|--version - Ruby Package Version, defaults to 'latest'
69
+ -l|--level - Patch level for the specified Ruby version
70
+ -p|--prefix - Package and source directory prefix, with trailing slash!
71
+ Default is a users home directory and /usr/local/ for root
72
+ -c|--configure - Options for source compile (default: --enable-shared)
73
+ -a|--archives - Directory to place downladed files into (~/.rvm/archives/)
74
+ -n|--nice - Niceness level (default: 0)
75
+ -d|--debug - Toggle debug mode on for very verbose output.
76
+ -m|--gem-set - Named gem set for switching between different gem sets
77
+ --rm-gem-set - Removes a named gemset.
78
+
79
+ Resources:
80
+
81
+ http://rvm.beginrescueend.com/notes/
82
+ http://rvm.beginrescueend.com/examples/
83
+ http://rvm.beginrescueend.com/todo/
84
+ https://www.pivotaltracker.com/projects/26822
85
+
86
+ Usage
87
+
88
+ }
89
+
90
+ # Logging functions based on level
91
+ function rvm-log {
92
+
93
+ case "$1" in
94
+ debug) shift ; echo -e "\n\033[0;35m <d> $* \033[0m" ;;
95
+ info) shift ; echo -e "\n\033[0;32m <i> $* \033[0m" ;;
96
+ warn) shift ; echo -e "\n\033[0;33m <w> $* \033[0m" ;;
97
+ fail) shift ; echo -e "\n\033[0;31m <e> $* \033[0m" ; return 1 ;;
98
+ *) echo -e "$*"
99
+ esac
100
+ }
101
+
102
+ function rvm-clean-path {
103
+ PATH=`echo $PATH | tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | tr -s '\n' ':'`
104
+ PATH="${PATH%:}"
105
+ export PATH
106
+ }
107
+
108
+ function rvm-remove-from-path {
109
+ PATH=`echo $PATH | tr -s ':' '\n' | grep -v "\.rvm" | tr -s '\n' ':'`
110
+ PATH="${PATH%:}"
111
+ export PATH
112
+ }
113
+
114
+ function rvm-gi { gem install -q --no-rdoc --no-ri $* ; }
115
+ function rvm-gems-install { for gem in $* ; do rvm-gi $gem ; done }
116
+
117
+ function rvm-set-defaults {
118
+
119
+ # TODO: Store defaults in "defaults/" dir.
120
+ if [ ! -f $rvm_install_path/default ] ; then
121
+ for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do
122
+ eval "export $variable"
123
+ eval value=\$${variable}
124
+ echo "${variable}='$value' ; export ${variable}" >> $rvm_install_path/default
125
+ done
126
+ fi
127
+
128
+ if [ -s $rvm_install_path/default_path ] ; then
129
+ rvm_default_path=`cat $rvm_install_path/default_path`
130
+ else
131
+ rvm-clean-path # Clean the path the first time we compute default path.
132
+ rvm-remove-from-path
133
+ echo $PATH > $rvm_install_path/default_path
134
+ rvm_default_path=$PATH
135
+ fi
136
+
137
+ rvm_default_ps1=`rvm-cache rvm_default_ps1`
138
+ if [ -z "$rvm_default_ps1" ] ; then
139
+ rvm_default_ps1=$PS1
140
+ rvm-cache "rvm_default_ps1" "$rvm_default_ps1"
141
+ fi
142
+
143
+ if [ -s $rvm_install_path/default_user_gem_path ] ; then
144
+ rvm_default_user_gem_path=`cat $rvm_install_path/default_user_gem_path`
145
+ else
146
+ ruby -r rubygems -e "puts Gem::default_path.compact.first" > $rvm_install_path/default_user_gem_path
147
+ fi
148
+
149
+ if [ -s $rvm_install_path/default_system_gem_path ] ; then
150
+ rvm_default_system_gem_path=`cat $rvm_install_path/default_system_gem_path`
151
+ else
152
+ ruby -r rubygems -e "puts Gem::default_path.compact[1] || Gem::default_path.compact.first" > $rvm_install_path/default_system_gem_path
153
+ fi
154
+
155
+ if [ -s $rvm_install_path/default_system_ruby ] ; then
156
+ default_system_ruby=`cat $rvm_install_path/default_system_ruby`
157
+ else
158
+ default_system_ruby=`which ruby`
159
+ echo $default_system_ruby > $rvm_install_path/default_system_ruby
160
+ fi
161
+
162
+ }
163
+
164
+ function rvm-initialize {
165
+
166
+ rvm_curl=`which curl`
167
+ if [ $? -ne 0 ] ; then
168
+ rvm-log "fail" "rvm expects that curl is available, which curl shows no curl :("
169
+ else
170
+ rvm_curl="$rvm_curl -O -L -s -C - "
171
+ fi
172
+
173
+ rvm_niceness=${rvm_niceness:-0}
174
+
175
+ # TODO: Sanitize user input, ensure that there is a / a the end...
176
+ if [ "`whoami`" = "root" ] ; then
177
+ rvm-log "fail" "root user support is not yet implemented."
178
+ #rvm_prefix_path=${rvm_prefix_path:-/usr/local/}
179
+ else
180
+ rvm_prefix_path=${rvm_prefix_path:-"$HOME/."}
181
+ fi
182
+ if [ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '.' -o "${rvm_prefix_path#${rvm_prefix_path%?}}" = '/' ] ; then
183
+ rvm_install_path="${rvm_prefix_path}rvm"
184
+ else
185
+ rvm_install_path="${rvm_prefix_path}/rvm"
186
+ fi
187
+ rvm_archives_path="${rvm_archives_path:-"${rvm_install_path}/archives"}"
188
+ rvm_source_path="${rvm_source_path:-"${rvm_install_path}/src"}"
189
+ rvm_log_path=${rvm_log_path:-"${rvm_install_path}/log"}
190
+ rvm_bin_path=${rvm_bin_path:-"${rvm_install_path}/bin"}
191
+ rvm_gem_path=${rvm_gem_path:-"${rvm_install_path}/gems"}
192
+ rvm_config_path=${rvm_config_path:-"${rvm_install_path}/config"}
193
+
194
+ rvm_ruby_repo_url="${rvm_ruby_repo_url:-"http://svn.ruby-lang.org/repos/ruby"}"
195
+ rvm_rubinius_repo_url="${rvm_rubinius_repo_url:-"git://github.com/evanphx/rubinius.git"}"
196
+ rvm_macruby_repo_url="${rvm_macruby_repo_url:-"http://svn.macosforge.org/repository/ruby/MacRuby"}"
197
+ rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
198
+
199
+ if [ ! -z "$rvm_ruby_configure" ] ; then
200
+ rvm_ruby_configure="$(echo $rvm_ruby_configure | tr ',-' ' -')"
201
+ fi
202
+ rvm-clean-path
203
+ rvm_result=$(echo $PATH | grep 'rvm\/bin:')
204
+ if [ -z $rvm_result ] ; then
205
+ PATH=$rvm_bin_path:$PATH ; export PATH
206
+ fi
207
+
208
+ mkdir -p $rvm_source_path $rvm_install_path/bin $rvm_archives_path
209
+ }
210
+
211
+ function rvm-curl {
212
+
213
+ pushd $rvm_archives_path > /dev/null
214
+ eval $rvm_curl "$1"
215
+ popd > /dev/null
216
+
217
+ }
218
+
219
+ function rvm-install-source {
220
+
221
+ if [ -z "$rvm_selected" ] ; then rvm-select $* ; fi
222
+
223
+ rvm-log "info" "Installing Ruby from source to: $rvm_install_path/$rvm_ruby_package_name"
224
+ mkdir -p $rvm_log_path/$rvm_ruby_package_name
225
+
226
+ pushd $rvm_source_path > /dev/null
227
+
228
+ if [ -z "$rvm_ruby_tag" -a -z "$rvm_ruby_rev" ] ; then
229
+ if [ ! -d $rvm_source_path/$rvm_ruby_package_name ] ; then
230
+ rvm_url="${rvm_url:-"ftp://ftp.ruby-lang.org/pub/ruby/1.$rvm_major_version/$rvm_ruby_package_name.tar.gz"}"
231
+ rvm-log "info" "\tDownloading $rvm_ruby_package_name, this may take a while depending on your connection..."
232
+ rvm-curl $rvm_url
233
+
234
+ rvm-log "info" "\tExtracting $rvm_ruby_package_name ..."
235
+ mkdir -p $rvm_source_path/$rvm_ruby_package_name
236
+ nice -n $rvm_niceness tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path
237
+ fi
238
+ cd $rvm_source_path/$rvm_ruby_package_name
239
+ else
240
+ if [ -z "$rvm_ruby_rev" ] ; then
241
+ # TODO: Check if tag v is valid
242
+ rvm_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag
243
+ rvm_rev=""
244
+ else
245
+ if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then
246
+ rvm_url=$rvm_ruby_repo_url/branches/ruby_1_${rvm_major_version}_${rvm_minor_version}
247
+ rvm_rev=""
248
+ else
249
+ rvm_url=$rvm_ruby_repo_url/branches/ruby_1_${rvm_major_version}_${rvm_minor_version}
250
+ rvm_rev="-r $rvm_ruby_rev"
251
+ fi
252
+ fi
253
+ rvm-log "info" "\tRetrieving Ruby from $rvm_url"
254
+ mkdir -p $rvm_source_path/$rvm_ruby_package_name
255
+ # TODO: Instead of always forcing, check if it's already svn for correct url and simply check out required revision
256
+ svn checkout -q $rvm_rev --force $rvm_url $rvm_source_path/$rvm_ruby_package_name
257
+ cd $rvm_source_path/$rvm_ruby_package_name
258
+ autoconf
259
+ fi
260
+
261
+ if [ -s ./configure ] ; then
262
+ rvm-log "info" "\tConfiguring $rvm_ruby_package_name using ${rvm_ruby_configure:-"--enable-shared"}, this may take a while depending on your cpu(s)..."
263
+ nice -n $rvm_niceness ./configure --prefix=$rvm_install_path/$rvm_ruby_package_name ${rvm_ruby_configure:-"--enable-shared"} > $rvm_log_path/$rvm_ruby_package_name/configure.log 2> $rvm_log_path/$rvm_ruby_package_name/configure.error.log
264
+ else
265
+ rvm-log "warn" "\tSkipping configure step, ./configure file does not exist."
266
+ fi
267
+
268
+ rvm-log "info" "\tCompiling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..."
269
+ if [ -z "$rvm_ruby_make" ] ; then
270
+ nice -n $rvm_niceness make > $rvm_log_path/$rvm_ruby_package_name/make.log 2> $rvm_log_path/$rvm_ruby_package_name/make.error.log
271
+ else
272
+ nice -n $rvm_niceness $rvm_ruby_make > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log
273
+ fi
274
+ if [ -z "$rvm_ruby_make" ] ; then
275
+ rvm-log "info" "\tInstalling $rvm_ruby_package_name"
276
+ nice -n $rvm_niceness make install > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log
277
+ else
278
+ nice -n $rvm_niceness $rvm_ruby_make_install > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log
279
+ fi
280
+
281
+ chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/*
282
+
283
+ ln -fs $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name
284
+
285
+ rvm-log "info" "\tInstalling rubygems dedicated to $rvm_ruby_package_name..."
286
+ rvm_gem_package_name="rubygems-1.3.5"
287
+ rvm_gem_url="http://rubyforge.org/frs/download.php/60718/$rvm_gem_package_name.tgz"
288
+ if [ -d $rvm_source_path/$rvm_gem_package_name ] ; then
289
+ cd $rvm_source_path/$rvm_gem_package_name
290
+ else
291
+ rvm-curl $rvm_gem_url
292
+ mkdir -p $rvm_source_path/$rvm_gem_package_name
293
+ nice -n $rvm_niceness tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path
294
+ fi
295
+ # Well this is fun... fix nil error on require_paths:
296
+ sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb
297
+
298
+ nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log
299
+ popd > /dev/null
300
+ rvm-log "info" "Installation of $rvm_ruby_package_name complete."
301
+
302
+ for rvm_gem_name in rake ; do
303
+ rvm-log "info" "Installing $rvm_gem_name"
304
+ nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log
305
+ done
306
+ }
307
+
308
+ function rvm-install-ruby {
309
+
310
+ if [ -z "$rvm_selected" ] ; then rvm-select $* ; fi
311
+
312
+ if [ -z "$RUBYOPT" ] ; then ruby_options=$RUBYOPT ; unset RUBYOPT ; fi
313
+
314
+ case "$rvm_ruby_interpreter" in
315
+
316
+ macruby)
317
+ if [ "`uname`" = "Darwin" ] ; then
318
+ rvm_ruby_repo_url=$rvm_macruby_repo_url
319
+ rvm_ruby_configure=""
320
+ rvm_ruby_make="rake macruby:build"
321
+ rvm_ruby_make_install="rake install"
322
+ rvm_ruby_rev="head"
323
+ DESTDIR="$rvm_install_path/$rvm_ruby_package_name" ; export DESTDIR
324
+ if [ -z "$rvm_ruby_rev" ] ; then
325
+ # TODO: Check if tag v is valid
326
+ rvm_ruby_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag
327
+ rvm_ruby_rev=""
328
+ else
329
+ if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then
330
+ rvm_ruby_url=$rvm_ruby_repo_url/trunk
331
+ rvm_ruby_rev=""
332
+ else
333
+ rvm_ruby_url=$rvm_ruby_repo_url/trunk
334
+ rvm_ruby_rev="-r $rvm_ruby_rev"
335
+ fi
336
+ fi
337
+ rvm-log "info" "\tRetrieving MacRuby from $rvm_url"
338
+ #mkdir -p $rvm_source_path/$rvm_ruby_package_name
339
+ # TODO: Instead of always forcing, check if it's already svn for correct url and simply check out required revision
340
+ #svn checkout -q $rvm_rev --force $rvm_url $rvm_source_path/$rvm_ruby_package_name
341
+ cd $rvm_source_path/$rvm_ruby_package_name
342
+ rvm-install-source
343
+ unset DESTDIR
344
+ else
345
+ rvm-log "fail" "MacRuby can only be installed on a Darwin OS."
346
+ fi
347
+ ;;
348
+
349
+ ruby-enterprise|ree)
350
+ rvm_url="http://rubyforge.org/frs/download.php/58677/$rvm_ruby_package_name.tar.gz"
351
+ rvm-log "info" "Installing Ruby Enterprise Edition from source to: $rvm_install_path/$rvm_ruby_package_name"
352
+ pushd $rvm_source_path > /dev/null
353
+ if [ -d $rvm_source_path/$rvm_ruby_package_name ] ; then
354
+ cd $rvm_source_path/$rvm_ruby_package_name
355
+ else
356
+ rvm-log "info" "\tDownloading $rvm_ruby_package_name, this may take a while depending on your connection..."
357
+ rvm-curl $rvm_url
358
+ rvm-log "info" "\tExtracting $rvm_ruby_package_name..."
359
+ mkdir -p $rvm_source_path/$rvm_ruby_package_name
360
+ nice -n $rvm_niceness tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path
361
+ fi
362
+
363
+ rvm-log "info" "\tInstalling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..."
364
+ mkdir -p $rvm_log_path/$rvm_ruby_package_name
365
+
366
+ cd $rvm_source_path/$rvm_ruby_package_name
367
+ nice -n $rvm_niceness ./installer -a $rvm_install_path/ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level --dont-install-useful-gems --no-tcmalloc > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log
368
+ chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/*
369
+
370
+ ln -fs $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name
371
+
372
+ rvm-log "info" "\tInstalling rubygems dedicated to $rvm_ruby_package_name..."
373
+ rvm_gem_package_name="rubygems-1.3.5"
374
+ rvm_gem_url="http://rubyforge.org/frs/download.php/60718/$rvm_gem_package_name.tgz"
375
+ if [ -d $rvm_source_path/$rvm_gem_package_name ] ; then
376
+ cd $rvm_source_path/$rvm_gem_package_name
377
+ else
378
+ rvm-curl $rvm_gem_url
379
+ mkdir -p $rvm_source_path/$rvm_gem_package_name
380
+ nice -n $rvm_niceness tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path
381
+ fi
382
+ # Well this is fun... fix nil error on require_paths:
383
+ sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb > $rvm_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log
384
+
385
+ nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log
386
+ rvm-log "info" "Installation of $rvm_ruby_package_name complete."
387
+ popd > /dev/null
388
+
389
+ for rvm_gem_name in rake ; do
390
+ rvm-log "info" "Installing $rvm_gem_name"
391
+ nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log
392
+ done
393
+ ;;
394
+
395
+ rubinius)
396
+ rvm_ruby_repo_url=$rvm_rubinius_repo_url
397
+ rvm_ruby_configure=""
398
+ rvm_ruby_make="rake"
399
+ rvm_ruby_make_install="rake install"
400
+ #rvm_ruby_rev="head"
401
+ # TODO: Check if already git repo, then git pull origin master && build
402
+ if [ ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version -o ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git ] ; then
403
+ rm -rf $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version
404
+ git clone --depth 1 $rvm_ruby_repo_url $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version
405
+ fi
406
+ cd $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version && rake build
407
+ for binary in ruby irb ; do
408
+ ln -fs $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/bin/rbx $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/bin/$binary
409
+ done
410
+ ;;
411
+
412
+ jruby)
413
+ rvm_package_file="$rvm_ruby_interpreter-bin-$rvm_ruby_version"
414
+ rvm_url="http://dist.codehaus.org/$rvm_ruby_interpreter/$rvm_ruby_version/$rvm_package_file.zip"
415
+ rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
416
+
417
+ rvm-log "info" "Installing jRuby to: $rvm_install_path/$rvm_ruby_package_name"
418
+ mkdir -p $rvm_log_path/$rvm_ruby_package_name
419
+ pushd $rvm_source_path > /dev/null
420
+
421
+
422
+ if [ ! -z "$rvm_ruby_rev" ] ; then
423
+ if [ ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version -o ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git ] ; then
424
+ git clone --depth 1 $rvm_jruby_repo_url $rvm_source_path/$rvm_ruby_package_name
425
+ cd $rvm_source_path/$rvm_ruby_package_name && ant
426
+ fi
427
+ else
428
+ if [ -d $rvm_source_path/$rvm_ruby_package_name ] ; then
429
+ cd $rvm_source_path/$rvm_ruby_package_name
430
+ else
431
+ rvm-log "info" "\tDownloading $rvm_package_file, this may take a while depending on your connection..."
432
+ rvm-curl $rvm_url
433
+ rvm-log "info" "\tExtracting $rvm_package_file..."
434
+ nice -n $rvm_niceness unzip -q $rvm_archives_path/$rvm_package_file.zip -d $rvm_source_path
435
+ cd $rvm_source_path/$rvm_ruby_package_name
436
+ fi
437
+ fi
438
+
439
+ rvm-log "info" "\tInstalling $rvm_ruby_package_name..."
440
+ mkdir -p $rvm_install_path/$rvm_ruby_package_name/bin/
441
+ rsync -ag $rvm_source_path/$rvm_ruby_package_name/ $rvm_install_path/$rvm_ruby_package_name/
442
+ cd $rvm_source_path/$rvm_ruby_package_name/tool/nailgun && make > $rvm_log_path/$rvm_ruby_package_name/install.nailgun.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.nailgun.log
443
+ popd > /dev/null
444
+ chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/*
445
+ for binary in jruby jgem jirb ; do
446
+ ln -fs $rvm_install_path/$rvm_ruby_package_name/bin/$binary $rvm_install_path/$rvm_ruby_package_name/bin/${binary#j}
447
+ done
448
+
449
+ ln -fs $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name
450
+
451
+ for rvm_gem_name in rake jruby-openssl ; do
452
+ rvm-log "info" "Installing $rvm_gem_name"
453
+ nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/jgem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log
454
+ done
455
+ ;;
456
+
457
+ ruby)
458
+ rvm-install-source $*
459
+ ;;
460
+
461
+ default)
462
+ rvm-log "fail" "please specify a ruby implementation to install."
463
+ ;;
464
+ *) rvm-log "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known."
465
+
466
+ esac
467
+
468
+ if [ ! -z "$ruby_options" ] ; then
469
+ RUBYOPT=$ruby_options ; export RUBYOPT
470
+ fi
471
+
472
+ }
473
+
474
+ function rvm-uninstall {
475
+
476
+ if [ -z "$rvm_selected" ] ; then rvm-select $* ; fi
477
+
478
+ if [ ! -z "$rvm_ruby_package_name" ] ; then
479
+ for dir in $rvm_source_path $rvm_install_path ; do
480
+ if [ -d $dir/$rvm_ruby_package_name ] ; then
481
+ rvm-log "info" "Removing $dir/$rvm_ruby_package_name..."
482
+ rm -rf $dir/$rvm_ruby_package_name
483
+ else
484
+ rvm-log "info" "it seems that $dir/$rvm_ruby_package_name is already non existent."
485
+ fi
486
+ if [ -e $rvm_bin_path/$rvm_ruby_package_name ] ; then
487
+ rm -f $rvm_bin_path/$rvm_ruby_package_name
488
+ fi
489
+ done ; unset dir
490
+ rm -rf $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version*/
491
+ else
492
+ rvm-log "fail" "Cannot uninstall unknown package '$rvm_ruby_package_name'"
493
+ fi
494
+
495
+ }
496
+
497
+ # rvm-select implementation version patch_level
498
+ function rvm-select {
499
+
500
+ rvm_ruby_interpreter="${1:-$rvm_ruby_interpreter}"
501
+ rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}" # Default is standard ruby
502
+
503
+ if [ "$rvm_ruby_version" = "1.8" ] ; then rvm_ruby_version="1.8.6" ; fi
504
+ if [ "$rvm_ruby_version" = "1.9" ] ; then rvm_ruby_version="1.9.1" ; fi
505
+
506
+ case "$rvm_ruby_interpreter" in
507
+ macruby)
508
+ if [ "`uname`" = "Darwin" ] ; then
509
+ rvm_ruby_repo_url=$rvm_macruby_repo_url
510
+ rvm_ruby_version="head" # For now we are only supporting latest
511
+ unset rvm_ruby_patch_level
512
+ else
513
+ rvm-log "fail" "MacRuby can only be installed on a Darwin OS."
514
+ fi
515
+ ;;
516
+
517
+ rubinius)
518
+ rvm_ruby_version="head"
519
+ unset rvm_ruby_patch_level
520
+ rvm_ruby_repo_url=$rvm_rubinius_repo_url
521
+ rvm_ruby_configure=""
522
+ rvm_ruby_make="build"
523
+ rvm_ruby_make_install=""
524
+ #rvm_ruby_rev="head"
525
+ ;;
526
+
527
+ jruby)
528
+ rvm_ruby_version="${rvm_ruby_version:-1.3.1}"
529
+ unset rvm_ruby_patch_level
530
+ if [ "$rvm_ruby_version" != "1.2.0" -a "$rvm_ruby_version" != "1.3.1" ] ; then
531
+ rvm-log "fail" "Unknown jRuby version: $rvm_ruby_version"
532
+ fi
533
+ alias jruby_ng="jruby --ng"
534
+ alias jruby_ng_server="jruby --ng-server"
535
+ ;;
536
+
537
+ ruby-enterprise|ree)
538
+ rvm_ruby_interpreter="ruby-enterprise"
539
+ rvm_ruby_version=${rvm_ruby_version:-1.8.6}
540
+ rvm_ruby_patch_level="${3:-20090610}"
541
+
542
+ if [ "$rvm_ruby_version" != "1.8.6" ] ; then
543
+ rvm-log "fail" "Unknown Ruby Enterprise Edition version: $rvm_ruby_version"
544
+ fi
545
+ ;;
546
+
547
+ ruby)
548
+ if [ ! -z "$rvm_ruby_tag" ] ; then
549
+ rvm_ruby_version=$(echo $rvm_ruby_tag | sed 's/^v//' | sed 's/\///' | awk -F'_' '{print 1 "." $2 "." $3 }')
550
+ rvm_ruby_patch_level=$rvm_ruby_tag # $(echo $rvm_ruby_tag | sed 's/^v//' | sed 's/\///' | awk -F'_' '{print $4 }')
551
+ fi
552
+
553
+ rvm_ruby_version=${rvm_ruby_version:-1.8.6} # Default verison is 1.8.6
554
+ if [ "$rvm_ruby_version" = "1.9.1" ] ; then
555
+ rvm_ruby_patch_level="${rvm_ruby_patch_level:-p243}"
556
+
557
+ elif [ "$rvm_ruby_version" = "1.9.2" ] ; then
558
+ rvm_ruby_patch_level="${rvm_ruby_patch_level:-preview1}"
559
+
560
+ elif [ "$rvm_ruby_version" = "1.8.6" ] ; then
561
+ rvm_ruby_patch_level="${rvm_ruby_patch_level:-p369}"
562
+
563
+ elif [ "$rvm_ruby_version" = "1.8.7" ] ; then
564
+ rvm_ruby_patch_level="${rvm_ruby_patch_level:-p174}"
565
+
566
+ elif [ "$rvm_ruby_version" = "1.8.5" ] ; then
567
+ rvm_ruby_patch_level="${rvm_ruby_patch_level:-p115}"
568
+
569
+ elif [ "$rvm_ruby_version" = "1.8.0" -o "$rvm_ruby_version" = "1.8.1" -o "$rvm_ruby_version" = "1.8.2" -o "$rvm_ruby_version" = "1.8.3" -o "$rvm_ruby_version" = "1.8.4" ] ; then
570
+ unset rvm_ruby_patch_level
571
+
572
+ else
573
+ rvm-log "fail" "Unknown ruby version: $rvm_ruby_version"
574
+ fi
575
+ ;;
576
+
577
+ system|default)
578
+ unset rvm_ruby_interpreter rvm_ruby_version
579
+ rvm-cleanup-variables
580
+ if [ -e $rvm_install_path/current ] ; then
581
+ source $rvm_install_path/current
582
+ fi
583
+ ;;
584
+ *)
585
+ rvm-log "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known."
586
+ esac
587
+
588
+ if [ ! -z "$rvm_ruby_rev" ] ; then
589
+ if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then
590
+ rvm_ruby_patch_level="head"
591
+ else
592
+ rvm_ruby_patch_level="$rvm_ruby_rev"
593
+ fi
594
+ fi
595
+
596
+ if [ ! -z "$rvm_ruby_interpreter" -a ! -z "$rvm_ruby_version" ] ; then
597
+ rvm_major_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $2 }')
598
+ rvm_minor_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $3 }')
599
+
600
+ if [ -z "$rvm_gem_set_name" ] ; then
601
+ rvm_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version"
602
+ else
603
+ if [ ! -z "$rvm_gem_set_name_rm" -a -d $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name ] ; then
604
+ rm -rf $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name/
605
+ if [ "$rvm_gem_set_name_rm" = "$rvm_gem_set_name" ] ; then unset rvm_gem_set_name ; fi
606
+ else
607
+ rvm_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name"
608
+ fi
609
+ fi
610
+ mkdir -p $rvm_gem_home
611
+
612
+ if [ -z "$rvm_ruby_patch_level" ] ; then
613
+ rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version"}"
614
+ rvm_ruby_home="${rvm_ruby_home:-"$rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version"}"
615
+ else
616
+ rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}"
617
+ rvm_ruby_home="${rvm_ruby_home:-"$rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}"
618
+ fi
619
+ rvm_ruby_irbrc="$rvm_ruby_home/.irbrc"
620
+ rvm_ruby_binary="$rvm_ruby_home/bin/ruby"
621
+ rvm_selected=1
622
+ else
623
+ unset rvm_selected
624
+ fi
625
+
626
+ }
627
+
628
+ function rvm-use {
629
+
630
+ if [ -z "$rvm_selected" ] ; then rvm-select $* ; fi
631
+
632
+ if [ "$rvm_ruby_interpreter" = "default" -o "$rvm_ruby_interpreter" = "system" -o -z "$rvm_ruby_interpreter" ] ; then
633
+ unset GEM_HOME MY_RUBY_HOME IRBRC
634
+ rvm-cleanup-variables
635
+ PATH="$rvm_default_path" ; export PATH
636
+ if [ -e $rvm_install_path/current ] ; then
637
+ source $rvm_install_path/current
638
+ fi
639
+ else
640
+ GEM_HOME=$rvm_gem_home ; export GEM_HOME
641
+ MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME
642
+ IRBRC="$rvm_ruby_irbrc" ; export IRBRC
643
+
644
+ # Install if not installed
645
+ if [ ! -d $MY_RUBY_HOME ] ; then
646
+ rvm-log "warn" "$rvm_ruby_interpreter $rvm_ruby_version is not installed."
647
+ rvm-install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level
648
+ fi
649
+
650
+ if [ ! -s "$rvm_ruby_irbrc" ] ; then
651
+ rvm_irbrc_file=$(cat <<Config
652
+ @prompt = {
653
+ :PROMPT_I => "${rvm_ruby_package_name} > ", # default prompt
654
+ :PROMPT_S => "${rvm_ruby_package_name}%l> ", # known continuation
655
+ :PROMPT_C => "${rvm_ruby_package_name} > ",
656
+ :PROMPT_N => "${rvm_ruby_package_name} ?> ", # unknown continuation
657
+ :RETURN => " => %s \n",
658
+ :AUTO_INDENT => true
659
+ }
660
+ @prompt_mode = :DEFAULT
661
+ IRB.conf[:PROMPT][@prompt_mode] = @prompt
662
+ IRB.conf[:PROMPT_MODE] = @prompt_mode
663
+
664
+ require "irb/completion" rescue nil
665
+ Config
666
+ )
667
+ # TODO: Prepend users irbrc, keep custom path
668
+ echo "$rvm_irbrc_file" > $rvm_ruby_home/.irbrc
669
+ fi
670
+ PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_default_path ; export PATH
671
+
672
+ if [ ! -z "$PS1" ] ; then
673
+ PS1="\033[0;32m${rvm_ruby_package_name}\033[0m:: ${rvm_default_ps1}" ; export PS1
674
+ fi
675
+
676
+ if [ ! -z "$rvm_set_default" ] ; then
677
+ RUBY_VERSION="$($MY_RUBY_HOME/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')"
678
+ export GEM_HOME MY_RUBY_HOME RUBY_VERSION
679
+
680
+ echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_default_path ; export PATH" > $rvm_install_path/current
681
+
682
+ for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do
683
+ eval "export $variable"
684
+ eval value=\$${variable}
685
+ echo "${variable}='$value' ; export ${variable}" >> $rvm_install_path/current
686
+ done
687
+ fi
688
+ fi
689
+ }
690
+
691
+ function rvm-symlinks {
692
+
693
+ mkdir -p ${rvm_install_path}/bin
694
+ for release in `/bin/ls $rvm_install_path | grep 'ruby-'` ; do
695
+ for binary in ruby irb gem rdoc ri erb ; do
696
+ if [ -x $rvm_install_path/$release/bin/$binary ] ; then
697
+ ln -fs $rvm_install_path/$release/bin/$binary $rvm_install_path/bin/$binary-${release#ruby-}
698
+ fi
699
+ done
700
+ done
701
+
702
+ }
703
+
704
+ function rvm-list {
705
+
706
+ echo -e "\nruby:\n$(/bin/ls -l $rvm_install_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }')\n"
707
+ echo -e "jruby:\n$(/bin/ls -l $rvm_install_path/ | awk '/jruby-.*/ { print " - " $NF }')\n"
708
+ echo -e "ree:\n$(/bin/ls $rvm_install_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }')\n"
709
+ echo -e "system:\n - ($($default_system_ruby -v))\n"
710
+
711
+ }
712
+
713
+ function rvm-reset {
714
+
715
+ rvm-select "default"
716
+
717
+ PATH="$rvm_default_path" ; export PATH
718
+ for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do unset $variable ; done
719
+ rm -f $rvm_install_path/default*
720
+ rm -f $rvm_install_path/current
721
+
722
+ }
723
+
724
+ function rvm-gem-dir {
725
+
726
+ if [ -z "$rvm_selected" ] ; then rvm-select $* ; fi
727
+
728
+ mkdir -p $rvm_gem_home
729
+ echo $rvm_gem_home
730
+ }
731
+
732
+ function rvm-src-dir {
733
+
734
+ if [ -z "$rvm_selected" ] ; then rvm-select $* ; fi
735
+
736
+ if [ "$rvm_ruby_interpreter" -a "$rvm_ruby_version" ] ; then
737
+ rvm_ruby_source_dir="$rvm_source_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"
738
+ mkdir -p $rvm_ruby_source_dir
739
+ echo "$rvm_ruby_source_dir"
740
+ else
741
+ rvm-log "fail" "No source directory exists for the default implementation."
742
+ fi
743
+
744
+ }
745
+
746
+ # clones from source implementation/version to current
747
+ function rvm-gem-dup {
748
+
749
+ if [ "$1" = "default" ] ; then
750
+ rvm_source_gem_dir="$default_user_gem_path"
751
+ elif [ "$1" = "system" ] ; then
752
+ rvm_source_gem_dir="$default_system_gem_path"
753
+ else
754
+ rvm_source_gem_dir=${1:-$default_user_gem_path} # TODO: check for and remove trailing /gems
755
+ fi
756
+
757
+ if [ ! -z "$rvm_source_gem_dir" ] ; then
758
+ for rvm_gem_name_version in `/bin/ls $rvm_source_gem_dir/gems` ; do
759
+ rvm_gem_name=${rvm_gem_name_version%-*}
760
+ rvm_gem_version=${rvm_gem_name_version##*-}
761
+ if [ -d $GEM_HOME/gems/$rvm_gem_name_version ] ; then
762
+ echo "$rvm_gem_name_version already installed."
763
+ else
764
+ rvm-gi $rvm_source_gem_dir/cache/$rvm_gem_name-$rvm_gem_version.gem
765
+ fi
766
+ done
767
+ unset rvm_gem_name_version rvm_gem_name rvm_gem_version
768
+ else
769
+ rvm-log "fail" "Unknown $rvm_ruby_interpreter version: $rvm_ruby_version"
770
+ fi
771
+
772
+ }
773
+
774
+ function rvm-execute {
775
+ if [ -z "$rvm_selected" ] ; then rvm-select $* ; fi
776
+ $rvm_ruby_home/bin/ruby $rvm_ruby_args
777
+ }
778
+
779
+ function rvm-cache {
780
+ rvm_cache_file="$rvm_config_path/cache"
781
+ touch $rvm_cache_file
782
+ key="$1" ; shift
783
+
784
+ if [ -z "$key" ] ; then
785
+ rvm-log "fail" "rvm-cache must be called with at least one argument: rvm-cache key [value]"
786
+ else
787
+ if [ "$key" = "unset" -o "$key" = "delete" ] ; then
788
+ sed -i~ "s/^$2=.*$//" $rvm_cache_file
789
+ else
790
+ value="$*"
791
+ if [ -z "$value" ] ; then # get
792
+ grep "^$key=" $rvm_cache_file | awk -F'=' '{print $2}'
793
+ else # set
794
+ if [ -z "$(grep "^$key=" $rvm_cache_file)" ] ; then # append
795
+ echo "$key=$value" >> $rvm_cache_file
796
+ else # overwrite
797
+ sed -i~ "s/^$key=.*$/$key=$value/" $rvm_cache_file
798
+ fi
799
+ fi
800
+ fi
801
+ fi
802
+ }
803
+
804
+ function rvm-cleanup-variables {
805
+ unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_install_path rvm_debug rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message IRBRC rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_delete_flag rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_make_install rvm_config_path
806
+ }
807
+
808
+ function rvm-get-user-defaults {
809
+ # NOW load defaults settings. TODO: root user loads /etc/rvmrc
810
+ if [ -s ~/.rvmrc ] ; then source ~/.rvmrc ; fi
811
+ }
812
+
813
+ function rvm-parse-args {
814
+ while [ $# -gt 0 ] ; do
815
+ rvm_token="$1" ; shift
816
+ case "$rvm_token" in
817
+ install|uninstall|path|info|setup|version|srcdir|list|symlinks|reset|debug|reload|usage|help)
818
+ rvm_action=$rvm_token
819
+ ;;
820
+ use)
821
+ rvm_action=$rvm_token
822
+ if [ "$1" = "default" -o -z "$1" ] ; then
823
+ rvm_ruby_interpreter="system" ; shift
824
+ fi
825
+ ;;
826
+
827
+ ruby|jruby|ree|macruby|rubinius|default|all)
828
+ rvm_ruby_interpreter="$rvm_token"
829
+ rvm_action="${rvm_action:-use}"
830
+ ;;
831
+
832
+ gemdir)
833
+ rvm_action=$rvm_token
834
+
835
+ if [ "$1" = "system" ] ; then
836
+ rvm_ruby_interpreter="system" ; shift
837
+ fi
838
+
839
+ if [ "$1" = "user" ] ; then
840
+ rvm_ruby_interpreter="user" ; shift
841
+ fi
842
+
843
+ rvm_ruby_interpreter="${rvm_ruby_interpreter:-current}"
844
+ ;;
845
+
846
+ gemdup)
847
+ rvm_action=$rvm_token
848
+ if [ -z "$1" ] ; then
849
+ rvm_ruby_interpreter="default"
850
+ elif [ "$1" = "system" ] ; then
851
+ rvm_ruby_interpreter=$1 ; shift
852
+ elif [ "$1" = "default" ] ; then
853
+ rvm_ruby_interpreter=$1 ; shift
854
+ else
855
+ rvm_ruby_interpreter=$1 ; shift
856
+ rvm_ruby_version=$2 ; shift
857
+ fi
858
+ ;;
859
+
860
+ do|rubydo)
861
+ rvm_action=$rvm_token
862
+ temp=$(echo $1 | awk '{print substr($1, 0, 1)}')
863
+ if [ "$temp" != "-" ] ; then
864
+ if [ ! -z "$(echo $temp | grep '[0-9]')" ] ; then
865
+ rvm_ruby_version=$(echo "$1" | tr ',' ' ') ; shift
866
+ else
867
+ rvm_ruby_version=$1 ; shift
868
+ fi
869
+ else
870
+ unset rvm_ruby_version
871
+ fi
872
+ unset rvm_ruby_interpreter
873
+ ;;
874
+
875
+ 1.8|1.8.0|1.8.1|1.8.2|1.8.3|1.8.4|1.8.5|1.8.6|1.8.7|1.9|1.9.1|1.9.2)
876
+ rvm_ruby_interpreter="ruby"
877
+ rvm_ruby_version="$rvm_token"
878
+ rvm_action="${rvm_action:-use}"
879
+ ;;
880
+ 1.2.0|1.3.1)
881
+ rvm_ruby_interpreter="jruby"
882
+ rvm_ruby_version="$rvm_token"
883
+ rvm_action="${rvm_action:-use}"
884
+ ;;
885
+
886
+ -v|--version)
887
+ if [ -z "$1" ] ; then
888
+ rvm_action="version"
889
+ else
890
+ rvm_ruby_version="$1"
891
+ fi
892
+ shift
893
+ ;;
894
+
895
+ -t|--tag) rvm_ruby_tag="$1";
896
+ rvm_action="${rvm_action:-use}"
897
+ shift ;;
898
+ -r|--rev) rvm_ruby_rev="$1";
899
+ rvm_action="${rvm_action:-use}"
900
+ shift ;;
901
+ -b|--branch) rvm_ruby_rev="$1";
902
+ rvm_action="${rvm_action:-use}"
903
+ shift ;;
904
+
905
+
906
+ -P|--prefix) rvm_prefix_path="$1" ; shift ;;
907
+ -B|--bin) rvm_bin_path="$1" ; shift ;;
908
+ -S|--source) rvm_source_path="$1" ; shift ;;
909
+ -A|--archive) rvm_archives_path="$1" ; shift ;;
910
+ -G|--gems) rvm_gem_path="$1" ; shift ;;
911
+ -C|--configure) rvm_ruby_configure="$1" ; shift ;;
912
+ -M|--make) rvm_ruby_make="$1" ; shift ;;
913
+ -I|--make-install) rvm_ruby_make_install="$1" ; shift ;;
914
+ -l|--level) rvm_ruby_patch_level="$1" ; shift ;;
915
+ -n|--nice) rvm_niceness="$1" ; shift ;;
916
+ -f|--file) rvm_ruby_args="$1" ; shift ;;
917
+ -h|--help) rvm_action=help ; shift ;;
918
+ -d|--default) rvm_set_default=1 ;;
919
+ --debug) rvm_debug=1 ;;
920
+ -m|--gem-set) rvm_gem_set_name="$1" ; shift ;;
921
+ --rm-gem-set) rvm_gem_set_name_rm="$1" ; shift ;;
922
+
923
+ default|system)
924
+ rvm_action="use"
925
+ rvm_ruby_interpreter="system"
926
+ ;;
927
+ *)
928
+ rvm_action="error"
929
+ rvm_error_message="Unrecognized command line argument(s): '$rvm_token $*'"
930
+ break;
931
+ esac
932
+ if [ ! -z "$rvm_ruby_args" -o ! -z "$rvm_error_message" ] ; then break; fi
933
+ done
934
+
935
+ if [ ! -z "$rvm_error_message" ] ; then return 1 ; fi
936
+ if [ -z "$rvm_debug" ] ; then set +x ; else set -x ; fi
937
+
938
+ }
939
+
940
+ function rvm {
941
+
942
+ rvm-cleanup-variables
943
+ rvm-get-user-defaults
944
+ rvm-initialize
945
+ rvm-set-defaults
946
+ rvm-parse-args $*
947
+
948
+ case "$rvm_action" in
949
+ install)
950
+ if [ "$rvm_ruby_interpreter" = "all" ] ; then
951
+ for rvm_ruby_interpreter in ruby jruby ree ; do
952
+ if [ "$rvm_ruby_interpreter" = "ruby" ] ; then
953
+ for rvm_ruby_version in 1.8.6 1.8.7 1.9.1 1.9.2 ; do
954
+ rvm-install-ruby $rvm_ruby_interpreter $rvm_ruby_version
955
+ done
956
+ else
957
+ rvm-install-ruby $rvm_ruby_interpreter $rvm_ruby_version
958
+ fi
959
+ unset rvm_ruby_version
960
+ done
961
+ else
962
+ rvm-install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level
963
+ fi
964
+ ;;
965
+ uninstall) rvm-uninstall $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;;
966
+ use) rvm-use $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;;
967
+ list) rvm-list ;;
968
+ gemdir) rvm-gem-dir $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;;
969
+ srcdir) rvm-src-dir $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;;
970
+ gemdup) rvm-gem-dup $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;;
971
+ symlinks) rvm-symlinks ;;
972
+ version) rvm-version ;;
973
+ rubydo)
974
+ if [ ! -z "$rvm_ruby_version" ] ; then
975
+ rvm_ruby_versions=$(echo $rvm_ruby_version | tr ',' ' ')
976
+ for rvm_ruby_version in $rvm_ruby_versions ; do
977
+ temp=$(echo $rvm_ruby_version | awk '{print substr($1, 0, 1)}')
978
+ if [ ! -z "$(echo $temp | grep '[0-9]')" ] ; then
979
+ rvm_ruby_interpreter="ruby"
980
+ else
981
+ rvm_ruby_interpreter="$rvm_ruby_version"
982
+ unset rvm_ruby_version
983
+ fi
984
+ unset temp
985
+ rvm-select $rvm_ruby_interpreter $rvm_ruby_version
986
+
987
+ rvm_command="$rvm_ruby_binary $rvm_ruby_args"
988
+ echo "$(basename $rvm_ruby_binary):"
989
+ eval $rvm_command
990
+ unset rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_ruby_package_name rvm_ruby_home rvm_ruby_irbrc rvm_ruby_binary
991
+ done
992
+ else # all
993
+ rvm_ruby_versions=`/bin/ls $rvm_install_path/bin/ruby-*`
994
+ for rvm_ruby_binary in $rvm_ruby_versions ; do
995
+ if [ -x $rvm_ruby_binary ] ; then
996
+ rvm_command="$rvm_ruby_binary $rvm_ruby_args"
997
+ echo "$(basename $rvm_ruby_binary):"
998
+ eval $rvm_command
999
+ fi
1000
+ done
1001
+ fi
1002
+ ;;
1003
+ reset) rvm-reset ;;
1004
+ # TODO: how can we use bin_path here for reload, default file?
1005
+ reload) source ~/.rvm/scripts/rvm ;;
1006
+ error) rvm-log "fail" "$rvm_error_message ( see: rvm usage )" ; return 1; ;;
1007
+ info|debug)
1008
+ rvm-version
1009
+ cat <<-Info
1010
+
1011
+ ruby:
1012
+ interpreter: "$(ruby -v | awk '{print $1}')"
1013
+ version: "$(ruby -v | awk '{print $2}')"
1014
+ date: "$(ruby -v | sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/')"
1015
+ platform: "$(ruby -v | sed 's/^.*\[//' | sed 's/\].*$//')"
1016
+ patchlevel: "$(ruby -v | sed 's/^.*(//' | sed 's/).*$//')"
1017
+ full_version: "$(ruby -v)"
1018
+
1019
+ homes:
1020
+ gem: "${GEM_HOME:-'not set'}"
1021
+ ruby: "${MY_RUBY_HOME:-'not set'}"
1022
+
1023
+ binaries:
1024
+ ruby: "$(which ruby)"
1025
+ irb: "$(which irb)"
1026
+ gem: "$(which gem)"
1027
+
1028
+ environment:
1029
+ GEM_HOME: "$GEM_HOME"
1030
+ MY_RUBY_HOME: "$MY_RUBY_HOME"
1031
+ IRBRC: "$IRBRC"
1032
+ Info
1033
+
1034
+ if [ "$rvm_action" = "debug" ] ; then
1035
+ rvm-log "info" "PATH:$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')"
1036
+ for file in .bash_profile .bashrc .zshrc ; do
1037
+ if [ -s $file ] ; then
1038
+ rvm-log "debug" "~/$file:\n$(cat ~/$file | grep rvm)\n"
1039
+ fi
1040
+ done
1041
+ if [ -s $rvm_install_path/current ] ; then
1042
+ rvm-log "debug" "$rvm_install_path/current:\n$($rvm_install_path/current)\n"
1043
+ fi
1044
+ if [ -e $rvm_install_path/bin/rvm ] ; then
1045
+ rvm-log "debug" "rvm script in bin:\n$(ls -laht $rvm_install_path/bin/rvm)"
1046
+ fi
1047
+ fi
1048
+ return 0
1049
+ ;;
1050
+ usage|help) rvm-usage ;;
1051
+ *)
1052
+ if [ ! -z "$rvm_action" ] ; then
1053
+ rvm-log "fail" "unknown action '$rvm_action'"
1054
+ else
1055
+ rvm-usage
1056
+ fi
1057
+ return 1
1058
+ esac
1059
+
1060
+ if [ "$rvm_debug" = "1" ] ; then set +x ; unset rvm_debug ; fi
1061
+ }
1062
+
1063
+ if [ -f ~/.rvm/current ] ; then source ~/.rvm/current ; fi # magic :)
1064
+