rvm 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +62 -1
  2. data/bash/rvm +93 -47
  3. data/bash/rvm-install +6 -1
  4. metadata +1 -1
data/README CHANGED
@@ -1 +1,62 @@
1
- After installation simply run rvm usage for more information.
1
+
2
+ Usage:
3
+
4
+ rvm Action [Implementation] [Options]
5
+
6
+ Action:
7
+
8
+ * usage - Show this usage information
9
+ use - Switch to using a specific ruby versio (new login shell)
10
+ info - Show information for current ruby
11
+ gemdir - Switch to gem directory for installation (new login shell)
12
+ srcdir - Switch to src directory for the current ruby installation
13
+ gemdup - Clone source implementation version gems to currently used version
14
+ install - Install a ruby version, default is from source
15
+ debug - Emit environment and configuration information for debugging
16
+
17
+ Implementation:
18
+
19
+ * ruby - MRI/YARV Ruby (The Standard), defaults to 1.8.6
20
+ jruby - jRuby
21
+ ree - Ruby Enterprise Edition
22
+ rubinius - Rubinius (NIY)
23
+ default - Resets to the default system ruby
24
+ all - Used with install, installs all latest known versions
25
+
26
+ Options:
27
+
28
+ -v|--version - Ruby Package Version, defaults to 'latest'
29
+ -l|--level - Patch level for the specified Ruby version
30
+ -p|--prefix - Package and source directory prefix, with trailing slash!
31
+ Default is a users home directory and /usr/local/ for root
32
+ -c|--configure - Options for source compile (default: --enable-shared)
33
+ -d|--debug - Toggle debug mode on for extra messages (NIY)
34
+
35
+ Notes:
36
+
37
+ * Defaults above are denoted with a '*' prefix.
38
+ * rvm is intended to be run as an individual user (not root, yet)
39
+ * All ruby installation, configuration and source files are in ~/.rvm
40
+ * To manually reset to defaults: "rm -f ~/.rvm/current", then open new shell
41
+ * To preserve previous gem installations for a particular ruby version copy,
42
+ move, symlink or copy the old gem directory to (1.8 for 1.8.X):
43
+ ~/.gem/$interpreter/$version
44
+
45
+ Examples:
46
+
47
+ $ gem install rvm # Install the rvm gem
48
+ $ rvm-install # Install rvm, adds source hooks to ~/.bash_profile
49
+ $ rvm install jruby # Install jRuby, default 1.3.1
50
+ $ rvm use ruby -v 1.9.1 # Use Ruby 1.9, install first if not installed
51
+ $ rvm use -v 1.9 # Equivalent to above, because of defaults
52
+ $ rvm use default # Use the system default (as if no rvm)
53
+
54
+ TODO: (in order)
55
+
56
+ * Documentation
57
+ * Change gemdup to simply allow for a path to base gem dir to clone from
58
+ * rvm gemdir default
59
+ * Debug level messages
60
+ * Rubinius (not in first revisions)
61
+ * Shell detection instead of simply assuming bash (not in first revisions)
62
+
data/bash/rvm CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  rvm_author="Wayne E. Seguin"
4
- rvm_version="0.0.2"
4
+ rvm_version="0.0.3"
5
5
  rvm_updated="2009.08.23"
6
6
 
7
7
  #
@@ -25,6 +25,7 @@ function usage {
25
25
  use - Switch to using a specific ruby versio (new login shell)
26
26
  info - Show information for current ruby
27
27
  gemdir - Switch to gem directory for installation (new login shell)
28
+ srcdir - Switch to src directory for the current ruby installation
28
29
  gemdup - Clone source implementation version gems to currently used version
29
30
  install - Install a ruby version, default is from source
30
31
  debug - Emit environment and configuration information for debugging
@@ -44,6 +45,7 @@ function usage {
44
45
  -l|--level - Patch level for the specified Ruby version
45
46
  -p|--prefix - Package and source directory prefix, with trailing slash!
46
47
  Default is a users home directory and /usr/local/ for root
48
+ -c|--configure - Options for source compile (default: --enable-shared)
47
49
  -d|--debug - Toggle debug mode on for extra messages (NIY)
48
50
 
49
51
  Notes:
@@ -68,7 +70,8 @@ function usage {
68
70
  TODO: (in order)
69
71
 
70
72
  * Documentation
71
- * Change gemdir to simply allow for a path to base gem dir to clone from
73
+ * Change gemdup to simply allow for a path to base gem dir to clone from
74
+ * rvm gemdir default
72
75
  * Debug level messages
73
76
  * Rubinius (not in first revisions)
74
77
  * Shell detection instead of simply assuming bash (not in first revisions)
@@ -83,7 +86,7 @@ function debug { log "\e[4;34m <d> $*" ; }
83
86
  function info { log "\e[0;32m <i> $*" ; }
84
87
  function warn { log "\e[0;33m <w> $*" ; }
85
88
  function error { log "\e[0;31m <e> $*" ; }
86
- function fail { log "\e[0;31m <e> $*" ; }
89
+ function fail { log "\e[0;31m <e> $*" ; return 1 ; }
87
90
 
88
91
  function ruby-gi { gem install -q --no-rdoc --no-ri $* ; }
89
92
 
@@ -129,7 +132,7 @@ function ruby-install-source {
129
132
  if [ ! -f "$package_name.tar.gz" ] ; then $curl $url ; fi
130
133
  tar xzf $package_name.tar.gz && cd $package_name/
131
134
  fi
132
- ./configure --prefix=$install_path/$package_name --enable-shared && make && make install
135
+ ./configure --prefix=$install_path/$package_name ${configure-'--enable-shared'} && make && make install
133
136
  chmod +x $install_path/$package_name/bin/*
134
137
  popd
135
138
 
@@ -191,9 +194,6 @@ function ruby-install {
191
194
 
192
195
  ruby-gi rake
193
196
 
194
- MY_RUBY_HOME=ruby_home
195
- export ruby_home GEM_HOME PATH MY_RUBY_HOME
196
-
197
197
  }
198
198
 
199
199
  function ruby-use {
@@ -202,15 +202,15 @@ function ruby-use {
202
202
 
203
203
  default)
204
204
  rm -f ~/.rvm/current
205
- unset ruby_home
205
+ unset MY_RUBY_HOME
206
206
  unset GEM_HOME
207
207
  ;;
208
- #leopard) ruby_home="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr"; GEM_HOME="$HOME/.gem/ruby/1.8" ;;
208
+ #leopard) MY_RUBY_HOME="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr"; GEM_HOME="$HOME/.gem/ruby/1.8" ;;
209
209
 
210
210
  jruby)
211
211
  version="${version-1.3.1}"
212
212
  if [ "$version" = "1.2.0" -o "$version" = "1.3.1" ] ; then
213
- ruby_home="$install_path/jruby-$version"
213
+ MY_RUBY_HOME="$install_path/jruby-$version"
214
214
  GEM_HOME="$HOME/.gem/jruby/1.8"
215
215
  alias ruby_ng="jruby --ng"
216
216
  alias ruby_ng_server="jruby --ng-server"
@@ -223,7 +223,7 @@ function ruby-use {
223
223
  version=${version-1.8.6}
224
224
  if [ "$version" = "1.8.6" ] ; then
225
225
  patchlevel="${3-20090610}"
226
- ruby_home="$install_path/ruby-enterprise-$version-$patchlevel"
226
+ MY_RUBY_HOME="$install_path/ruby-enterprise-$version-$patchlevel"
227
227
  GEM_HOME="$HOME/.gem/ruby-enterprise/1.8"
228
228
  else
229
229
  fail "Unknown Ruby Enterprise Edition version: $version"
@@ -233,15 +233,15 @@ function ruby-use {
233
233
  ruby)
234
234
  if [ "$version" = "1.8.6" ] ; then
235
235
  patchlevel="${patchlevel-369}"
236
- ruby_home="$install_path/ruby-1.8.6-p$patchlevel"
236
+ MY_RUBY_HOME="$install_path/ruby-1.8.6-p$patchlevel"
237
237
  GEM_HOME="$HOME/.gem/ruby/1.8"
238
238
  elif [ "$version" = "1.8.7" ] ; then
239
239
  patchlevel="${patchlevel-174}"
240
- ruby_home="$install_path/ruby-1.8.7-p$patchlevel"
240
+ MY_RUBY_HOME="$install_path/ruby-1.8.7-p$patchlevel"
241
241
  GEM_HOME="$HOME/.gem/ruby/1.8"
242
242
  elif [ "$version" = "1.9.1" -o "$version" = "1.9" ] ; then
243
243
  patchlevel="${patchlevel-243}"
244
- ruby_home="$install_path/ruby-1.9.1-p$patchlevel"
244
+ MY_RUBY_HOME="$install_path/ruby-1.9.1-p$patchlevel"
245
245
  GEM_HOME="$HOME/.gem/ruby/1.9.1"
246
246
  else
247
247
  fail "Unknown ruby version: $version"
@@ -254,18 +254,17 @@ function ruby-use {
254
254
  esac
255
255
 
256
256
  if [ ! "$implementation" = "default" ] ; then
257
- MY_RUBY_HOME=$ruby_home
258
- RUBY_VERSION="$($ruby_home/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')"
259
- export GEM_HOME ruby_home MY_RUBY_HOME RUBY_VERSION
257
+ RUBY_VERSION="$($MY_RUBY_HOME/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')"
258
+ export GEM_HOME MY_RUBY_HOME RUBY_VERSION
260
259
 
261
- if [ ! -d $ruby_home ] ; then
260
+ if [ ! -d $MY_RUBY_HOME ] ; then
262
261
  warn "$implementation $version is not installed, installing."
263
262
  ruby-install $implementation $version $patchlevel
264
263
  fi
265
264
 
266
265
  # Setup ~/.rvm/current
267
- echo "PATH=$ruby_home/bin:$GEM_HOME/bin:\$PATH ; export PATH" > ~/.rvm/current
268
- for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ruby_home ; do
266
+ echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:\$PATH ; export PATH" > ~/.rvm/current
267
+ for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do
269
268
  eval "export $variable"
270
269
  eval value=\$${variable}
271
270
  echo "${variable}='$value' ; export ${variable}" >> ~/.rvm/current
@@ -285,7 +284,7 @@ function ruby-gem-dir {
285
284
  jruby) GEM_HOME="$HOME/.gem/jruby/1.8" ;;
286
285
  ree) GEM_HOME="$HOME/.gem/ruby-enterprise/1.8" ;;
287
286
  ruby)
288
- if [ "$version" = "1.8.6" ] ; then
287
+ if [ "$version" = "1.8.6" -o "$version" = "1.8" ] ; then
289
288
  GEM_HOME="$HOME/.gem/ruby/1.8"
290
289
  elif [ "$version" = "1.8.7" ] ; then
291
290
  GEM_HOME="$HOME/.gem/ruby/1.8"
@@ -298,39 +297,77 @@ function ruby-gem-dir {
298
297
  *)
299
298
  fail "Ruby implementation '$implementation' is not known."
300
299
  esac
301
- cd $GEM_HOME
300
+
301
+ if [ -d $GEM_HOME ] ; then
302
+ cd $GEM_HOME
303
+ else
304
+ fail "$implementation $version GEM directory does not exist."
305
+ fi
302
306
 
303
307
  }
304
308
 
305
- # clones from source implementation/version to current
306
- function ruby-gem-dup {
309
+ function ruby-src-dir {
310
+ case "$implementation" in
307
311
 
308
- source_implementation=${1-ruby}
309
- source_version=${2-1.8.6}
312
+ jruby)
313
+ version="${version-1.3.1}"
314
+ if [ "$version" = "1.2.0" -o "$version" = "1.3.1" ] ; then
315
+ src_dir="$source_path/$implementation-$version"
316
+ else
317
+ fail "Unknown jRuby version: $version"
318
+ fi
319
+ ;;
320
+
321
+ ree)
322
+ version=${version-1.8.6}
323
+ if [ "$version" = "1.8.6" ] ; then
324
+ patchlevel="${3-20090610}"
325
+ src_dir="$source_path/ruby-enterprise-$version-$patchlevel"
326
+ else
327
+ fail "Unknown Ruby Enterprise Edition version: $version"
328
+ fi
329
+ ;;
310
330
 
311
- # TODO: use ruby-gem-dir for this once it has stabilized
312
- case "$source_implementation" in
313
- jruby) gemdir="$HOME/.gem/jruby/1.8" ;;
314
- ree) gemdir="$HOME/.gem/ruby-enterprise/1.8" ;;
315
331
  ruby)
316
- if [ "$source_version" = "1.8.6" ] ; then
317
- gemdir="$HOME/.gem/ruby/1.8"
318
- elif [ "$source_version" = "1.8.7" ] ; then
319
- gemdir="$HOME/.gem/ruby/1.8"
320
- elif [ "$source_version" = "1.9.1" -o "$version" = "1.9" ] ; then
321
- gemdir="$HOME/.gem/ruby/1.9.1"
332
+ if [ "$version" = "1.8.6" -o "$version" = "1.8" ] ; then
333
+ patchlevel="${patchlevel-369}"
334
+ src_dir="$source_path/ruby-1.8.6-p$patchlevel"
335
+ elif [ "$version" = "1.8.7" ] ; then
336
+ patchlevel="${patchlevel-174}"
337
+ src_dir="$source_path/ruby-1.8.7-p$patchlevel"
338
+ elif [ "$version" = "1.9.1" -o "$version" = "1.9" ] ; then
339
+ patchlevel="${patchlevel-243}"
340
+ src_dir="$source_path/ruby-1.9.1-p$patchlevel"
341
+ else
342
+ fail "Unknown ruby version: $version"
322
343
  fi
323
344
  ;;
345
+
346
+ *)
347
+ fail "Ruby implementation '$implementation' is not known."
348
+ return 1
324
349
  esac
325
350
 
326
- if [ ! -z "$gemdir" ] ; then
327
- for gem_name_version in `ls $gemdir/gems` ; do
351
+ if [ -d $src_dir ] ; then
352
+ cd $src_dir
353
+ else
354
+ fail "$implementation $version source directory does not exist."
355
+ fi
356
+
357
+ }
358
+
359
+ # clones from source implementation/version to current
360
+ function ruby-gem-dup {
361
+
362
+ gem_dir=$1 # TODO: check for and remove trailing /gems
363
+ if [ ! -z "$gem_dir" ] ; then
364
+ for gem_name_version in `ls $gem_dir/gems` ; do
328
365
  gem_name=${gem_name_version%-*}
329
366
  gem_version=${gem_name_version##*-}
330
367
  if [ -d $GEM_HOME/gems/$gem_name_version ] ; then
331
368
  echo "$gem_name_version already installed."
332
369
  else
333
- ruby-gi $gemdir/cache/$gem_name-$gem_version.gem
370
+ ruby-gi $gem_dir/cache/$gem_name-$gem_version.gem
334
371
  fi
335
372
  done
336
373
  else
@@ -343,16 +380,24 @@ function rvm-version { info "rvm $rvm_version" ; }
343
380
 
344
381
  function rvm {
345
382
 
383
+ # Cleanup, aisle 3
384
+ for variable in action implementation patchlevel version source_path install_path manager debug prefix_path ; do
385
+ eval "unset $variable"
386
+ done
346
387
  while [ $# -gt 0 ] ; do
347
- arg="$1" ; shift
348
- case "$arg" in
349
- install|use|path|info|gemdir|gemdup|setup|version|debug)
350
- action=$arg ;;
388
+ token="$1" ; shift
389
+ case "$token" in
390
+ install|use|path|info|gemdir|gemdup|setup|version|debug|srcdir)
391
+ action=$token ;;
351
392
  ruby|jruby|ree|default|all)
352
- implementation="$arg" ;;
393
+ implementation="$token" ;;
394
+ 1.8|1.9|1.8.6|1.8.7|1.9.1|1.2.0|1.3.1)
395
+ version="$token" ;;
353
396
  -v|--version) version="$1" ; shift ;;
354
397
  -l|--level) patchlevel="$1" ; shift ;;
355
398
  -p|--prefix) install_path="$1" ; shift ;;
399
+ -s|--source) source_path="$1" ; shift ;; # Undocumented / untested "feature"
400
+ -c|--configure) configure="$1" ; shift ;;
356
401
  -m|--manager) manager="$1" ; shift ;;
357
402
  -d|--debug) debug=true ;;
358
403
  *) usage ; return 1
@@ -362,14 +407,14 @@ function rvm {
362
407
  curl="curl -O -L -s "
363
408
  implementation=${implementation-'ruby'}
364
409
  username=`whoami`
410
+
411
+ # TODO: Sanitize user input, ensure that there is a / a the end...
365
412
  if [ "$username" = "root" ] ; then
366
413
  prefix_path=${prefix-/usr/local/}
367
414
  else
368
415
  prefix_path=${prefix-$HOME/.}
369
416
  fi
370
-
371
- # TODO: Sanitize user input, ensure that there is a / a the end...
372
- source_path="${prefix_path}rvm/src"
417
+ source_path="${source_path-${prefix_path}rvm/src}"
373
418
  install_path="${prefix_path}rvm"
374
419
 
375
420
  mkdir -p $source_path $install_path
@@ -398,6 +443,7 @@ function rvm {
398
443
  ;;
399
444
  use) ruby-use $implementation $version $patchlevel ;;
400
445
  gemdir) ruby-gem-dir $implementation $version $patchlevel ;;
446
+ srcdir) ruby-src-dir $implementation $version $patchlevel ;;
401
447
  gemdup) ruby-gem-dup $implementation $version $patchlevel ;;
402
448
  info) ruby-info $implementation $version $patchlevel ;;
403
449
  version) rvm-version ;;
@@ -17,5 +17,10 @@ if [ -z "`grep '\.rvm/current' ~/.bash_profile`" ] ; then
17
17
  echo "if [ -f ~/.rvm/current ] ; then source ~/.rvm/current ; fi" >> ~/.bash_profile
18
18
  fi
19
19
 
20
- source ~/.bash_profile
20
+ if [ -z "`grep '\.profile' ~/.bash_profile`" ] ; then
21
+ echo "Adding 'source ~/.profile' to the end of ~/.bash_profile."
22
+ echo "if [ -f ~/.profile ] ; then source ~/.profile ; fi" >> ~/.bash_profile
23
+ fi
24
+
25
+ source ~/.rvm/bin/rvm
21
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne E. Seguin