rvm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/INSTALL +1 -0
  2. data/README +1 -0
  3. data/bash/rvm +426 -0
  4. data/bash/rvm-install +21 -0
  5. data/bin/rvm-install +5 -0
  6. metadata +59 -0
data/INSTALL ADDED
@@ -0,0 +1 @@
1
+ From the *project directory* run bin/rvm-install
data/README ADDED
@@ -0,0 +1 @@
1
+ After installation simply run rvm usage for more information.
@@ -0,0 +1,426 @@
1
+ #!/bin/bash
2
+
3
+ rvm_author="Wayne E. Seguin"
4
+ rvm_version="0.0.1"
5
+ rvm_updated="2009.08.23"
6
+
7
+ #
8
+ # License: See LICENSE
9
+ #
10
+
11
+ #
12
+ # Functions
13
+ #
14
+ function usage {
15
+
16
+ cat <<-Usage
17
+
18
+ Usage:
19
+
20
+ $0 Action [Implementation] [Options]
21
+
22
+ Action:
23
+
24
+ install - Install a ruby version, default is from source
25
+ use - Switch to using a specific ruby versio (new login shell)
26
+ path - Set path for current ruby
27
+ info - Show information for current ruby
28
+ gemdir - Switch to gem directory for installation (new login shell)
29
+ gemdup - Clone source implementation version gems to currently used version
30
+ setup - Place rvm to in default path (~/.bin/ && .profile)
31
+ * usage - Show this usage information
32
+
33
+ Implementation:
34
+
35
+ * ruby - MRI/YARV Ruby (The Standard)
36
+ jruby - jRuby
37
+ ree - Ruby Enterprise Edition
38
+ rubinius - Rubinius (NI)
39
+ leopard - Leopard's system Ruby ( Mac OS X only )
40
+ default - Resets to the default system ruby
41
+
42
+ Options:
43
+
44
+ -v|--version - Ruby Package Version, defaults to 'latest'
45
+ -l|--level - Patch level for the specified Ruby version
46
+ -p|--prefix - Package and source directory prefix, with trailing slash!
47
+ Default is a users home directory and /usr/local/ for root
48
+ -m|--manager - Package Manager to use, one of:
49
+ {port,aptitude,apt-get,emerge,yum,pacman}
50
+ -d|--debug - Toggle debug mode on
51
+
52
+ Notes:
53
+
54
+ * Defaults are denoted with a * prefix.
55
+
56
+ TODO: (in order)
57
+
58
+ * Rubinius (not in first revisions)
59
+ * Shell detection instead of simply assuming bash (not in first revisions)
60
+
61
+ Usage
62
+
63
+ }
64
+
65
+ # Logging functions based on level
66
+ function log { echo -e "\n $* \e[0m\n" ; }
67
+ function debug { log "\e[4;34m <d> $*" ; }
68
+ function info { log "\e[0;32m <i> $*" ; }
69
+ function warn { log "\e[0;33m <w> $*" ; }
70
+ function error { log "\e[0;31m <e> $*" ; }
71
+ function fail { log "\e[0;31m <e> $*" ; }
72
+
73
+ function ruby-gi { gem install -q --no-rdoc --no-ri $* ; }
74
+
75
+ function ruby-info {
76
+
77
+ full_version=$(ruby -v)
78
+ ruby_implementation=$(echo "$full_version" | awk '{print $1}')
79
+ ruby_version=$(echo "$full_version" | awk '{print $2}')
80
+ ruby_patchlevel=$(echo "$full_version" | sed 's/^.*(//' | sed 's/).*$//')
81
+ ruby_date=$(echo "$full_version" | sed 's/^.*(\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\).*$/\1/')
82
+ ruby_platform=$(echo "$full_version" | sed 's/^.*\[//' | sed 's/\].*$//')
83
+
84
+ cat <<-Info
85
+ ruby:
86
+ implementation: "$ruby_implementation"
87
+ version: "$ruby_version"
88
+ date: "$ruby_date"
89
+ platform: "$ruby_platform"
90
+ patchlevel: "$ruby_patchlevel"
91
+ gem_home: "${GEM_HOME-not set}"
92
+ ruby_home: "${ruby_home-not set}"
93
+ full_version: "$full_version"
94
+ Info
95
+
96
+ }
97
+
98
+ function ruby-install-source {
99
+
100
+ case "${version-$1}" in
101
+ 1.9|1.9.1) major="1.9" ; minor="1" ; patchlevel="${2-243}" ;;
102
+ 1.8|1.8.6) major="1.8" ; minor="6" ; patchlevel="${2-369}" ;;
103
+ 1.8.7) major="1.8" ; minor="7" ; patchlevel="${2-174}" ;;
104
+ *) fail "Ruby version '$version' is unknown."
105
+ esac
106
+
107
+ package_name="ruby-$major.$minor-p$patchlevel"
108
+ url="ftp://ftp.ruby-lang.org/pub/ruby/$major/$package_name.tar.gz"
109
+
110
+ pushd $source_path
111
+ if [ -d $package_name ] ; then
112
+ cd $package_name
113
+ else
114
+ if [ ! -f "$package_name.tar.gz" ] ; then $curl $url ; fi
115
+ tar xzf $package_name.tar.gz && cd $package_name/
116
+ fi
117
+ ./configure --prefix=$install_path/$package_name --enable-shared && make && make install
118
+ chmod +x $install_path/$package_name/bin/*
119
+ popd
120
+
121
+ }
122
+
123
+ function ruby-install {
124
+
125
+ case "$implementation" in
126
+ leopard) # no-op
127
+ system_type=`uname`
128
+ if [ "$system_type" = "Darwin" ] ; then
129
+ echo "Leopard ruby is not installable via rvm."
130
+ else
131
+ fail "leopard ruby is the default ruby installed on Mac OS X (Darwin), you are on: $system_type"
132
+ fi
133
+ ;;
134
+
135
+ ree)
136
+ version=${version-1.8.6}
137
+ patchlevel=${patchlevel-20090610}
138
+ package_name="ruby-enterprise-$version-$patchlevel"
139
+ url="http://rubyforge.org/frs/download.php/58677/$package_name.tar.gz"
140
+ pushd $source_path
141
+ if [ -d $package_name ] ; then
142
+ cd $package_name
143
+ else
144
+ if [ ! -f "$package_name.tar.gz" ] ; then $curl $url ; fi
145
+ tar xzf $package_name.tar.gz && cd $package_name/
146
+ fi
147
+ cd ruby-enterprise-$version-$patchlevel && ./installer -a $install_path/ruby-enterprise-$version-$patchlevel --dont-install-useful-gems
148
+ popd
149
+ chmod +x $install_path/$package_name/bin/*
150
+ ;;
151
+
152
+ jruby)
153
+ version=${version-1.3.1} # 1.2.0, 1.3.1
154
+ patchlevel="" # No patchlevel for jRuby
155
+ package_name="$implementation-bin-$version"
156
+ package_dir="$implementation-$version"
157
+ url="http://dist.codehaus.org/$implementation/$version/$package_name.zip"
158
+ pushd $source_path
159
+ if [ -d $package_name ] ; then
160
+ cd $package_name
161
+ else
162
+ if [ ! -f "$package_name.zip" ] ; then $curl $url ; fi
163
+ jar xf $package_name.zip && cd $package_name/
164
+ fi
165
+ mkdir -p $install_path/$package_dir/bin/
166
+ for binary in jruby jgem jirb ; do
167
+ ln -sf $source_path/$package_dir/bin/$binary $source_path/$package_dir/bin/${binary#j}
168
+ done
169
+ rsync -ag $source_path/$package_dir/ $install_path/$package_dir/
170
+ cd $source_path/$package_dir/tool/nailgun && make
171
+ popd
172
+ chmod +x $install_path/$package_dir/bin/*
173
+ ruby-gi jruby-openssl
174
+ ;;
175
+
176
+ ruby)
177
+ version=${version-1.8.6}
178
+ ruby-install-source $version ${patchlevel-$3}
179
+ ;;
180
+
181
+ *) fail "Ruby implementation '$implementation' is not known."
182
+
183
+ esac
184
+
185
+ ruby-gi rake
186
+
187
+ MY_RUBY_HOME=ruby_home
188
+ export ruby_home GEM_HOME PATH MY_RUBY_HOME
189
+
190
+ }
191
+
192
+ function ruby-use {
193
+
194
+ case "$implementation" in
195
+
196
+ default)
197
+ rm -f ~/.rvm/current
198
+ unset ruby_home
199
+ unset GEM_HOME
200
+ ;;
201
+
202
+ leopard)
203
+ ruby_home="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr"
204
+ GEM_HOME="$HOME/.gem/ruby/1.8"
205
+ ;;
206
+
207
+ jruby)
208
+ version="${version-1.3.1}"
209
+ if [ "$version" = "1.2.0" -o "$version" = "1.3.1" ] ; then
210
+ ruby_home="$install_path/jruby-$version"
211
+ GEM_HOME="$HOME/.gem/jruby/1.8"
212
+ alias ruby_ng="jruby --ng"
213
+ alias ruby_ng_server="jruby --ng-server"
214
+ else
215
+ fail "Unknown jRuby version: $version"
216
+ fi
217
+ ;;
218
+
219
+ ree)
220
+ version=${version-1.8.6}
221
+ if [ "$version" = "1.8.6" ] ; then
222
+ patchlevel="${3-20090610}"
223
+ ruby_home="$install_path/ruby-enterprise-$version-$patchlevel"
224
+ GEM_HOME="$HOME/.gem/ruby-enterprise/1.8"
225
+ else
226
+ fail "Unknown Ruby Enterprise Edition version: $version"
227
+ fi
228
+ ;;
229
+
230
+ ruby)
231
+ if [ "$version" = "1.8.6" ] ; then
232
+ patchlevel="${patchlevel-369}"
233
+ ruby_home="$install_path/ruby-1.8.6-p$patchlevel"
234
+ GEM_HOME="$HOME/.gem/ruby/1.8"
235
+ elif [ "$version" = "1.8.7" ] ; then
236
+ patchlevel="${patchlevel-174}"
237
+ ruby_home="$install_path/ruby-1.8.7-p$patchlevel"
238
+ GEM_HOME="$HOME/.gem/ruby/1.8"
239
+ elif [ "$version" = "1.9.1" -o "$version" = "1.9" ] ; then
240
+ patchlevel="${patchlevel-243}"
241
+ ruby_home="$install_path/ruby-1.9.1-p$patchlevel"
242
+ GEM_HOME="$HOME/.gem/ruby/1.9.1"
243
+ else
244
+ fail "Unknown ruby version: $version"
245
+ fi
246
+ ;;
247
+
248
+ *)
249
+ fail "Ruby implementation '$implementation' is not known."
250
+
251
+ esac
252
+
253
+ if [ ! "$implementation" = "default" ] ; then
254
+ MY_RUBY_HOME=$ruby_home
255
+ RUBY_VERSION="$($ruby_home/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')"
256
+ export GEM_HOME ruby_home MY_RUBY_HOME RUBY_VERSION
257
+
258
+ if [ ! -d $ruby_home ] ; then
259
+ warn "$implementation $version is not installed, installing."
260
+ ruby-install $implementation $version $patchlevel
261
+ fi
262
+
263
+ # Setup ~/.rvm/current
264
+ echo "PATH=$ruby_home/bin:$GEM_HOME/bin:\$PATH ; export PATH" > ~/.rvm/current
265
+ for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ruby_home ; do
266
+ eval "export $variable"
267
+ eval value=\$${variable}
268
+ echo "${variable}='$value' ; export ${variable}" >> ~/.rvm/current
269
+ done
270
+ else
271
+ PATH=$original_path ; export PATH
272
+ fi
273
+
274
+ info "Switching to $implementation $version $patchlevel ..."
275
+ exec bash --login
276
+
277
+ }
278
+
279
+ function ruby-gem-dir {
280
+
281
+ case "$implementation" in
282
+ leopard) GEM_HOME="$HOME/.gem/ruby/1.8" ;;
283
+ jruby) GEM_HOME="$HOME/.gem/jruby/1.8" ;;
284
+ ree) GEM_HOME="$HOME/.gem/ruby-enterprise/1.8" ;;
285
+ ruby)
286
+ if [ "$version" = "1.8.6" ] ; then
287
+ GEM_HOME="$HOME/.gem/ruby/1.8"
288
+ elif [ "$version" = "1.8.7" ] ; then
289
+ GEM_HOME="$HOME/.gem/ruby/1.8"
290
+ elif [ "$version" = "1.9.1" -o "$version" = "1.9" ] ; then
291
+ GEM_HOME="$HOME/.gem/ruby/1.9.1"
292
+ else
293
+ fail "Unknown ruby version: $version"
294
+ fi
295
+ ;;
296
+ *)
297
+ fail "Ruby implementation '$implementation' is not known."
298
+ esac
299
+ cd $GEM_HOME
300
+
301
+ }
302
+
303
+ # clones from source implementation/version to current
304
+ function ruby-gem-dup {
305
+
306
+ source_implementation=${1-ruby}
307
+ source_version=${2-1.8.6}
308
+
309
+ # TODO: use ruby-gem-dir for this once it has stabilized
310
+ case "$source_implementation" in
311
+ leopard) gemdir="$HOME/.gem/ruby/1.8" ;;
312
+ jruby) gemdir="$HOME/.gem/jruby/1.8" ;;
313
+ ree) gemdir="$HOME/.gem/ruby-enterprise/1.8" ;;
314
+ ruby)
315
+ if [ "$source_version" = "1.8.6" ] ; then
316
+ gemdir="$HOME/.gem/ruby/1.8"
317
+ elif [ "$source_version" = "1.8.7" ] ; then
318
+ gemdir="$HOME/.gem/ruby/1.8"
319
+ elif [ "$source_version" = "1.9.1" -o "$version" = "1.9" ] ; then
320
+ gemdir="$HOME/.gem/ruby/1.9.1"
321
+ fi
322
+ ;;
323
+ esac
324
+
325
+ if [ ! -z "$gemdir" ] ; then
326
+ for gem_name_version in `ls $gemdir/gems` ; do
327
+ gem_name=${gem_name_version%-*}
328
+ gem_version=${gem_name_version##*-}
329
+ if [ -d $GEM_HOME/gems/$gem_name_version ] ; then
330
+ echo "$gem_name_version already installed."
331
+ else
332
+ ruby-gi $gemdir/cache/$gem_name-$gem_version.gem
333
+ fi
334
+ done
335
+ else
336
+ fail "Unknown $implementation version: $version"
337
+ fi
338
+
339
+ }
340
+
341
+ function rvm-setup {
342
+
343
+ rm -f ~/.bin/rvm
344
+ bindir=$(dirname `which rvm`)
345
+ gemsdir="$(dirname $bindir)/gems"
346
+ cd $gemsdir/`ls -t ~/.gem/ruby/1.8/gems | grep rvm | head -n 1`
347
+ bash/rvm-setup
348
+
349
+ info "~/.bin/rvm is symlinked to the gem's rvm script and ~/.bin is in your path.\n" \
350
+ "You may now use rvm via the command line the next time you open a terminal shell."
351
+
352
+ }
353
+
354
+ function rvm-version {
355
+
356
+ info "rvm $rvm_version"
357
+
358
+ }
359
+
360
+ function rvm {
361
+
362
+ while [ $# -gt 0 ] ; do
363
+ arg="$1" ; shift
364
+ case "$arg" in
365
+ install|use|path|info|gemdir|gemdup|setup|version)
366
+ action=$arg ;;
367
+ ruby|jruby|ree|leopard|default)
368
+ implementation="$arg" ;;
369
+ -v|--version) version="$1" ; shift ;;
370
+ -l|--level) patchlevel="$1" ; shift ;;
371
+ -p|--prefix) install_path="$1" ; shift ;;
372
+ -m|--manager) manager="$1" ; shift ;;
373
+ -d|--debug) debug=true ;;
374
+ *) usage
375
+ esac
376
+ done
377
+
378
+ curl="curl -O -L -s "
379
+ implementation=${implementation-'ruby'}
380
+ username=`whoami`
381
+ if [ "$username" = "root" ] ; then
382
+ prefix_path=${prefix-/usr/local/}
383
+ else
384
+ prefix_path=${prefix-$HOME/.}
385
+ fi
386
+
387
+ # TODO: Sanitize user input, ensure that there is a / a the end...
388
+ source_path="${prefix_path}rvm/src"
389
+ install_path="${prefix_path}rvm"
390
+
391
+ mkdir -p $source_path $install_path
392
+
393
+ original_path=`cat $install_path/.original_path`
394
+ if [ -z "$original_path" ] ; then
395
+ echo $PATH > $install_path/.original_path
396
+ original_path=$PATH
397
+ fi
398
+
399
+ case "$action" in
400
+ install)
401
+ if [ "$implementation" = "all" ] ; then
402
+ for implementation in ruby jruby ree ; do
403
+ if [ "$implementation" = "ruby" ] ; then
404
+ for versions in 1.8.6 1.8.7 1.9.1 ; do
405
+ ruby-install
406
+ done
407
+ else
408
+ ruby-install
409
+ fi
410
+ done
411
+ else
412
+ ruby-install $implementation $version $patchlevel
413
+ fi
414
+ ;;
415
+ use) ruby-use $implementation $version $patchlevel ;;
416
+ gemdir) ruby-gem-dir $implementation $version $patchlevel ;;
417
+ gemdup) ruby-gem-dup $implementation $version $patchlevel ;;
418
+ path) ruby-path $implementation $version $patchlevel ;;
419
+ info) ruby-info $implementation $version $patchlevel ;;
420
+ version) rvm-version ;;
421
+ setup) rvm-setup ;;
422
+ *) usage ; fail "unknown action '$action'"
423
+ esac
424
+
425
+ }
426
+
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+
3
+ mkdir -p ~/.rvm/src ~/.rvm/bin
4
+
5
+ cwd=`pwd`
6
+ cp $cwd/bash/rvm ~/.rvm/bin/
7
+
8
+ touch ~/.bash_profile
9
+
10
+ if [ -z "`grep '\.rvm/bin/rvm' ~/.bash_profile`" ] ; then
11
+ echo "Adding 'source ~/.rvm' to your ~/.bash_profile."
12
+ echo "source ~/.rvm/bin/rvm" >> ~/.bash_profile
13
+ fi
14
+
15
+ if [ -z "`grep '\.rvm/current' ~/.bash_profile`" ] ; then
16
+ echo "Adding 'source ~/.rvm/current' ~/.bash_profile."
17
+ echo "if [ -f ~/.rvm/current ] ; then source ~/.rvm/current ; fi" >> ~/.bash_profile
18
+ fi
19
+
20
+ source ~/.bash_profile
21
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Hot potato!!! Bash it!
4
+ exec "bash -c 'cd #{File.dirname(File.dirname(__FILE__))} && ./bash/rvm-install #{ARGV.join(' ')}'"
5
+
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rvm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Wayne E. Seguin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-23 00:00:00 -04:00
13
+ default_executable: rvm-install
14
+ dependencies: []
15
+
16
+ description: Manages Ruby interpreter installations and switching between them.
17
+ email: wayneeseguin@gmail.com
18
+ executables:
19
+ - rvm-install
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ files:
25
+ - INSTALL
26
+ - README
27
+ - bash/rvm
28
+ - bash/rvm-install
29
+ has_rdoc: true
30
+ homepage: http://github.com/wayneeseguin/rvm
31
+ licenses: []
32
+
33
+ post_install_message:
34
+ rdoc_options:
35
+ - --inline-source
36
+ - --charset=UTF-8
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project: dynamicreports
54
+ rubygems_version: 1.3.4
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Ruby Version Manager (rvm)
58
+ test_files: []
59
+