wayneeseguin-rvm 0.0.31 → 0.0.35

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,188 @@
1
+ #!/bin/bash
2
+
3
+ # __rvm_select implementation version patch_level
4
+ function __rvm_select {
5
+
6
+ rvm_ruby_interpreter="${1:-$rvm_ruby_interpreter}"
7
+ rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}" # Default is standard ruby
8
+
9
+ if [ "$rvm_ruby_version" = "1.8" ] ; then rvm_ruby_version="1.8.6" ; fi
10
+ if [ "$rvm_ruby_version" = "1.9" ] ; then rvm_ruby_version="1.9.1" ; fi
11
+
12
+ case "$rvm_ruby_interpreter" in
13
+
14
+ macruby)
15
+ if [ "`uname`" = "Darwin" ] ; then
16
+ rvm_ruby_repo_url="${rvm_ruby_repo_url:-`__rvm_db "macruby_repo_url"`}"
17
+ rvm_ruby_version="${rvm_ruby_version:-`__rvm_db "macruby_version"`}"
18
+ rvm_ruby_package_name=${rvm_ruby_interpreter}_nightly-${rvm_ruby_version}
19
+ rvm_url="http://dl.getdropbox.com/u/163257/$rvm_ruby_package_name.pkg" # For now we are only supporting the 'nightly' builds
20
+ unset rvm_ruby_patch_level
21
+ else
22
+ __rvm_log "fail" "MacRuby can only be installed on a Darwin OS."
23
+ fi
24
+ ;;
25
+
26
+ rbx|rubinius)
27
+ rvm_ruby_version="head"
28
+ unset rvm_ruby_patch_level
29
+ rvm_ruby_repo_url=`__rvm_db "rubinius_repo_url"`
30
+ rvm_ruby_configure=""
31
+ rvm_ruby_make="build"
32
+ rvm_ruby_make_install=""
33
+ #rvm_ruby_rev="head"
34
+ ;;
35
+
36
+ jruby)
37
+ rvm_ruby_version="${rvm_ruby_version:-`__rvm_db "jruby_version"`}"
38
+ unset rvm_ruby_patch_level
39
+ if [ "$rvm_ruby_version" != "1.2.0" -a "$rvm_ruby_version" != "1.3.1" ] ; then
40
+ __rvm_log "fail" "Unknown jRuby version: $rvm_ruby_version"
41
+ fi
42
+ alias jruby_ng="jruby --ng"
43
+ alias jruby_ng_server="jruby --ng-server"
44
+ ;;
45
+
46
+ ruby-enterprise|ree)
47
+ rvm_ruby_interpreter=`__rvm_db "ree_interpreter"`
48
+ rvm_ruby_version=${rvm_ruby_version:-`__rvm_db "ruby_version"`}
49
+ rvm_ruby_patch_level="${3:-`__rvm_db "ree_patch_level"`}"
50
+
51
+ if [ "$rvm_ruby_version" != "1.8.6" ] ; then
52
+ __rvm_log "fail" "Unknown Ruby Enterprise Edition version: $rvm_ruby_version"
53
+ fi
54
+ ;;
55
+
56
+ ruby)
57
+ if [ ! -z "$rvm_ruby_tag" ] ; then
58
+ rvm_ruby_version=$(echo $rvm_ruby_tag | sed 's/^v//' | sed 's/\///' | awk -F'_' '{print 1 "." $2 "." $3 }')
59
+ rvm_ruby_patch_level=$rvm_ruby_tag # $(echo $rvm_ruby_tag | sed 's/^v//' | sed 's/\///' | awk -F'_' '{print $4 }')
60
+ fi
61
+
62
+ rvm_ruby_version=${rvm_ruby_version:-`__rvm_db "ruby_version"`} # Default verison is 1.8.6
63
+ rvm_ruby_patch_level=${rvm_ruby_patch_level:-`__rvm_db "ruby_${rvm_ruby_version}_patch_level"`} # Default verison is 1.8.6
64
+ if [ -z "rvm_ruby_patch_level" ] ; then unset rvm_ruby_patch_level ; fi
65
+
66
+ if [ -z "rvm_ruby_version" ] ; then
67
+ __rvm_log "fail" "Unknown ruby version: $rvm_ruby_version"
68
+ fi
69
+ ;;
70
+
71
+ default|system|current)
72
+ #noop?
73
+ ;;
74
+ *)
75
+ __rvm_log "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known."
76
+ esac
77
+
78
+ if [ ! -z "$rvm_ruby_rev" ] ; then
79
+ if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then
80
+ rvm_ruby_patch_level="head"
81
+ else
82
+ rvm_ruby_patch_level="$rvm_ruby_rev"
83
+ fi
84
+ fi
85
+
86
+ if [ ! -z "$rvm_ruby_interpreter" -a ! -z "$rvm_ruby_version" ] ; then
87
+ rvm_major_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $2 }')
88
+ rvm_minor_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $3 }')
89
+
90
+ if [ -z "$rvm_gem_set_name" ] ; then
91
+ rvm_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version"
92
+ else
93
+ if [ ! -z "$rvm_gem_set_name_rm" -a -d $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name ] ; then
94
+ rm -rf $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name/
95
+ if [ "$rvm_gem_set_name_rm" = "$rvm_gem_set_name" ] ; then unset rvm_gem_set_name ; fi
96
+ else
97
+ rvm_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name"
98
+ fi
99
+ fi
100
+ mkdir -p $rvm_gem_home
101
+
102
+ if [ -z "$rvm_ruby_patch_level" ] ; then
103
+ rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version"}"
104
+ rvm_ruby_home="${rvm_ruby_home:-"$rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version"}"
105
+ else
106
+ rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}"
107
+ rvm_ruby_home="${rvm_ruby_home:-"$rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}"
108
+ fi
109
+ rvm_ruby_log_path="$rvm_log_path/$rvm_ruby_package_name"
110
+ rvm_ruby_src_path="$rvm_source_path/$rvm_ruby_package_name"
111
+ rvm_ruby_binary="$rvm_ruby_home/bin/ruby"
112
+ rvm_ruby_irbrc="$rvm_ruby_home/.irbrc"
113
+ rvm_selected=1
114
+
115
+ export rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_version rvm_ruby_package_name rvm_url rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install rvm_ruby_rev rvm_ruby_tag rvm_major_version rvm_minor_version rvm_gem_set_name rvm_gem_path rvm_gem_home rvm_path rvm_source_path rvm_bin_path rvm_ruby_binary rvm_ruby_package_name rvm_ruby_home rvm_log_path rvm_ruby_log_path rvm_source_path rvm_ruby_src_path rvm_ruby_irbrc rvm_selected
116
+
117
+ else
118
+ unset rvm_selected
119
+ fi
120
+
121
+ }
122
+
123
+ function __rvm_use {
124
+
125
+ if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
126
+ if [ -z "$rvm_ruby_interpreter" ] ; then rvm_ruby_interpreter="default" ; fi
127
+
128
+ if [ "$rvm_ruby_interpreter" = "default" -o "$rvm_ruby_interpreter" = "system" ] ; then
129
+ unset GEM_HOME MY_RUBY_HOME IRBRC
130
+ PATH="$rvm_default_path" ; export PATH
131
+ if [ "$rvm_ruby_interpreter" = "default" -a -s $rvm_path/current ] ; then
132
+ source $rvm_path/current
133
+ fi
134
+ else
135
+ GEM_HOME=$rvm_gem_home ; export GEM_HOME
136
+ MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME
137
+ IRBRC="$rvm_ruby_irbrc" ; export IRBRC
138
+
139
+ # Install if not installed
140
+ if [ ! -d $MY_RUBY_HOME ] ; then
141
+ __rvm_log "warn" "$rvm_ruby_interpreter $rvm_ruby_version is not installed."
142
+ __rvm_install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level
143
+ fi
144
+
145
+ if [ ! -s "$rvm_ruby_irbrc" ] ; then
146
+ rvm_irbrc_file=$(cat <<Config
147
+ ; # No, this is not a stray ';' :)
148
+ require "irb/completion" rescue nil
149
+ @prompt = {
150
+ :PROMPT_I => "${rvm_ruby_package_name} > ", # default prompt
151
+ :PROMPT_S => "${rvm_ruby_package_name}%l> ", # known continuation
152
+ :PROMPT_C => "${rvm_ruby_package_name} > ",
153
+ :PROMPT_N => "${rvm_ruby_package_name} ?> ", # unknown continuation
154
+ :RETURN => " => %s \n",
155
+ :AUTO_INDENT => true
156
+ }
157
+ @prompt_mode = :DEFAULT
158
+ IRB.conf[:PROMPT][@prompt_mode] = @prompt
159
+ IRB.conf[:PROMPT_MODE] = @prompt_mode
160
+ Config
161
+ )
162
+ if [ -s ~/.irbrc ] ; then
163
+ cp ~/.irbrc $rvm_ruby_home/.irbrc
164
+ fi
165
+ echo "$rvm_irbrc_file" >> $rvm_ruby_home/.irbrc
166
+ fi
167
+ PATH="$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_path/bin:$rvm_default_path" ; export PATH
168
+
169
+ rvm_prompt="$rvm_ruby_package_name" ; export rvm_prompt
170
+ if [ ! -z "$rvm_set_prompt" -a ! -z "$PS1" ] ; then
171
+ PS1="\033[0;32m${rvm_prompt}\033[0m:: ${rvm_default_ps1}" ; export PS1
172
+ fi
173
+
174
+ if [ ! -z "$rvm_set_default" ] ; then
175
+ RUBY_VERSION="$($MY_RUBY_HOME/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')"
176
+ export GEM_HOME MY_RUBY_HOME RUBY_VERSION
177
+
178
+ echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_path/bin:$rvm_default_path ; export PATH" > $rvm_path/current
179
+
180
+ for variable in rvm_prompt RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do
181
+ eval "export $variable"
182
+ eval value=\$${variable}
183
+ echo "${variable}='$value' ; export ${variable}" >> $rvm_path/current
184
+ done
185
+ fi
186
+ fi
187
+ }
188
+
data/scripts/rvm-update CHANGED
@@ -18,19 +18,17 @@ for dir in src scripts bin log archives config gems examples ; do
18
18
  mkdir -p $rvm_dir/$dir
19
19
  done
20
20
 
21
+ echo -e "\n\033[0;32m<i>\033[0m Ensuring that rvm script location in $file is scripts/rvm not bin/rvm for: ~/.bash_profile, ~/.bashrc, ~/.zshrc"
21
22
  for file in ~/.bash_profile ~/.bashrc ~/.zshrc ; do
22
- if [ -s $file ] ; then
23
- echo -e "\n\033[0;33m<w>\033[0m Ensuring that rvm script location in $file is scripts/rvm not bin/rvm"
24
- sed -i.orig 's/rvm\/bin\/rvm/rvm\/scripts\/rvm/g' $file
25
- fi
23
+ if [ -s $file ] ; then sed -i.orig 's/rvm\/bin\/rvm/rvm\/scripts\/rvm/g' $file ; fi
26
24
  done
27
25
 
28
26
  if [ -f ~/.rvm/bin/rvm ] ; then
29
- echo -e "\n\033[0;33m<w>\033[0m Removing old rvm file from ~/.rvm/bin/rvm"
27
+ echo -e "\n\033[0;32m<i>\033[0m Removing old rvm file from ~/.rvm/bin/rvm"
30
28
  rm -f ~/.rvm/bin/rvm
31
29
  fi
32
30
 
33
- for dir in scripts examples ; do
31
+ for dir in config scripts examples ; do
34
32
  mkdir -p $rvm_dir/$dir
35
33
  for file in `/bin/ls $source_dir/$dir/`; do
36
34
  cp $source_dir/$dir/$file $rvm_dir/$dir/$file
@@ -39,10 +37,10 @@ done
39
37
 
40
38
  system=`uname`
41
39
  if [ "$system" = "Linux" ] ; then
42
- rvm_apt_get_binary=`which apt-get`
43
- rvm_emerge_binary=`which emerge`
44
- rvm_pacman_binary=`which pacman`
45
- rvm_yum_binary=`which yum`
40
+ rvm_apt_get_binary=`which apt-get 2> /dev/null`
41
+ rvm_emerge_binary=`which emerge 2> /dev/null`
42
+ rvm_pacman_binary=`which pacman 2> /dev/null`
43
+ rvm_yum_binary=`which yum 2> /dev/null`
46
44
 
47
45
  echo -e "\033[0;33m <w> \033[0mFor jRuby & ree (if you wish to use it) you will need:"
48
46
  if [ ! -z "$rvm_apt_get_binary" ] ; then
@@ -66,10 +64,11 @@ fi
66
64
 
67
65
  echo -e "$info There have been a great many updates since previous releases, please:"
68
66
  echo -e "$info * remove sourcing of ~/.rvm/current from your shell profiles."
69
- echo -e "$info * note that gems are now all pulled into ~/.rvm/gems/"
67
+ echo -e "$info * note that ruby gems are now all installed into ~/.rvm/gems"
70
68
 
71
- echo -e "\n Thank you, come again! \n"
72
- echo -e " ~ Wayne"
69
+ echo -e "\n$info Please visit the website for much more information: http://rvm.beginrescueend.com/\n"
70
+ echo ' w⦿‿⦿t! '
71
+ echo -e "\n ~ Wayne"
73
72
 
74
73
  source $rvm_dir/scripts/rvm
75
74
  rvm symlinks
@@ -0,0 +1,459 @@
1
+ #!/bin/bash
2
+
3
+ function __rvm_meta {
4
+ rvm_meta_author="Wayne E. Seguin"
5
+ rvm_meta_author_email="wayneeseguin@gmail.com"
6
+ rvm_meta_website="http://rvm.beginrescueend.com/"
7
+ rvm_meta_version="0.0.35"
8
+ rvm_meta_updated="2009.09.05"
9
+ }
10
+
11
+ function __rvm_version { __rvm_meta ; echo "rvm $rvm_meta_version ($rvm_meta_updated) [$rvm_meta_website]" ; }
12
+
13
+ function __rvm_usage {
14
+
15
+ __rvm_meta
16
+
17
+ cat <<-Usage
18
+
19
+ rvm ${rvm_meta_version} ${rvm_meta_website} by ${rvm_meta_author} (${rvm_meta_author_email})
20
+
21
+ Usage:
22
+
23
+ rvm Action [Implementation] [Options]
24
+
25
+ Action:
26
+
27
+ * usage - Show this usage information
28
+ use - Switch to using a specific ruby version (new login shell)
29
+ info - Show information for current ruby
30
+ list - Show currently installed versions
31
+ gemdir - Switch to gem directory for installation (new login shell)
32
+ srcdir - Switch to src directory for the current ruby installation
33
+ gemdup - Clone source version gems to current version
34
+ (highly expiramental) Example: rvm gemdup ~/.gem/ruby/1.8/
35
+ install - Install a ruby version, default is from source
36
+ uninstall - Uninstall a ruby version
37
+ reset - Remove default and current settings, exit the shell.
38
+ (If you experience odd behavior try this first)
39
+ rubydo - Used with -f to run a ruby file against specified or all rubies
40
+ debug - Emit environment & configuration information for *current* ruby
41
+
42
+ reload - Reload rvm source itself (useful after changing rvm source)
43
+ implode - Removes all ruby installations it manages, everything in ~/.rvm
44
+ update - Upgrades rvm to the latest version.
45
+
46
+ Implementation:
47
+
48
+ * ruby - MRI/YARV Ruby (The Standard), defaults to 1.8.6
49
+ jruby - jRuby
50
+ rubinius - Rubinius
51
+ ree - Ruby Enterprise Edition
52
+ system - Use the system ruby (eg. pre-rvm state)
53
+ default - Use rvm set default ruby and system if it hasn't been set.
54
+
55
+ Options:
56
+
57
+ -v|--version - Ruby Package Version, defaults to 'latest'
58
+ -l|--level - Patch level for the specified Ruby version
59
+ -p|--prefix - Package and source directory prefix, with trailing slash!
60
+ Default is a users home directory and /usr/local/ for root
61
+ -a|--archives - Directory to place downladed files into (~/.rvm/archives/)
62
+ -n|--nice - Niceness level (default: 0)
63
+ -m|--gem-set - Named gem set for switching between different gem sets
64
+ --rm-gem-set - Removes a named gemset.
65
+
66
+ -l|--level - Specify a patch level to use
67
+ -t|--tag -
68
+ -r|--rev - Specify the repository revision # to use or 'head' for
69
+
70
+ -P|--prefix - Sets the prefix path for installs to be installed to
71
+ -B|--bin - Specify path for binaries to be placed
72
+ -S|--source - Specify src directory to use
73
+ -A|--archive - Specify archive directory to use (tabralls / zips)
74
+ -G|--gems - Specify root gem path to use
75
+ -C|--configure - Specify custom configure options, comma separated
76
+ default: --enable-shared=true
77
+ --re-configure - Force installer to re-run configure if already run
78
+ -M|--make - Specify a custom make command
79
+ -I|--make-install - " a custom make install command
80
+
81
+ -n|--nice - Specify a process niceness (for slow computers)
82
+ -f|--file - Specify a ruby file to run with 'rubydo' command
83
+ -h|--help - Emit this output and exit
84
+ -d|--default - Set the default Ruby to a specified version
85
+ -m|--gem-set - Use a named gem set instead of the default set.
86
+ --all - Used with 'rvm list' to list "most" installable versions.
87
+ --rm-gem-set - Remove a named gem set
88
+ --jit - Enable JIT for the Rubinius build
89
+ --force - Force install, removes old install & source directories.
90
+ --set-prompt - Set prompt to have the selected ruby prepended.
91
+ --debug|--trace - Toggle debug mode on for very verbose output.
92
+
93
+ Resources:
94
+
95
+ http://rvm.beginrescueend.com/
96
+ https://www.pivotaltracker.com/projects/26822
97
+
98
+ Usage
99
+
100
+ }
101
+
102
+ function __rvm_info {
103
+ cat <<Info
104
+
105
+ ruby:
106
+ interpreter: "`ruby -v | awk '{print $1}'`"
107
+ version: "`ruby -v | awk '{print $2}'`"
108
+ date: "`ruby -v | sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/'`"
109
+ platform: "`ruby -v | sed 's/^.*\[//' | sed 's/\].*$//'`"
110
+ patchlevel: "`ruby -v | sed 's/^.*(//' | sed 's/).*$//'`"
111
+ full_version: "`ruby -v`"
112
+
113
+ homes:
114
+ gem: "${GEM_HOME:-'not set'}"
115
+ ruby: "${MY_RUBY_HOME:-'not set'}"
116
+
117
+ binaries:
118
+ ruby: "`which ruby`"
119
+ irb: "`which irb`"
120
+ gem: "`which gem`"
121
+
122
+ environment:
123
+ GEM_HOME: "$GEM_HOME"
124
+ MY_RUBY_HOME: "$MY_RUBY_HOME"
125
+ IRBRC: "$IRBRC"
126
+ Info
127
+ }
128
+
129
+ function __rvm_debug {
130
+ __rvm_log "info" "PATH:$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')"
131
+ for file in .bash_profile .bashrc .zshrc ; do
132
+ if [ -s $file ] ; then
133
+ __rvm_log "debug" "~/$file:\n$(grep rvm ~/$file)\n"
134
+ fi
135
+ done
136
+ if [ -s $rvm_path/current ] ; then
137
+ __rvm_log "debug" "$rvm_path/current:\n$($rvm_path/current)\n"
138
+ fi
139
+ if [ -e $rvm_path/bin/rvm ] ; then
140
+ __rvm_log "debug" "rvm script in bin:\n$(ls -laht $rvm_path/bin/rvm)"
141
+ fi
142
+
143
+ }
144
+
145
+ # Logging functions based on level
146
+ function __rvm_log {
147
+
148
+ case "$1" in
149
+ debug) shift ; echo -e "\n\033[0;35m <d> \033[0m $*" ;;
150
+ info) shift ; echo -e "\n\033[0;32m <i> \033[0m $*" ;;
151
+ warn) shift ; echo -e "\n\033[0;33m <w> \033[0m $*" ;;
152
+ fail) shift ; echo -e "\n\033[0;31m <e> \033[0m $*" ; popd 2> /dev/null ; return 1 ;;
153
+ *) echo -e "$*"
154
+ esac
155
+ }
156
+
157
+ function __rvm_clean-path {
158
+ PATH=`echo $PATH | tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | tr -s '\n' ':' | sed 's/:$//'`
159
+ export PATH
160
+ }
161
+
162
+ function __rvm_remove-rvm-from-path {
163
+ PATH=`echo $PATH | tr -s ':' '\n' | grep -v "\.rvm" | tr -s '\n' ':' | sed 's/:$//'`
164
+ export PATH
165
+ }
166
+
167
+ function __rvm_gi { gem install -q --no-rdoc --no-ri $* ; }
168
+
169
+ function __rvm_run {
170
+ log_file_name="$1" ; shift
171
+ command="$*"
172
+ if [ $rvm_debug ] ; then __rvm_log "debug" "Executing: $command" ; fi
173
+ eval "nice -n $rvm_niceness $command" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log
174
+ if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/$log_file_name.error.log" ; popd 2> /dev/null ; return 1 ; fi
175
+ unset log_file command
176
+ }
177
+
178
+ function __rvm_cleanup-variables {
179
+ 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_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 rvm_bin_path rvm_force rvm_set_prompt rvm_all rvm_re_configure
180
+ }
181
+
182
+ # TODO: root user loadng of /etc/rvmrc
183
+ function __rvm_load-rvmrc {
184
+ if [ -s ~/.rvmrc ] ; then source ~/.rvmrc ; fi
185
+ }
186
+
187
+ function __rvm_bin_scripts {
188
+ if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
189
+
190
+ ruby_wrapper=$(cat <<-RubyWrapper
191
+ #!/bin/bash
192
+ GEM_HOME=$rvm_gem_home ; export GEM_HOME
193
+ MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME
194
+ PATH=$rvm_ruby_home/bin:$rvm_gem_home/bin:$rvm_default_path ; export PATH
195
+
196
+ exec "$rvm_ruby_binary" "\$@"
197
+ RubyWrapper
198
+ )
199
+
200
+ echo "$ruby_wrapper" > $rvm_bin_path/$rvm_ruby_package_name
201
+ unset ruby_wrapper
202
+ chmod +x $rvm_bin_path/$rvm_ruby_package_name
203
+
204
+ }
205
+
206
+
207
+ function __rvm_fetch {
208
+
209
+ pushd $rvm_archives_path > /dev/null
210
+ eval $rvm_fetch "$1"
211
+ if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi
212
+ popd 2> /dev/null
213
+
214
+ }
215
+
216
+ function __rvm_load-defaults {
217
+
218
+ if [ ! -s $rvm_path/default ] ; then
219
+ for variable in rvm_prompt RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do
220
+ eval value=\$${variable}
221
+ if [ -z "$value" ] ; then
222
+ echo "unset ${variable}" >> $rvm_path/default
223
+ else
224
+ eval "export $variable"
225
+ eval value=\$${variable}
226
+ echo "${variable}='$value' ; export ${variable}" >> $rvm_path/default
227
+ fi
228
+ done
229
+ fi
230
+
231
+ rvm_default_path=`__rvm_db "rvm_default_path"`
232
+ if [ -z "$rvm_default_path" ] ; then
233
+ __rvm_clean-path # Clean the path the first time we compute default path.
234
+ __rvm_remove-rvm-from-path
235
+ rvm_default_path="$PATH"
236
+ __rvm_db "rvm_default_path" "$rvm_default_path"
237
+ fi
238
+
239
+ rvm_default_ps1=`__rvm_db "rvm_default_ps1"`
240
+ if [ -z "$rvm_default_ps1" ] ; then
241
+ rvm_default_ps1=$PS1
242
+ __rvm_db "rvm_default_ps1" "$rvm_default_ps1"
243
+ fi
244
+
245
+ rvm_default_system_ruby=`__rvm_db "default_system_ruby"`
246
+ if [ -z "$rvm_default_system_ruby" ] ; then
247
+ rvm_default_system_ruby=`which ruby`
248
+ if [ $? -ne 0 ] ; then
249
+ __rvm_log "info" "System ruby not found, no db will be stored."
250
+ else
251
+ __rvm_db "default_system_ruby" "$rvm_default_system_ruby"
252
+
253
+ # Now store default system & user gem paths
254
+ rvm_default_user_gem_path=`__rvm_db "default_user_gem_path"`
255
+ if [ -z "$rvm_default_user_gem_path" ] ; then
256
+ rvm_default_user_gem_path=`ruby -r rubygems -e "puts Gem::default_path.compact.first"`
257
+ __rvm_db "default_user_gem_path" "$rvm_default_user_gem_path"
258
+ fi
259
+ rvm_default_system_gem_path=`__rvm_db "default_system_gem_path"`
260
+ if [ -z "$rvm_default_system_gem_path" ] ; then
261
+ rvm_default_system_gem_path=`ruby -r rubygems -e "puts Gem::default_path.compact[1] || Gem::default_path.compact.first"`
262
+ __rvm_db "default_system_gem_path" "$rvm_default_system_gem_path"
263
+ fi
264
+ fi
265
+ fi
266
+
267
+ }
268
+
269
+ function __rvm_reset {
270
+
271
+ PATH="$rvm_path/bin:$rvm_default_path" ; export PATH
272
+ for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME rvm_prompt ; do unset $variable ; done
273
+ rm -f $rvm_path/default*
274
+ rm -f $rvm_path/current
275
+
276
+ __rvm_select "system"
277
+
278
+ }
279
+
280
+ function __rvm_implode {
281
+ while : ; do
282
+ __rvm_log "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
283
+ read response
284
+ if [ "$response" = "yes" ] ; then
285
+ if [ -d $rvm_path ] ; then
286
+ __rvm_log "info" "Hai! Removing $rvm_path"
287
+ rm -rf $rvm_path/
288
+ else
289
+ __rvm_log "info" "It appears that $rvm_path is already non existant."
290
+ fi
291
+ break
292
+ elif [ "$response" = "no" ] ; then
293
+ __rvm_log "info" "Cancelling implosion, no harm done :)"
294
+ break
295
+ fi
296
+ done
297
+ }
298
+
299
+ function __rvm_gem-dir {
300
+
301
+ if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
302
+
303
+ mkdir -p $rvm_gem_home
304
+ echo $rvm_gem_home
305
+ }
306
+
307
+ function __rvm_src-dir {
308
+
309
+ if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
310
+
311
+ if [ -z "$rvm_ruby_src_path" ] ; then
312
+ __rvm_log "fail" "No source directory exists for the default implementation."
313
+ else
314
+ echo "$rvm_ruby_src_path"
315
+ fi
316
+
317
+ }
318
+
319
+ # clones from source implementation/version to current
320
+ function __rvm_gem-dup {
321
+
322
+ if [ "$1" = "default" ] ; then
323
+ rvm_source_gem_dir="$rvm_default_user_gem_path"
324
+ elif [ "$1" = "system" ] ; then
325
+ rvm_source_gem_dir="$rvm_default_system_gem_path"
326
+ else
327
+ rvm_source_gem_dir=${1:-$rvm_default_user_gem_path} # TODO: check for and remove trailing /gems
328
+ fi
329
+
330
+ if [ ! -z "$rvm_source_gem_dir" ] ; then
331
+ for rvm_gem_name_version in `/bin/ls $rvm_source_gem_dir/gems` ; do
332
+ rvm_gem_name=${rvm_gem_name_version%-*}
333
+ rvm_gem_version=${rvm_gem_name_version##*-}
334
+ if [ -d $GEM_HOME/gems/$rvm_gem_name_version ] ; then
335
+ echo "$rvm_gem_name_version already installed."
336
+ else
337
+ __rvm_gi $rvm_source_gem_dir/cache/$rvm_gem_name-$rvm_gem_version.gem
338
+ fi
339
+ done
340
+ unset rvm_gem_name_version rvm_gem_name rvm_gem_version
341
+ else
342
+ __rvm_log "fail" "Unknown $rvm_ruby_interpreter version: $rvm_ruby_version"
343
+ fi
344
+
345
+ }
346
+
347
+ function __rvm_db {
348
+ rvm_hash_file="$rvm_config_path/db"
349
+ touch $rvm_hash_file
350
+ key="$1" ; shift
351
+
352
+ if [ -z "$key" ] ; then
353
+ __rvm_log "fail" "__rvm_db must be called with at least one argument: __rvm_db key [value]"
354
+ else
355
+ if [ "$key" = "unset" -o "$key" = "delete" ] ; then
356
+ sed -i# "s/^$2=.*$//" $rvm_hash_file
357
+ else
358
+ value="$*"
359
+ if [ -z "$value" ] ; then # get
360
+ grep "^$key=" $rvm_hash_file | awk -F'=' '{print $2}'
361
+ else # set
362
+ if [ -z "$(grep "^$key=" $rvm_hash_file)" ] ; then # append
363
+ echo "$key=$value" >> $rvm_hash_file
364
+ else # overwrite
365
+ sed -i# "s/^$key=.*$/$key=$value/" $rvm_hash_file
366
+ fi
367
+ fi
368
+ fi
369
+ fi
370
+ }
371
+
372
+ # Q: TODO: Is this neccessary any longer?
373
+ function __rvm_symlinks {
374
+ # TODO: Account for the ruby wrapper script files
375
+
376
+ mkdir -p ${rvm_path}/bin
377
+ for release in `/bin/ls $rvm_path | grep 'ruby-'` ; do
378
+ for binary in irb gem rdoc ri erb ; do
379
+ if [ -x $rvm_path/$release/bin/$binary ] ; then
380
+ ln -fs $rvm_path/$release/bin/$binary $rvm_path/bin/$binary-${release#ruby-}
381
+ fi
382
+ done
383
+ done
384
+
385
+ }
386
+
387
+ function __rvm_list {
388
+
389
+ if [ "$rvm_all" ] ; then
390
+ svn list http://svn.ruby-lang.org/repos/ruby/tags/ | grep 'v1_[8|9]' | sed 's/^v1_//' | sed 's/\/$//' | awk -F'_' '{print "1."$1"."$2 " -l "$3}' | sed 's/p$//'
391
+
392
+ echo "jruby 1.2.0"
393
+ echo "jruby 1.3.0"
394
+ echo "jruby 1.3.1"
395
+ echo "jruby head"
396
+ echo "rubinius head"
397
+ echo "rbx head"
398
+ echo "ree 20090610"
399
+ else
400
+ echo -e "\nruby:\n$(/bin/ls -l $rvm_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }')\n"
401
+ echo -e "jruby:\n$(/bin/ls -l $rvm_path/ | awk '/jruby-.*/ { print " - " $NF }')\n"
402
+ echo -e "ree:\n$(/bin/ls $rvm_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }')\n"
403
+ echo -e "system:\n - ($($rvm_default_system_ruby -v))\n"
404
+ fi
405
+
406
+ }
407
+
408
+ function __rvm_initialize {
409
+
410
+ rvm_fetch=`which curl`
411
+ if [ $? -ne 0 ] ; then
412
+ rvm_fetch=`which wget`
413
+ if [ $? -ne 0 ] ; then
414
+ rvm_fetch="wget -q -c "
415
+ else
416
+ __rvm_log "fail" "rvm expects either curl or wget, neither seem to be in your path :("
417
+ fi
418
+ else
419
+ rvm_fetch="$rvm_fetch -O -L -s --create-dirs -C - "
420
+ fi
421
+
422
+ rvm_niceness=${rvm_niceness:-0}
423
+
424
+ # TODO: Sanitize user input, ensure that there is a / a the end...
425
+ if [ "`whoami`" = "root" ] ; then
426
+ __rvm_log "fail" "root user support is not yet implemented."
427
+ #rvm_prefix_path=${rvm_prefix_path:-/usr/local/}
428
+ else
429
+ rvm_prefix_path=${rvm_prefix_path:-"$HOME/."}
430
+ fi
431
+ if [ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '.' -o "${rvm_prefix_path#${rvm_prefix_path%?}}" = '/' ] ; then
432
+ rvm_path="${rvm_prefix_path}rvm"
433
+ else
434
+ rvm_path="${rvm_prefix_path}/rvm"
435
+ fi
436
+ rvm_archives_path="${rvm_archives_path:-"${rvm_path}/archives"}"
437
+ rvm_source_path="${rvm_source_path:-"${rvm_path}/src"}"
438
+ rvm_log_path=${rvm_log_path:-"${rvm_path}/log"}
439
+ rvm_bin_path=${rvm_bin_path:-"${rvm_path}/bin"}
440
+ rvm_gem_path=${rvm_gem_path:-"${rvm_path}/gems"}
441
+ rvm_config_path=${rvm_config_path:-"${rvm_path}/config"}
442
+
443
+ rvm_ruby_repo_url="${rvm_ruby_repo_url:-"http://svn.ruby-lang.org/repos/ruby"}"
444
+ # Rubinius sha1's will be available after RC1.
445
+ rvm_rubinius_repo_url="${rvm_rubinius_repo_url:-"git://github.com/evanphx/rubinius.git"}"
446
+ #rvm_macruby_repo_url="${rvm_macruby_repo_url:-"http://svn.macosforge.org/repository/ruby/MacRuby"}"
447
+ rvm_macruby_repo_url="${rvm_macruby_repo_url:-"git://github.com/masterkain/macruby.git"}"
448
+ rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
449
+
450
+ __rvm_clean-path
451
+ rvm_result=$(echo $PATH | grep 'rvm\/bin:')
452
+ if [ -z $rvm_result ] ; then
453
+ PATH=$rvm_bin_path:$PATH ; export PATH
454
+ fi
455
+
456
+ mkdir -p $rvm_source_path $rvm_bin_path $rvm_archives_path
457
+ }
458
+
459
+