gemrage 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. data/Gemfile +2 -0
  2. data/Gemfile.lock +5 -0
  3. data/VERSION +1 -1
  4. data/gemrage.gemspec +148 -3
  5. data/lib/rubygems/commands/scan_command.rb +77 -4
  6. data/vendor/ruby/1.8/bin/rvm-install +19 -0
  7. data/vendor/ruby/1.8/cache/macaddr-1.0.0.gem +0 -0
  8. data/vendor/ruby/1.8/cache/rvm-1.0.14.gem +0 -0
  9. data/vendor/ruby/1.8/gems/macaddr-1.0.0/README +33 -0
  10. data/vendor/ruby/1.8/gems/macaddr-1.0.0/gemspec.rb +27 -0
  11. data/vendor/ruby/1.8/gems/macaddr-1.0.0/install.rb +210 -0
  12. data/vendor/ruby/1.8/gems/macaddr-1.0.0/lib/macaddr.rb +69 -0
  13. data/vendor/ruby/1.8/gems/rvm-1.0.14/LICENCE +18 -0
  14. data/vendor/ruby/1.8/gems/rvm-1.0.14/README +127 -0
  15. data/vendor/ruby/1.8/gems/rvm-1.0.14/bin/rvm-install +5 -0
  16. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm +76 -0
  17. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-auto-ruby +24 -0
  18. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-prompt +204 -0
  19. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-shell +35 -0
  20. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-update-head +35 -0
  21. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-update-latest +27 -0
  22. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvmsudo +24 -0
  23. data/vendor/ruby/1.8/gems/rvm-1.0.14/config/db +71 -0
  24. data/vendor/ruby/1.8/gems/rvm-1.0.14/config/known +55 -0
  25. data/vendor/ruby/1.8/gems/rvm-1.0.14/config/md5 +87 -0
  26. data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/gemset_snapshot +25 -0
  27. data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/install-system-wide +191 -0
  28. data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/r +44 -0
  29. data/vendor/ruby/1.8/gems/rvm-1.0.14/examples/rvmrc +47 -0
  30. data/vendor/ruby/1.8/gems/rvm-1.0.14/gemsets/default.gems +1 -0
  31. data/vendor/ruby/1.8/gems/rvm-1.0.14/gemsets/global.gems +1 -0
  32. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/alias +46 -0
  33. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/benchmark +17 -0
  34. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/cleanup +23 -0
  35. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/debug +8 -0
  36. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/disk-usage +15 -0
  37. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/docs +22 -0
  38. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/exec +33 -0
  39. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/fetch +5 -0
  40. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gem +0 -0
  41. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gemdir +0 -0
  42. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gemset +0 -0
  43. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/implode +0 -0
  44. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/info +64 -0
  45. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/install +0 -0
  46. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/list +0 -0
  47. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/migrate +15 -0
  48. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/monitor +0 -0
  49. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/notes +0 -0
  50. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/package +0 -0
  51. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rake +14 -0
  52. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/remove +0 -0
  53. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/repair +23 -0
  54. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/reset +0 -0
  55. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/ruby +84 -0
  56. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rubygems +11 -0
  57. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rvmrc +34 -0
  58. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/snapshot +15 -0
  59. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/specs +0 -0
  60. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/srcdir +0 -0
  61. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/tests +0 -0
  62. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/tools +22 -0
  63. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/uninstall +0 -0
  64. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/update +0 -0
  65. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/upgrade +18 -0
  66. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/use +0 -0
  67. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/wrapper +41 -0
  68. data/vendor/ruby/1.8/gems/rvm-1.0.14/install +631 -0
  69. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/VERSION.yml +4 -0
  70. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/capistrano.rb +45 -0
  71. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/alias.rb +69 -0
  72. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/cleanup.rb +54 -0
  73. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/configuration.rb +60 -0
  74. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb +52 -0
  75. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/gemset.rb +222 -0
  76. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/info.rb +13 -0
  77. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/list.rb +124 -0
  78. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/rubies.rb +50 -0
  79. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/sets.rb +123 -0
  80. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/tools.rb +68 -0
  81. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/utility.rb +173 -0
  82. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/wrapper.rb +23 -0
  83. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment.rb +64 -0
  84. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/errors.rb +31 -0
  85. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb +51 -0
  86. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/abstract_wrapper.rb +145 -0
  87. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/calculate_rvm_path.sh +26 -0
  88. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/result.rb +42 -0
  89. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/shell_wrapper.sh +10 -0
  90. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/single_shot_wrapper.rb +56 -0
  91. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/utility.rb +37 -0
  92. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell.rb +25 -0
  93. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/version.rb +19 -0
  94. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm.rb +156 -0
  95. data/vendor/ruby/1.8/gems/rvm-1.0.14/man/man1/rvm.1 +385 -0
  96. data/vendor/ruby/1.8/gems/rvm-1.0.14/man/man1/rvm.1.gz +0 -0
  97. data/vendor/ruby/1.8/gems/rvm-1.0.14/rvm.gemspec +184 -0
  98. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/alias +225 -0
  99. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/aliases +4 -0
  100. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array +32 -0
  101. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/base +49 -0
  102. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cd +87 -0
  103. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cleanup +58 -0
  104. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cli +781 -0
  105. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/color +49 -0
  106. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/completion +151 -0
  107. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/db +87 -0
  108. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/default +64 -0
  109. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/disk-usage +60 -0
  110. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/docs +115 -0
  111. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/env +46 -0
  112. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/environment-convertor +74 -0
  113. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/fetch +229 -0
  114. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/gemsets +950 -0
  115. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash +37 -0
  116. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/help +46 -0
  117. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hook +23 -0
  118. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/info +214 -0
  119. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/initialize +29 -0
  120. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/install +631 -0
  121. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/irbrc +9 -0
  122. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/irbrc.rb +63 -0
  123. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/list +315 -0
  124. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/log +38 -0
  125. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/maglev +193 -0
  126. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/manage +2094 -0
  127. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/match +6 -0
  128. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/md5 +22 -0
  129. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/migrate +175 -0
  130. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/monitor +105 -0
  131. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/notes +121 -0
  132. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/override_gem +14 -0
  133. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/package +301 -0
  134. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/patches +64 -0
  135. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/patchsets +87 -0
  136. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/repair +199 -0
  137. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rubygems +157 -0
  138. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rvm +120 -0
  139. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rvm-install +631 -0
  140. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/selector +818 -0
  141. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/set +301 -0
  142. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/snapshot +262 -0
  143. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/tools +58 -0
  144. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/update +631 -0
  145. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/upgrade +144 -0
  146. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/utility +1557 -0
  147. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/version +17 -0
  148. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/wrapper +210 -0
  149. data/vendor/ruby/1.8/specifications/macaddr-1.0.0.gemspec +27 -0
  150. data/vendor/ruby/1.8/specifications/rvm-1.0.14.gemspec +42 -0
  151. metadata +149 -4
@@ -0,0 +1,2094 @@
1
+ #!/usr/bin/env bash
2
+
3
+ original_ruby_version=${rvm_ruby_version:-""}
4
+ original_ruby_string=${rvm_ruby_string:-""}
5
+
6
+ source "$rvm_path/scripts/base"
7
+ source "$rvm_path/scripts/patches"
8
+
9
+ __rvm_check_for_clang()
10
+ {
11
+ if [[ -n "${rvm_clang_flag:-""}" ]] && ! command -v clang >/dev/null ; then
12
+ "$rvm_path/scripts/log" "fail" "\nYou passed the --clang option and clang is not in your path. \nPlease try again or do not use --clang.\n"
13
+ return 1
14
+ fi
15
+ }
16
+
17
+ # Checks for bison, returns zero iff it is found
18
+ __rvm_check_for_bison()
19
+ {
20
+ if [[ ${rvm_head_flag:-0} -gt 0 ]]; then
21
+ command -v bison > /dev/null
22
+ result=$?
23
+ if [[ $? -gt 0 ]] ; then
24
+ "$rvm_path/scripts/log" "fail" \
25
+ "\nbison is not available in your path. \nPlease ensure bison is installed before compiling from head.\n"
26
+ fi
27
+ fi
28
+
29
+ return ${result:-0}
30
+ }
31
+
32
+ # Emits a number of patches to STDOUT, each on a new name
33
+ # Expands patchsets etc.
34
+ __rvm_current_patch_names()
35
+ {
36
+ # TODO: Lookup default patches on rvm_ruby_string heirarchy.
37
+ local separator patches level name
38
+
39
+ separator="%"
40
+ patches="${rvm_patch_names:-""} default"
41
+
42
+ for patch_name in $(echo ${patches//,/ }); do
43
+
44
+ level=1
45
+ name="$patch_name"
46
+
47
+ if echo "$name" | grep -q "$separator"; then
48
+ level="${name/*${separator}/}"
49
+ name="${name//${separator}*/}"
50
+ fi
51
+
52
+ local expanded_name="$(__rvm_expand_patch_name "$name")"
53
+
54
+ echo "${expanded_name}${separator}${level}"
55
+
56
+ done
57
+
58
+ return 0
59
+ }
60
+
61
+ __rvm_apply_patches()
62
+ {
63
+ local patches patch_name patch_level_separator patch_fuzziness patch_level source_directory full_patch_path
64
+
65
+ result=0
66
+ patch_level_separator="%"
67
+ patch_fuzziness="25"
68
+ patch_level=1
69
+
70
+ source_directory="${1:-""}"
71
+
72
+ if [[ -z "$source_directory" ]] ; then
73
+ source_directory="${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
74
+ fi
75
+
76
+ (
77
+ builtin cd "$source_directory"
78
+
79
+ patches=($(__rvm_current_patch_names))
80
+
81
+ for patch_name in "${patches[@]}" ; do
82
+
83
+ # If set, extract the patch level from the patch name.
84
+ patch_level=1
85
+
86
+ if echo "$patch_name" | \grep -q "$patch_level_separator"; then
87
+ patch_level=${patch_name//*${patch_level_separator}/}
88
+ patch_name="${patch_name//${patch_level_separator}*/}"
89
+ fi
90
+
91
+ full_patch_path="$(__rvm_lookup_full_patch_path "$patch_name")"
92
+
93
+ # Expand paths, and for those we found we then apply the patches.
94
+ if [[ -n "${full_patch_path:-""}" ]]; then
95
+
96
+ if [[ -f "$full_patch_path" ]] ; then
97
+
98
+ __rvm_run "patch.apply.${patch_name/*\/}" \
99
+ "patch -F$patch_fuzziness -p$patch_level -f <\"$full_patch_path\"" \
100
+ "Applying patch '$patch_name' (located at $full_patch_path)"
101
+
102
+ [[ $? -gt 0 ]] && result=1 # Detect failed patches
103
+ fi
104
+
105
+ else
106
+ "$rvm_path/scripts/log" "warn" \
107
+ "Patch '$patch_name' not found."
108
+ result=1
109
+ fi
110
+ done
111
+ )
112
+
113
+ return ${result:-0}
114
+ }
115
+
116
+ __rvm_install_source()
117
+ {
118
+ local directory configure_parameters db_configure_flags
119
+
120
+ [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] && __rvm_select
121
+
122
+ case ${rvm_ruby_string:-""} in
123
+ ruby-head|1.9.*-head) __rvm_ensure_has_18_compat_ruby || return 1 ;;
124
+ esac
125
+
126
+ "$rvm_path/scripts/log" "info" \
127
+ "Installing Ruby from source to: $rvm_ruby_home, this may take a while depending on your cpu(s)...\n"
128
+
129
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}"
130
+
131
+ if [[ ${rvm_force_flag:-0} -eq 1 ]] ; then
132
+
133
+ for directory in "$rvm_ruby_home" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" ; do
134
+
135
+ if [[ -d "$directory" ]] ; then
136
+ rm -rf "$directory"
137
+ fi
138
+
139
+ done
140
+ fi
141
+
142
+ result=0
143
+
144
+ __rvm_fetch_ruby
145
+ result=$?
146
+
147
+ if [[ "$result" -gt 0 ]] ; then
148
+ "$rvm_path/scripts/log" "error" \
149
+ "There has been an error fetching the ruby interpreter. Halting the installation."
150
+ return $result
151
+ fi
152
+
153
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
154
+
155
+ result=$? ; if [[ "$result" -gt 0 ]] ; then
156
+ "$rvm_path/scripts/log" "error" \
157
+ "Source directory is missing. Did the download or extraction fail? Halting the installation."
158
+ return $result
159
+ fi
160
+
161
+ if [[ -d "${rvm_path}/usr" ]] ; then
162
+ export PATH="${rvm_path}/usr/bin:${PATH}"
163
+
164
+ builtin hash -r
165
+ fi
166
+
167
+ __rvm_apply_patches
168
+ result="$?"
169
+
170
+ if [[ "$result" -gt 0 ]]; then
171
+ "$rvm_path/scripts/log" "fail" \
172
+ "There has been an error applying the specified patches. Halting the installation."
173
+ return $result
174
+ fi
175
+
176
+ if [[ -z "${rvm_ruby_configure:-""}" \
177
+ && ! -s "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/configure" ]] ; then
178
+
179
+ if command -v autoconf > /dev/null ; then
180
+
181
+ __rvm_run "autoconf" "autoconf" "Running autoconf"
182
+
183
+ else
184
+ "$rvm_path/scripts/log" "fail" \
185
+ "rvm requires autoconf to install the selected ruby interpreter however autoconf was not found in the PATH."
186
+ return 1
187
+ fi
188
+ fi
189
+
190
+ if [[ -n "${rvm_ruby_configure:-""}" ]] ; then
191
+
192
+ __rvm_run "configure" "$rvm_ruby_configure"
193
+ result=$?
194
+
195
+ if [[ "$result" -gt 0 ]] ; then
196
+ "$rvm_path/scripts/log" "error" \
197
+ "There has been an error while configuring. Halting the installation."
198
+ return $result
199
+ fi
200
+
201
+ elif [[ -s ./configure ]] ; then
202
+
203
+ # REE stores configure flags differently for head vs. the distributed release.
204
+ if [[ "ree" != "${rvm_ruby_interpreter:-""}" ]]; then
205
+ __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
206
+ fi
207
+
208
+ # On 1.9.2, we manually set the --with-baseruby option
209
+ # to point to an expanded path.
210
+ if [[ "${rvm_ruby_string:-""}" = "ruby-1.9.2-head" ]] ; then
211
+
212
+ local compatible_baseruby="$rvm_path/wrappers/$(__rvm_18_compat_ruby)/ruby"
213
+
214
+ if [[ -x "$compatible_baseruby" ]] ; then
215
+ configure_parameters="--with-baseruby=$compatible_baseruby"
216
+ fi
217
+ fi
218
+
219
+ local configure_command="./configure --prefix=$rvm_ruby_home ${db_configure_flags:-""} ${rvm_configure_flags:-""} ${configure_parameters:-""}"
220
+
221
+ __rvm_run "configure" "$configure_command" "$rvm_ruby_string - #configuring "
222
+ result=$?
223
+
224
+ if [[ "$result" -gt 0 ]] ; then
225
+ "$rvm_path/scripts/log" "error" \
226
+ "There has been an error while running configure. Halting the installation."
227
+ return $result
228
+ fi
229
+
230
+ else
231
+ "$rvm_path/scripts/log" "error" \
232
+ "Skipping configure step, 'configure' does not exist, did autoconf not run successfully?"
233
+ fi
234
+
235
+ rvm_ruby_make=${rvm_ruby_make:-"make"}
236
+
237
+ __rvm_run "make" "$rvm_ruby_make ${rvm_make_flags:-""}" "$rvm_ruby_string - #compiling "
238
+ result=$?
239
+
240
+ if [[ "$result" -gt 0 ]] ; then
241
+ "$rvm_path/scripts/log" "error" \
242
+ "There has been an error while running make. Halting the installation."
243
+ return $result
244
+ fi
245
+
246
+ if [[ -d .ext/rdoc ]] ; then
247
+ rm -rf .ext/rdoc
248
+ fi
249
+
250
+ rvm_ruby_make_install=${rvm_ruby_make_install:-"make install"}
251
+
252
+ __rvm_run "install" "$rvm_ruby_make_install" "$rvm_ruby_string - #installing "
253
+ result=$?
254
+
255
+ if [[ "$result" -gt 0 ]] ; then
256
+ "$rvm_path/scripts/log" "error" \
257
+ "There has been an error while running make install. Halting the installation."
258
+ return $result
259
+ fi
260
+
261
+ export GEM_HOME="$rvm_ruby_gem_home"
262
+ export GEM_PATH="$rvm_ruby_gem_path"
263
+ export BUNDLE_PATH="$rvm_ruby_gem_home"
264
+
265
+ __rvm_rubygems_setup
266
+ result=$?
267
+
268
+ __rvm_bin_script
269
+
270
+ __rvm_run "chmod.bin" "chmod +x $rvm_ruby_home/bin/*"
271
+
272
+ __rvm_post_install
273
+ result=$?
274
+
275
+ "$rvm_path/scripts/log" "info" \
276
+ "Install of $rvm_ruby_string - #complete "
277
+
278
+ return ${result:-0}
279
+ }
280
+
281
+ __rvm_install_ruby()
282
+ {
283
+ if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
284
+
285
+ if [[ -n "${RUBYOPT:-""}" ]] ; then ruby_options="$RUBYOPT" ; fi
286
+
287
+ unset RUBYOPT
288
+
289
+ # Check for clang if the flag is set
290
+ __rvm_check_for_clang
291
+ result="$?"
292
+
293
+ [[ $result -gt 0 ]] && return $result
294
+
295
+ case "$rvm_ruby_interpreter" in
296
+ macruby)
297
+ if [[ "Darwin" = "$(uname)" ]] ; then
298
+
299
+ if [[ "$rvm_head_flag" = 1 ]] ; then
300
+
301
+ if [[ -n "$rvm_llvm_flag" ]] ; then
302
+ "$rvm_path/scripts/package" llvm install
303
+ fi
304
+
305
+ macruby_path="/usr/local/bin"
306
+ # TODO: configure & make variables should be set here.
307
+ rvm_ruby_configure=" true "
308
+ rvm_ruby_make="rake"
309
+ rvm_ruby_make_install="sudo rake install"
310
+
311
+ __rvm_db "${rvm_ruby_interpreter}_repo_url" "rvm_ruby_url"
312
+
313
+ rvm_ruby_repo_url=$rvm_ruby_url
314
+
315
+ __rvm_install_source $*
316
+ result=$?
317
+
318
+ if [[ "$result" -gt 0 ]] ; then
319
+ "$rvm_path/scripts/log" "error" \
320
+ "There has been an error while trying to install from source. \
321
+ \nHalting the installation."
322
+ return $result
323
+ fi
324
+
325
+ elif [[ "nightly" = "$rvm_ruby_version" ]] ; then
326
+ macruby_path="/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/bin"
327
+ # TODO: Separated nightly from head.
328
+
329
+ "$rvm_path/scripts/log" "info" "Retrieving the latest nightly macruby build..."
330
+
331
+ "$rvm_path/scripts/fetch" "$rvm_ruby_url"
332
+ result=$?
333
+
334
+ if [[ "$result" -gt 0 ]] ; then
335
+ "$rvm_path/scripts/log" "error" \
336
+ "There has been an error while trying to fetch the source. \
337
+ \nHalting the installation."
338
+ return $result
339
+ fi
340
+
341
+ mv "${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly-latest.pkg" \
342
+ "$rvm_archives_path/macruby_nightly.pkg"
343
+
344
+ __rvm_run "macruby/extract" \
345
+ "sudo /usr/sbin/installer -pkg '${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly.pkg' -target '/'"
346
+
347
+ mkdir -p "$rvm_ruby_home/bin"
348
+
349
+ else
350
+ macruby_path="/Library/Frameworks/MacRuby.framework/Versions/${rvm_ruby_version}/usr/bin"
351
+
352
+ # TODO: Separated nightly from head.
353
+ "$rvm_path/scripts/log" "info" "Retrieving MacRuby ${rvm_ruby_version} ..."
354
+
355
+ "$rvm_path/scripts/fetch" "$rvm_ruby_url"
356
+
357
+ result=$?
358
+
359
+ if [[ "$result" -gt 0 ]] ; then
360
+ "$rvm_path/scripts/log" "error" \
361
+ "There has been an error while trying to fetch the source. Halting the installation."
362
+ return $result
363
+ fi
364
+
365
+ mkdir -p ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string
366
+
367
+ unzip -o -j "${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file" \
368
+ "MacRuby ${rvm_ruby_version}/MacRuby ${rvm_ruby_version}.pkg" \
369
+ -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
370
+
371
+ mv "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/MacRuby ${rvm_ruby_version}.pkg" \
372
+ "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/$rvm_ruby_string.pkg"
373
+
374
+ __rvm_run "macruby/extract" \
375
+ "sudo /usr/sbin/installer -pkg '${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/$rvm_ruby_string.pkg' -target '/'"
376
+
377
+ mkdir -p "$rvm_ruby_home/bin"
378
+ fi
379
+
380
+ binaries=(erb gem irb rake rdoc ri ruby testrb)
381
+ for binary_name in ${binaries[@]}; do
382
+ # TODO: This should be generated via an external script.
383
+ ruby_wrapper=$(cat <<RubyWrapper
384
+ #!/usr/bin/env bash
385
+
386
+ export GEM_HOME="$rvm_ruby_gem_home"
387
+ export GEM_PATH="$rvm_ruby_gem_path"
388
+ export MY_RUBY_HOME="$rvm_ruby_home"
389
+ export PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin:$rvm_ruby_home/bin:\$PATH"
390
+
391
+ exec "$macruby_path/mac$binary_name" "\$@"
392
+ RubyWrapper
393
+ )
394
+
395
+ file_name="$rvm_ruby_home/bin/$binary_name"
396
+
397
+ if [[ -f "$file_name" ]] ; then
398
+ rm -f "$file_name"
399
+ fi
400
+
401
+ echo "$ruby_wrapper" > "$file_name"
402
+
403
+ if [[ -f "$file_name" ]] ; then
404
+ chmod +x $file_name
405
+ fi
406
+
407
+ if [[ "$binary_name" = "ruby" ]] ; then
408
+ echo "$ruby_wrapper" \
409
+ > "${rvm_bin_path:-"$rvm_bin_path/bin"}/$rvm_ruby_string"
410
+ fi
411
+ done ; unset binaries
412
+
413
+ __rvm_irbrc
414
+
415
+ else
416
+ "$rvm_path/scripts/log" "fail" \
417
+ "MacRuby can only be installed on a Darwin OS."
418
+ fi
419
+ ;;
420
+
421
+ ree)
422
+ if [[ -n "$(echo "$rvm_ruby_version" | awk '/^1\.8/')" \
423
+ && $rvm_head_flag -eq 0 ]] ; then
424
+
425
+ rvm_ruby_url="$(__rvm_db "ree_${rvm_ruby_version}_url")/$rvm_ruby_package_file.tar.gz"
426
+
427
+ "$rvm_path/scripts/log" "info" \
428
+ "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home"
429
+
430
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}"
431
+
432
+ if [[ ${rvm_force_flag:-0} -eq 0 \
433
+ && -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \
434
+ && ! -x "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/installer" ]] ; then
435
+
436
+ "$rvm_path/scripts/log" \
437
+ "It appears that the archive has already been extracted. Skipping extract (use --force to force re-download and extract)."
438
+
439
+ else
440
+ "$rvm_path/scripts/log" \
441
+ "$rvm_ruby_string - #fetching ($rvm_ruby_package_file)"
442
+
443
+ "$rvm_path/scripts/fetch" \
444
+ "$rvm_ruby_url"
445
+ result=$?
446
+
447
+ if [[ "$result" -gt 0 ]] ; then
448
+ "$rvm_path/scripts/log" "error" \
449
+ "There has been an error while trying to fetch the source. \
450
+ \nHalting the installation."
451
+ return $result
452
+ fi
453
+
454
+ rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
455
+
456
+ __rvm_run "extract" \
457
+ "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
458
+ "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
459
+ result=$?
460
+
461
+ if [[ "$result" -gt 0 ]] ; then
462
+ "$rvm_path/scripts/log" "error" \
463
+ "There has been an error while trying to extract the source. Halting the installation."
464
+ return $result
465
+ fi
466
+
467
+ mv "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_package_file" \
468
+ "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
469
+ fi
470
+
471
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
472
+
473
+ # wait, what? v v v TODO: Investigate line smell.
474
+ mkdir -p "${rvm_ruby_home}/lib/ruby/gems/1.8/gems"
475
+
476
+ if [[ -n "$rvm_configure_flags" ]] ; then
477
+ rvm_configure_flags="${rvm_configure_flags//--/-c --}"
478
+ fi
479
+
480
+ if [[ "Darwin" = "$(uname)" && "1.8.6" = "$rvm_ruby_version" \
481
+ && -z "$rvm_ree_options" ]] ; then
482
+ rvm_ree_options="${rvm_ree_options} --no-tcmalloc"
483
+ fi
484
+
485
+ __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
486
+
487
+ __rvm_apply_patches "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/source"
488
+ result=$?
489
+
490
+ if [[ "$result" -gt 0 ]] ; then
491
+ "$rvm_path/scripts/log" "error" \
492
+ "There has been an error while trying to apply patches to ree. \
493
+ \nHalting the installation."
494
+ return $result
495
+ fi
496
+
497
+ __rvm_run "install" \
498
+ "./installer -a $rvm_path/rubies/$rvm_ruby_string $rvm_ree_options $db_configure_flags $rvm_configure_flags" "$rvm_ruby_string - #installing "
499
+
500
+ result=$?
501
+
502
+ if [[ "$result" -gt 0 ]] ; then
503
+ "$rvm_path/scripts/log" "error" \
504
+ "There has been an error while trying to run the ree installer. Halting the installation."
505
+ return $result
506
+ fi
507
+
508
+ chmod +x "$rvm_ruby_home"/bin/*
509
+
510
+ __rvm_rubygems_setup
511
+ __rvm_irbrc
512
+ __rvm_bin_script
513
+ __rvm_post_install
514
+ else
515
+
516
+ __rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_repo_url" "rvm_ruby_url"
517
+
518
+ if [[ -z "$rvm_ruby_url" ]] ; then
519
+ "$rvm_path/scripts/log" "fail" \
520
+ "rvm does not know the rvm repo url for '${rvm_ruby_interpreter}_${rvm_ruby_version}'"
521
+ result=1
522
+
523
+ else
524
+ rvm_ruby_repo_url="$rvm_ruby_url"
525
+ if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi
526
+ __rvm_install_source $*
527
+ fi
528
+ fi
529
+ ;;
530
+
531
+ rbx|rubinius)
532
+
533
+ "$rvm_path/scripts/log" "info" "$rvm_ruby_string installing #dependencies "
534
+
535
+ # Ensure we have a 1.8.7 compatible ruby installed.
536
+ __rvm_ensure_has_18_compat_ruby || return 1
537
+
538
+ # TODO: use 'rvm gems load' here:
539
+ unset CFLAGS LDFLAGS ARCHFLAGS # Important.
540
+
541
+ unset BUNDLE_PATH GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
542
+
543
+ __rvm_remove_rvm_from_path
544
+
545
+ __rvm_conditionally_add_bin_path ; export PATH
546
+
547
+ builtin hash -r
548
+
549
+ if [[ -n "$(printf $rvm_ruby_version | awk '/^1\./')" \
550
+ && ${rvm_head_flag:-0} -eq 0 ]] ; then
551
+
552
+ "$rvm_path/scripts/log" "info" \
553
+ "$rvm_ruby_string #downloading ($rvm_ruby_package_file), this may take a while depending on your connection..."
554
+
555
+ "$rvm_path/scripts/fetch" "$rvm_ruby_url"
556
+ result=$?
557
+
558
+ if [[ "$result" -gt 0 ]] ; then
559
+ "$rvm_path/scripts/log" "error" \
560
+ "There has been an error while trying to fetch the source. Halting the installation."
561
+ return $result
562
+ fi
563
+ __rvm_run "extract" \
564
+ "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$(basename $rvm_ruby_package_file)\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
565
+ "$rvm_ruby_string - #extracting"
566
+ result=$?
567
+
568
+ if [[ "$result" -gt 0 ]] ; then
569
+ "$rvm_path/scripts/log" "error" \
570
+ "There has been an error while trying to extract the source. \
571
+ \nHalting the installation."
572
+ return $result
573
+ fi
574
+
575
+ # Remove the left over folder first.
576
+ rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
577
+
578
+ mv "${rvm_src_path:-"$rvm_path/src"}/rubinius-${rvm_ruby_version}" \
579
+ "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
580
+ else
581
+ __rvm_db "rubinius_repo_url" "rvm_ruby_repo_url"
582
+ #rvm_ruby_home="$rvm_path/rubies/$rvm_ruby_interpreter-$rvm_ruby_version"
583
+ __rvm_fetch_from_github "rbx"
584
+ result=$?
585
+
586
+ if [[ "$result" -gt 0 ]] ; then
587
+ "$rvm_path/scripts/log" "error" \
588
+ "There has been an error while fetching the rbx git repo. \
589
+ \nHalting the installation."
590
+ return $result
591
+ fi
592
+ fi
593
+
594
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
595
+
596
+ chmod +x ./configure
597
+
598
+ __rvm_apply_patches
599
+ result=$?
600
+
601
+ if [[ "$result" -gt 0 ]] ; then
602
+ "$rvm_path/scripts/log" "error" \
603
+ "There has been an error while trying to apply patches to rubinius. \
604
+ \nHalting the installation."
605
+ return $result
606
+ fi
607
+
608
+ __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
609
+
610
+ export ruby="$(__rvm_18_compat_ruby)"
611
+
612
+ rvm_configure_flags="${rvm_configure_flags:-"--skip-system"}"
613
+
614
+ rvm_ruby_configure="$rvm_path/wrappers/$ruby/ruby ./configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_configure_flags"
615
+ message="$rvm_ruby_string - #configuring"
616
+
617
+ if [[ "$rvm_llvm_flag" = "0" ]] ; then
618
+ rvm_ruby_configure="$rvm_ruby_configure --disable-llvm"
619
+
620
+ else
621
+ if [[ "$rvm_ruby_patch_level" = "rc1" ]] ; then
622
+ rvm_ruby_configure="$rvm_ruby_configure --enable-llvm"
623
+ fi
624
+ fi
625
+
626
+ __rvm_run "configure" "$rvm_ruby_configure" "$message"
627
+ result=$?
628
+
629
+ if [[ "$result" -gt 0 ]] ; then
630
+ "$rvm_path/scripts/log" "error" \
631
+ "There has been an error while running '$rvm_ruby_configure'. \
632
+ \nHalting the installation."
633
+ return $result
634
+ fi
635
+
636
+ if [[ "$rvm_trace_flag" -eq 1 ]] ; then
637
+ rvm_ruby_make="$rvm_path/wrappers/$ruby/rake install --trace"
638
+ message="$rvm_ruby_string - #compiling (with --trace)"
639
+ else
640
+ rvm_ruby_make="$rvm_path/wrappers/$ruby/rake install"
641
+ message="$rvm_ruby_string - #compiling"
642
+ fi
643
+
644
+ __rvm_run "rake" "$rvm_ruby_make" "$message"
645
+ result=$?
646
+
647
+ if [[ "$result" -gt 0 ]] ; then
648
+ "$rvm_path/scripts/log" "error" \
649
+ "There has been an error while running '$rvm_ruby_configure'. \
650
+ \nHalting the installation."
651
+ return $result
652
+ fi ; unset ruby
653
+
654
+ # Symlink rubinius wrappers
655
+ ln -fs "$rvm_ruby_home/bin/rbx" "$rvm_ruby_home/bin/ruby"
656
+
657
+ # Install IRB Wrapper on Rubinius.
658
+ file_name="$rvm_ruby_home/bin/irb"
659
+
660
+ rm -f "$file_name"
661
+
662
+ printf '#!/usr/bin/env bash\n' > "$file_name"
663
+
664
+ printf "exec '$rvm_ruby_home/bin/rbx' 'irb' \"\$@\"\n" >> "$file_name"
665
+
666
+ [[ -f "$file_name" ]] && chmod +x "$file_name"
667
+
668
+ # Install Gem Wrapper on Rubinius.
669
+ file_name="$rvm_ruby_home/bin/gem"
670
+
671
+ cp -f "$rvm_ruby_home/lib/bin/gem.rb" "$file_name"
672
+
673
+ __rvm_inject_ruby_shebang "$file_name"
674
+
675
+ if [[ -f "$file_name" ]] ; then
676
+ chmod +x "$file_name"
677
+ fi
678
+
679
+ unset file_name
680
+
681
+ binaries=(erb ri rdoc)
682
+
683
+ __rvm_post_install
684
+
685
+ __rvm_irbrc
686
+
687
+ __rvm_bin_script
688
+ ;;
689
+
690
+ jruby)
691
+
692
+ if ! command -v java > /dev/null; then
693
+ printf "java must be installed and in PATH in order to install JRuby."
694
+ return 1
695
+ fi
696
+
697
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}"
698
+
699
+ __rvm_fetch_ruby
700
+ result=$?
701
+
702
+ if [[ "$result" -gt 0 ]] ; then
703
+ "$rvm_path/scripts/log" "error" \
704
+ "There has been an error while trying to fetch the source. \
705
+ \nHalting the installation."
706
+ return $result
707
+ fi
708
+
709
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
710
+
711
+ if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
712
+
713
+ __rvm_apply_patches
714
+
715
+ __rvm_run "ant.dist" "ant dist" "$rvm_ruby_string - #ant dist"
716
+
717
+ fi
718
+
719
+ mkdir -p "$rvm_ruby_home/bin/"
720
+
721
+ case "$rvm_ruby_version" in
722
+ 1.3|1.2)
723
+ __rvm_run "nailgun" \
724
+ "builtin cd \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/tool/nailgun\" && make $rvm_make_flags" \
725
+ "Building Nailgun"
726
+ ;;
727
+ *)
728
+ __rvm_run "nailgun" \
729
+ "builtin cd \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/tool/nailgun\" && ./configure --prefix=$rvm_ruby_home && make $rvm_make_flags" \
730
+ "Building Nailgun"
731
+ ;;
732
+ esac
733
+
734
+ if [[ -z "${rvm_ruby_home:-""}" || "$rvm_ruby_home" = "/" ]] ; then
735
+ echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000
736
+ fi
737
+
738
+ rm -rf "$rvm_ruby_home"
739
+
740
+ __rvm_run "install" \
741
+ "/bin/cp -Rf ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string $rvm_ruby_home" "$rvm_ruby_string - #installing to $rvm_ruby_home"
742
+
743
+ (
744
+ builtin cd "$rvm_ruby_home/bin/"
745
+ for binary in jirb jruby jgem ; do
746
+ ln -nfs "$binary" "${binary#j}"
747
+ done ; unset binary
748
+ )
749
+
750
+ # -server is "a lot slower for short-lived scripts like rake tasks, and takes longer to load"
751
+ #sed -e 's#^JAVA_VM=-client#JAVA_VM=-server#' $rvm_ruby_home/bin/jruby > $rvm_ruby_home/bin/jruby.new &&
752
+ # mv $rvm_ruby_home/bin/jruby.new $rvm_ruby_home/bin/jruby
753
+ chmod +x "$rvm_ruby_home/bin/jruby"
754
+
755
+ binaries=(jrubyc jirb_swing jirb jgem rdoc ri spec autospec testrb ast generate_yaml_index.rb)
756
+
757
+ for binary in "${binaries[@]}" ; do
758
+ __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
759
+ done
760
+
761
+ __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/rake"
762
+
763
+ __rvm_rubygems_setup
764
+
765
+ __rvm_irbrc
766
+
767
+ __rvm_bin_script
768
+
769
+ __rvm_use
770
+
771
+ __rvm_post_install
772
+
773
+ # jruby ships with some built in gems, copy them in to place.
774
+ if [[ -d "$rvm_ruby_home/lib/ruby/gems/1.8" ]]; then
775
+
776
+ "$rvm_path/scripts/log" "info" "Copying across included gems"
777
+
778
+ cp -R "$rvm_ruby_home/lib/ruby/gems/1.8/" "$rvm_ruby_gem_home/"
779
+ fi
780
+ ;;
781
+
782
+ maglev)
783
+ __rvm_ensure_has_18_compat_ruby
784
+
785
+ "$rvm_path/scripts/log" "info" \
786
+ "Running MagLev prereqs checking script."
787
+
788
+ "$rvm_path/scripts/maglev"
789
+ result=$?
790
+
791
+ if [[ "$result" -gt 0 ]] ; then
792
+ "$rvm_path/scripts/log" "error" \
793
+ "Prerequisite checks have failed. Halting the installation."
794
+ return $result
795
+ fi
796
+
797
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}"
798
+
799
+ if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \
800
+ || ${rvm_force_flag:-0} -eq 1 ]] ; then
801
+
802
+ rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/" \
803
+ "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/"
804
+
805
+ __rvm_fetch_ruby
806
+ result=$?
807
+
808
+ if [[ "$result" -gt 0 ]] ; then
809
+ "$rvm_path/scripts/log" "error" \
810
+ "There has been an error while trying to fetch the source. \
811
+ \nHalting the installation."
812
+ return $result
813
+ fi
814
+ fi
815
+
816
+ if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
817
+
818
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
819
+
820
+ rvm_gemstone_package_file="GemStone-$(\grep ^GEMSTONE version.txt | cut -f2 -d-).$(uname -sm | \tr ' ' '-')"
821
+
822
+ rvm_gemstone_url="${rvm_gemstone_url:-"$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"}"
823
+ fi
824
+
825
+ "$rvm_path/scripts/log" "info" \
826
+ "Downloading the GemStone package, this may take a while depending on your connection..."
827
+
828
+ "$rvm_path/scripts/fetch" "$rvm_gemstone_url"
829
+ result=$?
830
+
831
+ if [[ "$result" -gt 0 ]] ; then
832
+ "$rvm_path/scripts/log" "error" \
833
+ "There has been an error while trying to fetch the GemStone package. \
834
+ \nHalting the installation."
835
+ return $result
836
+ fi
837
+
838
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}"
839
+
840
+ if [[ -s "$rvm_ruby_package_file" ]] ; then
841
+ mv "$rvm_ruby_package_file" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
842
+ fi
843
+
844
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
845
+
846
+ __rvm_run "gemstone.extract" \
847
+ "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/${rvm_gemstone_package_file}.${rvm_archive_extension}\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
848
+ result=$?
849
+
850
+ if [[ "$result" -gt 0 ]] ; then
851
+ "$rvm_path/scripts/log" "error" \
852
+ "There has been an error while trying to extract the GemStone package. \
853
+ \nHalting the installation."
854
+ return $result
855
+ fi
856
+
857
+ chmod -R 777 "$rvm_gemstone_package_file" # for now. # WTF?! Crack.smoke!(:huff)
858
+
859
+ ln -nfs "$rvm_gemstone_package_file" "gemstone"
860
+
861
+ if [[ -z "${rvm_ruby_home:-""}" || "$rvm_ruby_home" = "/" ]] ; then
862
+ echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000
863
+ else
864
+ rm -rf $rvm_ruby_home
865
+ fi
866
+
867
+ __rvm_run "install" \
868
+ "/bin/cp -Rf ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string $rvm_ruby_home" \
869
+ "Installing maglev to $rvm_ruby_home"
870
+
871
+ (
872
+ builtin cd "$rvm_ruby_home/bin/"
873
+
874
+ for binary in maglev-irb maglev-ruby maglev-gem ; do
875
+
876
+ ln -nfs "$binary" "${binary#maglev-}"
877
+
878
+ done ; unset binary
879
+ )
880
+
881
+ binaries=(maglev-ruby maglev-irb maglev-gem)
882
+
883
+ for binary in "${binaries[@]}" ; do
884
+
885
+ __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
886
+
887
+ done
888
+
889
+ builtin cd "$rvm_ruby_home"
890
+
891
+ if [[ $rvm_head_flag -eq 1 ]] ; then
892
+
893
+ git submodule update --init
894
+
895
+ "$rvm_ruby_home/bin/maglev" force-reload
896
+
897
+ ln -sf maglev.demo.key-$(uname -sm | \tr ' ' '-') etc/maglev.demo.key
898
+ fi
899
+
900
+ #ln -fs "$rvm_ruby_home/$(echo $rvm_gemstone_package_file | awk -F'.' '{print $1}')" "$rvm_ruby_home/gemstone"
901
+
902
+ compatible_ruby="$(__rvm_18_compat_ruby)"
903
+
904
+ if [[ ! -e ${rvm_ruby_home}/etc/conf.d/maglev.conf ]] ; then
905
+ "$rvm_path/scripts/log" "info" "Creating default 'maglev' repository."
906
+ "$rvm_path/wrappers/$compatible_ruby/rake" "stone:create[maglev]" >/dev/null 2>&1
907
+ fi
908
+
909
+ "$rvm_path/scripts/log" "info" "Generating maglev HTML documentation"
910
+ "$rvm_path/wrappers/$compatible_ruby/rake" rdoc >/dev/null 2>&1
911
+
912
+ "$rvm_path/scripts/log" "info" "Generating smalltalk FFI."
913
+ "$rvm_path/wrappers/$compatible_ruby/rake" stwrappers >/dev/null 2>&1
914
+
915
+ unset compatible_ruby
916
+
917
+ # TODO: Figure out if anything needs to be done with rubygems.
918
+ #__rvm_rubygems_setup
919
+ __rvm_irbrc
920
+
921
+ __rvm_bin_script
922
+
923
+ __rvm_use
924
+ ;;
925
+
926
+ ironruby|ir)
927
+ if ! command -v mono > /dev/null ; then
928
+ printf "mono must be installed and in your path in order to install IronRuby." ; return 1
929
+ fi
930
+
931
+ if [[ $rvm_head_flag -eq 1 ]] ; then
932
+
933
+ mono_version="$(mono -V | head -n 1 | cut -d ' ' -f5)"
934
+
935
+ if "$rvm_path/scripts/match" "$mono_version" "([0-9]+)\.([0-9]+)\.?([0-9]+)?" ; then
936
+
937
+ mono_major_ver="$(echo "$mono_version" | cut -d '.' -f1)"
938
+
939
+ mono_minor_ver="$(echo "$mono_version" | cut -d '.' -f2)"
940
+
941
+ if [[ $mono_major_ver -lt 2 ]] \
942
+ || ( [[ $mono_major_ver -eq 2 && $mono_minor_ver -lt 6 ]] ) ; then
943
+ printf "Mono 2.6 (or greater) must be installed and in your path in order to build IronRuby from the repository."
944
+ printf "Version detected: ${mono_version}"
945
+ return 1
946
+ fi
947
+ else
948
+ printf "Cannot recognize mono version."
949
+ return 1
950
+ fi
951
+
952
+ __rvm_ensure_has_18_compat_ruby
953
+
954
+ __rvm_fetch_ruby
955
+
956
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
957
+
958
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
959
+
960
+ compatible_ruby="$(__rvm_18_compat_ruby)"
961
+
962
+ "$rvm_path/wrappers/$compatible_ruby/gem" install pathname2 --no-rdoc --no-ri
963
+
964
+ # MONO_LIB=/Library/Frameworks/Mono.framework/Versions/current/lib/
965
+ rvm_ruby_make="$rvm_path/wrappers/$compatible_ruby/rake MERLIN_ROOT=\"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main\" compile mono=1 configuration=release --trace"
966
+ __rvm_run "rake" "$rvm_ruby_make" "Building IronRuby..."
967
+ unset compatible_ruby
968
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
969
+
970
+ rm -rf "$rvm_ruby_home"/*
971
+ mkdir -p "$rvm_ruby_home/bin" "$rvm_ruby_home/lib" \
972
+ "$rvm_ruby_home/lib/ruby" "$rvm_ruby_home/lib/IronRuby"
973
+
974
+ cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Bin/mono_release"/* "$rvm_ruby_home/bin/"
975
+ cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Languages/Ruby/Scripts/bin"/* "$rvm_ruby_home/bin/"
976
+ cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby"/* "$rvm_ruby_home/lib/ruby"
977
+ cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Languages/Ruby/Libs"/* "$rvm_ruby_home/lib/IronRuby"
978
+ else
979
+ "$rvm_path/scripts/log" "info" \
980
+ "Retrieving IronRuby"
981
+
982
+ "$rvm_path/scripts/fetch" "$rvm_ruby_url" \
983
+ "$rvm_ruby_package_file"
984
+ result=$?
985
+
986
+ if [[ "$result" -gt 0 ]] ; then
987
+ "$rvm_path/scripts/log" "error" \
988
+ "There has been an error while trying to fetch the source. Halting the installation."
989
+ return $result
990
+ fi
991
+
992
+ mkdir -p "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" "$rvm_ruby_home"
993
+
994
+ unzip -o -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \
995
+ "${rvm_archives_path:-"$rvm_path/archives"}/${rvm_ruby_package_file}" >> \
996
+ "${rvm_log_path:-"$rvm_path/log"}$rvm_ruby_string/extract.log" 2>> \
997
+ "${rvm_log_path:-"$rvm_path/log"}$rvm_ruby_string/extract.error.log"
998
+ result=$?
999
+
1000
+ if [[ "$result" -gt 1 ]] ; then
1001
+
1002
+ "$rvm_path/scripts/log" "error" \
1003
+ "There has been an error while trying to extract $rvm_ruby_package_file. \
1004
+ \nHalting the installation."
1005
+ return $result
1006
+
1007
+ fi
1008
+
1009
+ for dir in bin lib silverlight ; do
1010
+ cp -Rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/$dir" "$rvm_ruby_home/$dir"
1011
+ done
1012
+ fi
1013
+
1014
+ binaries=(gem irb rdoc rake ri ruby)
1015
+
1016
+ for binary_name in "${binaries[@]}" ; do
1017
+
1018
+ if [[ -s "$rvm_ruby_home/bin/$binary_name" ]] ; then
1019
+
1020
+ tr -d '\r' < "$rvm_ruby_home/bin/$binary_name" > "$rvm_ruby_home/bin/$binary_name.new"
1021
+
1022
+ #sed -e '1,1s=.*=#!'"/usr/bin/env ir=" "$rvm_ruby_home/bin/$binary_name" > "$rvm_ruby_home/bin/$binary_name.new"
1023
+ mv -f "$rvm_ruby_home/bin/$binary_name.new" "$rvm_ruby_home/bin/$binary_name"
1024
+
1025
+ chmod +x "$rvm_ruby_home/bin/$binary_name"
1026
+
1027
+ fi
1028
+ done ; unset binaries
1029
+
1030
+ sed -e '1,1s=.*=#!'"/usr/bin/env bash=" "$rvm_ruby_home/bin/ir" \
1031
+ | \tr -d '\r' > "$rvm_ruby_home/bin/ir.new"
1032
+
1033
+ mv -f "$rvm_ruby_home/bin/ir.new" "$rvm_ruby_home/bin/ir"
1034
+
1035
+ chmod +x "$rvm_ruby_home/bin/ir"
1036
+
1037
+ ln -fs "$rvm_ruby_home/bin/ir" "$rvm_ruby_home/bin/ruby"
1038
+
1039
+ builtin hash -r
1040
+
1041
+ __rvm_run "gems.install" \
1042
+ "PATH=\"$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin:$rvm_ruby_home/bin:$PATH\" GEM_HOME=\"$rvm_ruby_gem_home\" GEM_PATH=\"$rvm_ruby_gem_home:$rvm_ruby_global_gems_path\" $rvm_ruby_home/bin/gem install --no-rdoc --no-ri rake $rvm_gem_options" \
1043
+ "Installing $rvm_gem_name to $dir"
1044
+ ;;
1045
+
1046
+ mput|shyouhei)
1047
+
1048
+ if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi
1049
+
1050
+ unset BUNDLE_PATH GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
1051
+
1052
+ __rvm_remove_rvm_from_path
1053
+
1054
+ __rvm_conditionally_add_bin_path ; export PATH
1055
+
1056
+ builtin hash -r
1057
+
1058
+ rvm_ruby_home="$rvm_path/rubies/$rvm_ruby_interpreter-$rvm_ruby_version"
1059
+
1060
+ __rvm_fetch_from_github "mput" "trunk"
1061
+
1062
+ __rvm_apply_patches ; result=$?
1063
+
1064
+ if [[ "$result" -gt 0 ]] ; then
1065
+ "$rvm_path/scripts/log" "error" \
1066
+ "There has been an error while trying to apply patches to mput. \
1067
+ \nHalting the installation."
1068
+ return $result
1069
+ fi
1070
+
1071
+ if [[ ! -s "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/configure" ]] ; then
1072
+
1073
+ if command -v autoconf &> /dev/null ; then
1074
+
1075
+ __rvm_run "autoconf" "autoconf" "Running autoconf"
1076
+
1077
+ else
1078
+ "$rvm_path/scripts/log" "fail" \
1079
+ "rvm expects autoconf to install this ruby interpreter, autoconf was not found in PATH. \
1080
+ \nHalting installation."
1081
+ return $result
1082
+ fi
1083
+ fi
1084
+
1085
+ if [[ -s ./Makefile ]] && [[ -z "$rvm_reconfigure_flag" ]] ; then
1086
+
1087
+ if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
1088
+ "$rvm_path/scripts/log" "debug" \
1089
+ "Skipping configure step, Makefile exists so configure must have already been run."
1090
+ fi
1091
+
1092
+ elif [[ -n "$rvm_ruby_configure" ]] ; then
1093
+
1094
+ __rvm_run "configure" "$rvm_ruby_configure"
1095
+ result=$?
1096
+
1097
+ if [[ "$result" -gt 0 ]] ; then
1098
+ "$rvm_path/scripts/log" "error" \
1099
+ "There has been an error while trying to configure the source. \
1100
+ \nHalting the installation."
1101
+ return $result
1102
+ fi
1103
+
1104
+ elif [[ -s ./configure ]] ; then
1105
+ local configure_command="./configure --prefix=$rvm_ruby_home $rvm_configure_flags"
1106
+
1107
+ __rvm_run "configure" "" \
1108
+ "Configuring $rvm_ruby_string using $rvm_configure_flags, this may take a while depending on your cpu(s)..."
1109
+ result=$?
1110
+
1111
+ if [[ "$result" -gt 0 ]] ; then
1112
+ "$rvm_path/scripts/log" "error" \
1113
+ "There has been an error while trying to configure the source.\
1114
+ \nHalting the installation."
1115
+ return $result
1116
+ fi
1117
+
1118
+ else
1119
+ "$rvm_path/scripts/log" "error" \
1120
+ "Skipping configure step, 'configure' script does not exist, did autoconf not run successfully?"
1121
+ fi
1122
+
1123
+ rvm_ruby_make=${rvm_ruby_make:-"make"}
1124
+
1125
+ __rvm_run "make" "$rvm_ruby_make $rvm_make_flags" \
1126
+ "Compiling $rvm_ruby_string, this may take a while depending on your cpu(s)..."
1127
+ result=$?
1128
+
1129
+ if [[ "$result" -gt 0 ]] ; then
1130
+ "$rvm_path/scripts/log" "error" \
1131
+ "There has been an error while trying to run make.\
1132
+ \nHalting the installation."
1133
+ return $result
1134
+ fi
1135
+
1136
+ rvm_ruby_make_install=${rvm_ruby_make_install:-"make install"}
1137
+
1138
+ __rvm_run "install" "$rvm_ruby_make_install" "Installing $rvm_ruby_string"
1139
+ result=$?
1140
+
1141
+ if [[ "$result" -gt 0 ]] ; then
1142
+ "$rvm_path/scripts/log" "error" \
1143
+ "There has been an error while trying to run make install. \
1144
+ \nHalting the installation."
1145
+ return $result
1146
+ fi
1147
+
1148
+ "$rvm_path/scripts/log" "info" \
1149
+ "Installation of $rvm_ruby_string is complete."
1150
+
1151
+ export GEM_HOME="$rvm_ruby_gem_home"
1152
+ export GEM_PATH="$rvm_ruby_gem_path"
1153
+ export BUNDLE_PATH="$rvm_ruby_gem_home"
1154
+
1155
+ __rvm_rubygems_setup
1156
+
1157
+ __rvm_bin_script
1158
+
1159
+ __rvm_run "chmod.bin" "chmod +x $rvm_ruby_home/bin/*"
1160
+
1161
+ __rvm_post_install
1162
+ ;;
1163
+
1164
+ ruby)
1165
+
1166
+ __rvm_check_for_bison # && Run like hell...
1167
+ if [[ $? -gt 0 ]] ; then return $result ; fi
1168
+
1169
+ if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi
1170
+
1171
+ ( __rvm_install_source $* )
1172
+ result=$?
1173
+ ;;
1174
+
1175
+ default)
1176
+ "$rvm_path/scripts/log" "fail" \
1177
+ "a ruby interpreter to install must be specified and not simply 'default'."
1178
+ ;;
1179
+
1180
+ *) "$rvm_path/scripts/log" "fail" \
1181
+ "Ruby interpreter '$rvm_ruby_interpreter' is not known."
1182
+
1183
+ esac
1184
+
1185
+ rvm_hook="after_install" ; source "$rvm_path/scripts/hook"
1186
+
1187
+ if [[ -n "$ruby_options" ]] ; then
1188
+ RUBYOPT="$ruby_options"
1189
+ export RUBYOPT
1190
+ fi
1191
+
1192
+ return ${result:-0}
1193
+ }
1194
+
1195
+ __rvm_fetch_from_github()
1196
+ {
1197
+ rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1198
+
1199
+ if [[ ! -d "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string/.git" ]] ; then
1200
+
1201
+ rm -rf "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string"
1202
+
1203
+ builtin cd "$rvm_home"
1204
+
1205
+ __rvm_run "$1.repo" \
1206
+ "git clone --depth 1 $rvm_ruby_repo_url ${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" \
1207
+ "Cloning $rvm_ruby_repo_url"
1208
+ result=$?
1209
+
1210
+ if [[ "$result" -gt 0 ]] ; then
1211
+ rvm_ruby_repo_http_url="${rvm_ruby_repo_url//git:/http:}"
1212
+
1213
+ "$rvm_path/scripts/log" "info" "Could not fetch $rvm_ruby_repo_url - trying $rvm_ruby_repo_http_url"
1214
+
1215
+ __rvm_run "$1.repo" "git clone --depth 1 $rvm_ruby_repo_http_url ${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" "Cloning $rvm_ruby_repo_http_url"
1216
+ fi
1217
+ else
1218
+ local branch="${2:-"master"}"
1219
+
1220
+ builtin cd "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string"
1221
+
1222
+ __rvm_run "$1.repo" "git pull origin $branch" "Pulling from origin $branch"
1223
+ fi
1224
+
1225
+ __rvm_run "$1.copy" "\\cp -R \"${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string\" \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string\"" "Copying from repo to source..."
1226
+
1227
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1228
+
1229
+ return ${result:-0}
1230
+ }
1231
+
1232
+ __rvm_fetch_ruby()
1233
+ {
1234
+ [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] && __rvm_select
1235
+
1236
+ "$rvm_path/scripts/log" "info" "$rvm_ruby_string - #fetching "
1237
+
1238
+ if [[ ${rvm_head_flag:-0} -eq 0 && -z "${rvm_ruby_tag:-""}" && -z "${rvm_ruby_revision:-""}" ]] ; then
1239
+
1240
+ rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_string"}"
1241
+
1242
+ rvm_ruby_package_file="${rvm_ruby_package_file:-"$rvm_ruby_package_name"}"
1243
+
1244
+ if [[ "ruby" = "$rvm_ruby_interpreter" ]]; then
1245
+ rvm_archive_extension="${rvm_archive_extension:-tar.bz2}"
1246
+ else
1247
+ rvm_archive_extension="${rvm_archive_extension:-tar.gz}"
1248
+ fi
1249
+
1250
+ if [[ ! -s "${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension" ]] ; then
1251
+
1252
+ case "$rvm_ruby_interpreter" in
1253
+ ruby)
1254
+ rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_release_version}.${rvm_ruby_major_version}_url")/$rvm_ruby_package_file.$rvm_archive_extension"
1255
+ ;;
1256
+ ree)
1257
+ rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_url")/${rvm_ruby_package_file}.${rvm_archive_extension}"
1258
+ ;;
1259
+ jruby)
1260
+ rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_url")/${rvm_ruby_version}/${rvm_ruby_package_file}.${rvm_archive_extension}"
1261
+ ;;
1262
+ maglev)
1263
+ : # Should already be set from selector
1264
+ ;;
1265
+ *)
1266
+ rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_url")/${rvm_ruby_package_file}.${rvm_archive_extension}"
1267
+ ;;
1268
+ esac
1269
+
1270
+ "$rvm_path/scripts/log" "info" \
1271
+ "$rvm_ruby_string - #downloading ${rvm_ruby_package_file}, this may take a while depending on your connection..."
1272
+
1273
+ "$rvm_path/scripts/fetch" "${rvm_ruby_url}"
1274
+ result=$?
1275
+
1276
+ if [[ "$result" -gt 0 ]] ; then
1277
+ "$rvm_path/scripts/log" "error" \
1278
+ "There has been an error while trying to fetch the source. \
1279
+ \nHalting the installation."
1280
+ return $result
1281
+ fi
1282
+ fi
1283
+
1284
+ if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \
1285
+ || ${rvm_force_flag:-0} -eq 1 ]] ; then
1286
+
1287
+ if [[ -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" ]] ; then
1288
+ # Especially when forced, we want to ensure the destination is missing.
1289
+ rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1290
+ fi
1291
+
1292
+ mkdir -p "/tmp/rvm_src_$$"
1293
+
1294
+ case "$rvm_archive_extension" in
1295
+ tar.gz|tgz)
1296
+ __rvm_run "extract" "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C /tmp/rvm_src_$$" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1297
+ result=$?
1298
+
1299
+ if [[ "$result" -gt 0 ]] ; then
1300
+ "$rvm_path/scripts/log" "error" \
1301
+ "There has been an error while trying to extract the source. \
1302
+ \nHalting the installation."
1303
+ return $result
1304
+ fi
1305
+ ;;
1306
+ zip)
1307
+ __rvm_run "extract" "unzip -q -o ${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file -d /tmp/rvm_src_$$"
1308
+ result=$?
1309
+
1310
+ if [[ "$result" -gt 0 ]] ; then
1311
+ "$rvm_path/scripts/log" "error" \
1312
+ "There has been an error while trying to extract $rvm_ruby_package_file. \
1313
+ \nHalting the installation."
1314
+ return $result
1315
+ fi
1316
+ ;;
1317
+ tar.bz2)
1318
+ __rvm_run "extract" "bunzip2 < '${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension' | tar xf - -C /tmp/rvm_src_$$" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1319
+ result=$?
1320
+
1321
+ if [[ "$result" -gt 0 ]] ; then
1322
+ "$rvm_path/scripts/log" "error" \
1323
+ "There has been an error while trying to extract the source. \
1324
+ \nHalting the installation."
1325
+ return $result
1326
+ fi
1327
+ ;;
1328
+ *)
1329
+ "$rvm_path/scripts/log" "error" \
1330
+ "Unknown archive format extension '$rvm_archive_extension'. \
1331
+ \nHalting the installation."
1332
+ return 1
1333
+ ;;
1334
+ esac
1335
+
1336
+ mv "/tmp/rvm_src_$$/$(builtin cd /tmp/rvm_src_$$ ; ls)" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" ; rm -rf "/tmp/rvm_src_$$"
1337
+
1338
+ if [[ -n "${rvm_ruby_name:-""}" && -d "${rvm_src_path:-"$rvm_path/src"}/$(echo $rvm_ruby_string | sed -e 's/-n.*//')" ]] ; then
1339
+ mv "${rvm_src_path:-"$rvm_path/src"}/$(echo "$rvm_ruby_string" | sed -e 's/-n.*//')" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1340
+ fi
1341
+
1342
+ "$rvm_path/scripts/log" "info" \
1343
+ "$rvm_ruby_string - #extracted to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1344
+
1345
+ else
1346
+ "$rvm_path/scripts/log" "info" \
1347
+ "$rvm_ruby_string - #extracted to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string (already extracted)"
1348
+ fi
1349
+
1350
+ return 0
1351
+ else
1352
+
1353
+ mkdir -p "${rvm_repo_path:-"$rvm_path/repos"}"
1354
+
1355
+ if [[ -n "$(echo "$rvm_ruby_url" | awk '/^git/')" ]] ; then
1356
+
1357
+ if [[ -d "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string/.git" ]] ; then
1358
+
1359
+ builtin cd "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string"
1360
+
1361
+ if [[ -z "$rvm_ruby_revision" ]] ; then
1362
+
1363
+ "$rvm_path/scripts/log" "info" \
1364
+ "Pulling from $rvm_ruby_repo_url, this may take a while depending on your connection..."
1365
+
1366
+ git pull origin master --force
1367
+
1368
+ result=$?
1369
+
1370
+ if [[ "$result" -gt 0 ]] ; then
1371
+ "$rvm_path/scripts/log" "error" \
1372
+ "There has been an error while trying to update the source from the remote repository. \
1373
+ \nHalting the installation."
1374
+ return $result
1375
+ fi
1376
+
1377
+ else
1378
+ if [[ -z "${rvm_ruby_sha:-""}" ]] ; then
1379
+ git checkout HEAD
1380
+ else
1381
+ git checkout $(echo "$rvm_ruby_sha" | sed 's#^s##')
1382
+ fi
1383
+ result=$?
1384
+
1385
+ if [[ "$result" -gt 0 ]] ; then
1386
+ "$rvm_path/scripts/log" "error" \
1387
+ "There has been an error while trying to checkout the source branch. \
1388
+ \nHalting the installation."
1389
+ return $result
1390
+ fi
1391
+ fi
1392
+
1393
+ else
1394
+ rm -rf "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string"
1395
+
1396
+ rvm_ruby_repo_http_url="${rvm_ruby_repo_url//git:/http:/}"
1397
+
1398
+ "$rvm_path/scripts/log" "info" \
1399
+ "Cloning from $rvm_ruby_repo_url, this may take a while depending on your connection..."
1400
+
1401
+ git clone --depth 1 "$rvm_ruby_repo_url" \
1402
+ "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string"
1403
+ result=$?
1404
+
1405
+ if [[ "$result" -gt 0 ]] ; then
1406
+ "$rvm_path/scripts/log" "info" \
1407
+ "cloning from $rvm_ruby_repo_url failed, now attempting to clone from $rvm_ruby_repo_http_url, this may take a while depending on your connection..."
1408
+
1409
+ git clone "$rvm_ruby_repo_http_url" \
1410
+ "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string"
1411
+ result=$?
1412
+
1413
+ if [[ "$result" -gt 0 ]] ; then
1414
+ "$rvm_path/scripts/log" "error" \
1415
+ "There has been an error while trying to fetch the repository. \
1416
+ \nHalting the installation."
1417
+ return $result
1418
+ fi
1419
+ fi
1420
+ fi
1421
+
1422
+ else
1423
+ if [[ -n "${rvm_ruby_tag:-""}" ]] ; then
1424
+ # TODO: Check if tag v is valid
1425
+ rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/tags/$(echo "$rvm_ruby_tag" | sed 's/^t//')"}"
1426
+
1427
+ elif [[ -z "${rvm_ruby_version:-""}" && ${rvm_head_flag:-0} -eq 1 ]] ; then
1428
+ rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/trunk"}"
1429
+
1430
+ elif [[ "${rvm_ruby_major_version:-""}" = "9" ]] ; then
1431
+
1432
+ if [[ -z "${rvm_ruby_minor_version:-""}" || "${rvm_ruby_minor_version:-""}" = 3 ]] ; then
1433
+ rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/trunk"}"
1434
+
1435
+ else
1436
+ rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/branches/ruby_${rvm_ruby_release_version}_${rvm_ruby_major_version}_${rvm_ruby_minor_version}"}"
1437
+ fi
1438
+
1439
+ elif [[ -z "${rvm_ruby_minor_version:-""}" || "${rvm_ruby_major_version:-""}.${rvm_ruby_minor_version:-""}" = "8.8" ]] ; then
1440
+ rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/branches/ruby_${rvm_ruby_release_version}_${rvm_ruby_major_version}"}"
1441
+
1442
+ else
1443
+ rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/branches/ruby_${rvm_ruby_release_version}_${rvm_ruby_major_version}_${rvm_ruby_minor_version}"}"
1444
+ fi
1445
+
1446
+ rvm_rev=""
1447
+
1448
+ if [[ -n "${rvm_ruby_revision:-""}" ]] ; then
1449
+ rvm_rev="-$rvm_ruby_revision"
1450
+ fi
1451
+
1452
+ if [[ -d "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string/.svn" ]] ; then
1453
+
1454
+ builtin cd "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string"
1455
+
1456
+ "$rvm_path/scripts/log" "info" "Updating ruby from $rvm_ruby_url"
1457
+
1458
+ __rvm_run "svn.switch" "svn switch $rvm_ruby_url"
1459
+
1460
+ __rvm_run "svn.update" "svn update"
1461
+
1462
+ if [[ -n "${rvm_rev:-""}" ]] ; then
1463
+ "$rvm_path/scripts/log" "info" "Checking out revision ${rvm_rev/-r/-r } from $rvm_ruby_url"
1464
+
1465
+ __rvm_run "svn.checkout" "svn update -q ${rvm_rev/-r/-r }"
1466
+ fi
1467
+ else
1468
+ rm -rf "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string"
1469
+
1470
+ __rvm_run "svn.checkout" \
1471
+ "svn checkout -q ${rvm_rev/-r/-r } $rvm_ruby_url ${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" \
1472
+ "Downloading source from ${rvm_ruby_url}."
1473
+ fi
1474
+ result=$?
1475
+
1476
+ if [[ "$result" -gt 0 ]] ; then
1477
+ "$rvm_path/scripts/log" "error" \
1478
+ "There has been an error while trying to fetch / update the source. \
1479
+ \nHalting the installation."
1480
+ return $result
1481
+ fi
1482
+ fi
1483
+
1484
+ "$rvm_path/scripts/log" "info" "Copying from repo to src path..."
1485
+
1486
+ rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1487
+
1488
+ cp -R "${rvm_repos_path:-"$rvm_path/repos"}/$rvm_ruby_string" \
1489
+ "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
1490
+ fi
1491
+
1492
+ return ${result:-0}
1493
+ }
1494
+
1495
+ __rvm_check_default()
1496
+ {
1497
+ local default_ruby_interpreter current_ruby_interpreter
1498
+
1499
+ default_ruby_interpreter="$(rvm alias show default 2>/dev/null \
1500
+ | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
1501
+
1502
+ current_ruby_interpreter="$(echo "$rvm_ruby_string" \
1503
+ | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
1504
+
1505
+ if [[ -n "$current_ruby_interpreter" \
1506
+ && "$current_ruby_interpreter" = "$default_ruby_interpreter" ]]; then
1507
+
1508
+ __rvm_run_with_env 'default.restore' 'system' \
1509
+ 'rvm use system --default' 'Removing default ruby interpreter'
1510
+
1511
+ fi
1512
+
1513
+ return $?
1514
+ }
1515
+
1516
+ __rvm_uninstall_ruby()
1517
+ {
1518
+ local dir
1519
+
1520
+ if [[ ${rvm_ruby_selected_flag} -eq 0 ]] ; then __rvm_select ; fi
1521
+
1522
+ if [[ -n "${rvm_ruby_string:-""}" ]] ; then
1523
+
1524
+ for dir in "$rvm_path/rubies" ; do
1525
+
1526
+ if [[ -d "$dir/$rvm_ruby_string" ]] ; then
1527
+
1528
+ "$rvm_path/scripts/log" "info" "Removing $dir/$rvm_ruby_string..."
1529
+
1530
+ rm -rf $dir/$rvm_ruby_string
1531
+
1532
+ else
1533
+
1534
+ "$rvm_path/scripts/log" "info" \
1535
+ "$dir/$rvm_ruby_string has already been removed."
1536
+
1537
+ fi
1538
+
1539
+ if [[ -e "${rvm_bin_path:-"$rvm_path/bin"}/$rvm_ruby_string" ]] ; then
1540
+
1541
+ rm -f "${rvm_bin_path:-"$rvm_path/bin"}/$rvm_ruby_string"
1542
+
1543
+ fi
1544
+
1545
+ done
1546
+
1547
+ __rvm_remove_install_record "$rvm_ruby_string"
1548
+
1549
+ __rvm_remove_gemsets
1550
+
1551
+ __rvm_check_default
1552
+
1553
+ else
1554
+
1555
+ "$rvm_path/scripts/log" "fail" \
1556
+ "Cannot uninstall unknown package '$rvm_ruby_string'"
1557
+
1558
+ fi
1559
+
1560
+ unset rvm_uninstall_flag
1561
+
1562
+ return 0
1563
+ }
1564
+
1565
+ __rvm_remove_ruby()
1566
+ {
1567
+ local dir
1568
+
1569
+ if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
1570
+
1571
+ if [[ -n "${rvm_ruby_string:-""}" ]] ; then
1572
+
1573
+ for dir in ${rvm_src_path:-"$rvm_path/src"} $rvm_path/rubies ; do
1574
+
1575
+ if [[ -d $dir/$rvm_ruby_string ]] ; then
1576
+
1577
+ "$rvm_path/scripts/log" "info" "Removing $dir/$rvm_ruby_string..."
1578
+
1579
+ rm -rf "$dir/$rvm_ruby_string"
1580
+
1581
+ else
1582
+
1583
+ "$rvm_path/scripts/log" "info" \
1584
+ "it seems that $dir/$rvm_ruby_string is already non existent."
1585
+
1586
+ fi
1587
+
1588
+ if [[ -e "${rvm_bin_path:-"$rvm_path/bin"}/$rvm_ruby_string" ]] ; then
1589
+
1590
+ rm -f "${rvm_bin_path:-"$rvm_path/bin"}/$rvm_ruby_string"
1591
+
1592
+ fi
1593
+
1594
+ __rvm_check_default
1595
+
1596
+ done
1597
+
1598
+ __rvm_remove_install_record "$rvm_ruby_string"
1599
+ __rvm_remove_gemsets
1600
+ __rvm_remove_archives
1601
+ __rvm_remove_aliases
1602
+ __rvm_remove_wrappers
1603
+ __rvm_remove_environments
1604
+ __rvm_remove_binaries
1605
+
1606
+ else
1607
+
1608
+ "$rvm_path/scripts/log" "fail" \
1609
+ "Cannot remove unknown package '$rvm_ruby_string'"
1610
+
1611
+ return 1
1612
+
1613
+ fi
1614
+
1615
+ unset rvm_remove_flag
1616
+
1617
+ return 0
1618
+ }
1619
+
1620
+ __rvm_remove_gemsets()
1621
+ {
1622
+ local gemset gemsets
1623
+
1624
+ if [[ ${rvm_gems_flag:-0} -eq 1 ]] ; then
1625
+
1626
+ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string gemsets..."
1627
+
1628
+ gemsets=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}"/ ; \
1629
+ find . -maxdepth 1 -mindepth 1 -type d))
1630
+
1631
+ for gemset in "${gemsets[@]//.\/}" ; do
1632
+
1633
+ if [[ -d "$gemset" ]] ; then
1634
+
1635
+ rm -rf "$gemset"
1636
+
1637
+ fi
1638
+
1639
+ done
1640
+
1641
+ fi
1642
+ }
1643
+
1644
+ __rvm_remove_wrappers()
1645
+ {
1646
+ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string wrappers..."
1647
+
1648
+ local wrapper wrappers
1649
+
1650
+ wrappers=($(find "$rvm_path/wrappers" -maxdepth 1 -mindepth 1 -type d -iname "*$rvm_ruby_string*" 2>/dev/null))
1651
+
1652
+ for wrapper in "${wrappers[@]}" ; do
1653
+
1654
+ rm -rf "$wrapper"
1655
+
1656
+ done
1657
+
1658
+ return 0
1659
+ }
1660
+
1661
+ __rvm_remove_environments()
1662
+ {
1663
+ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string environments..."
1664
+
1665
+ local environments environment
1666
+
1667
+ environments=($(find "$rvm_path/environments" -maxdepth 1 -mindepth 1 -type f -iname "*$rvm_ruby_string*" ))
1668
+
1669
+ for environment in "${environments[@]}" ; do
1670
+ if [[ -d "$environment" ]] ; then
1671
+ rm -rf "$environment"
1672
+ fi
1673
+ done
1674
+
1675
+ return 0
1676
+ }
1677
+
1678
+ __rvm_remove_aliases()
1679
+ {
1680
+ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string aliases..."
1681
+
1682
+ local alias_name aliases
1683
+
1684
+ aliases=($(awk '/'$rvm_ruby_string'/' "$rvm_path/config/alias" | sed 's/=.*//'))
1685
+
1686
+ for alias_name in "${aliases[@]}" ; do
1687
+ # Remove from alias key-value store
1688
+ "$rvm_path/scripts/alias" delete "$alias_name" >/dev/null 2>&1
1689
+ done
1690
+ }
1691
+
1692
+ __rvm_remove_archives()
1693
+ {
1694
+ if [[ ${rvm_archive_flag:-0} -eq 1 ]] ; then
1695
+
1696
+ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string archives..."
1697
+
1698
+ rm -f "${rvm_archives_path:-"$rvm_path/archives"}/${rvm_ruby_package_file}.${rvm_archive_extension}"
1699
+ fi
1700
+ }
1701
+
1702
+ __rvm_remove_binaries()
1703
+ {
1704
+ "$rvm_path/scripts/log" "info" "Removing $rvm_ruby_string binaries..."
1705
+
1706
+ # Iterate over all binaries and check for symlinked wrappers etc.
1707
+ local binary_name binaries full_patch_path
1708
+
1709
+ binaries=($(find "${rvm_bin_path:-"$rvm_path/bin"}" -maxdepth 1 -mindepth 1 -type f -iname "*$rvm_ruby_string*" ))
1710
+
1711
+ for binary_name in "${binaries[@]}" ; do
1712
+
1713
+ full_binary_path="${rvm_bin_path:-"$rvm_path/bin"}/$binary_name"
1714
+
1715
+ if [[ -L "$full_binary_path" ]] \
1716
+ && "$rvm_path/scripts/match" "$(readlink "$full_binary_path")" "$rvm_ruby_string"; then
1717
+ rm -f "$full_binary_path"
1718
+ fi
1719
+ done ; unset binaries
1720
+
1721
+ return 0
1722
+ }
1723
+
1724
+ __rvm_post_install()
1725
+ {
1726
+ local rvm_ruby_aliases ruby_alias binary
1727
+
1728
+ if [[ "$rvm_ruby_interpreter" != "jruby" ]] ; then
1729
+
1730
+ if [[ ${#binaries[@]} -lt 1 ]] ; then
1731
+ binaries=(gem irb erb ri rdoc testrb rake)
1732
+ fi
1733
+
1734
+ "$rvm_path/scripts/log" "info" \
1735
+ "$rvm_ruby_string - adjusting #shebangs for ($binaries)."
1736
+
1737
+ for binary in "${binaries[@]}" ; do
1738
+
1739
+ if [[ -e "$rvm_ruby_home/bin/$binary" \
1740
+ || -e "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/$binary" ]] ; then
1741
+
1742
+ if [[ "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" != "$rvm_ruby_home" \
1743
+ && -f "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/$binary" ]] ; then
1744
+
1745
+ cp -f "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/$binary" "$rvm_ruby_home/bin/$binary"
1746
+
1747
+ elif [[ -f "$rvm_ruby_gem_home/bin/$binary" ]] ; then
1748
+
1749
+ cp -f "$rvm_ruby_gem_home/bin/$binary" "$rvm_ruby_home/bin/$binary"
1750
+ fi
1751
+
1752
+ __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
1753
+
1754
+ __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/$binary"
1755
+
1756
+ chmod +x "$rvm_ruby_home/bin/$binary"
1757
+ fi
1758
+ done
1759
+
1760
+ binaries=(gem irb erb ri rdoc testrb rake)
1761
+ fi
1762
+
1763
+ # Import the initial gemsets.
1764
+ __rvm_run_with_env "gemsets.initial" "$rvm_ruby_string" \
1765
+ "'$rvm_path/scripts/gemsets' initial" \
1766
+ "$rvm_ruby_string - #importing default gemsets ($rvm_path/gemsets/)"
1767
+
1768
+ __rvm_irbrc
1769
+
1770
+ __rvm_generate_default_docs
1771
+
1772
+ if [[ -n "$rvm_ruby_aliases" ]]; then
1773
+ "$rvm_path/scripts/log" "info" "Setting up aliases for $rvm_ruby_string"
1774
+
1775
+ while read -r ruby_alias; do
1776
+
1777
+ "$rvm_path/scripts/log" info "Aliasing $rvm_ruby_string to $ruby_alias"
1778
+
1779
+ "$rvm_path/scripts/alias" delete "$ruby_alias" > /dev/null 2>&1
1780
+
1781
+ "$rvm_path/scripts/alias" create "$ruby_alias" "$rvm_ruby_string" > /dev/null 2>&1
1782
+
1783
+ done < <(echo "$rvm_ruby_string" | \tr ' ' '\n' | sort -u)
1784
+ fi
1785
+ }
1786
+
1787
+ __rvm_generate_default_docs()
1788
+ {
1789
+ if [[ "$rvm_docs_flag" = "1" && "$rvm_ruby_interpreter" != "macruby" ]]; then
1790
+
1791
+ __rvm_run_with_env "docs.generate" "$rvm_ruby_string" \
1792
+ "rvm docs generate-ri" "Attempting to generate ri documentation..."
1793
+ fi
1794
+ }
1795
+
1796
+ __rvm_rubygems_setup()
1797
+ {
1798
+ local home path dir directory_name version_number ruby_lib_gem_path
1799
+
1800
+ if [[ -n "$(echo "$rvm_ruby_version" | awk '/^1\.9/')" \
1801
+ || -n "$(echo "$rvm_ruby_interpreter" | awk '/^mput/')" ]] ; then
1802
+ install=0
1803
+
1804
+ elif [[ "$rvm_ruby_string" = "ruby-head" ]] ; then
1805
+ install=0
1806
+
1807
+ else
1808
+ install=1
1809
+ fi
1810
+
1811
+ __rvm_use
1812
+
1813
+ if [[ "$install" -eq 0 ]] ; then
1814
+ # 1.9.X has it's own built-in gem command
1815
+ __rvm_inject_ruby_shebang "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/gem"
1816
+
1817
+ __rvm_inject_gem_env "$rvm_ruby_home/bin/gem"
1818
+
1819
+ cp "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/gem" "$rvm_ruby_home/bin/gem"
1820
+
1821
+ home="$GEM_HOME" ; path="$GEM_PATH" # Save
1822
+
1823
+ for dir in $rvm_ruby_global_gems_path $rvm_ruby_gem_home ; do
1824
+
1825
+ export GEM_HOME="$dir" ; export GEM_PATH="$dir" ; export BUNDLE_PATH="$dir"
1826
+
1827
+ __rvm_run "rubygems.update" \
1828
+ "$rvm_ruby_home/bin/gem update --system" "$rvm_ruby_string - updating #rubygems for $dir"
1829
+
1830
+ done
1831
+
1832
+ GEM_HOME="$home" ; GEM_PATH="$path" ; BUNDLE_PATH="$home"
1833
+ export GEM_HOME GEM_PATH BUNDLE_PATH
1834
+
1835
+ __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/gem"
1836
+
1837
+ __rvm_inject_gem_env "$rvm_ruby_home/bin/gem"
1838
+
1839
+ directory_name="$rvm_ruby_home/lib/ruby/gems"
1840
+
1841
+ version_number="${rvm_ruby_release_version}.${rvm_ruby_major_version}"
1842
+
1843
+ if [[ "$version_number" == "." ]]; then
1844
+
1845
+ # TODO: Investigate this if statement, something feels not quite right.
1846
+ version_number="$(builtin cd "$directory_name" ; \
1847
+ find . -maxdepth 1 -mindepth 1 -type f \
1848
+ | \grep '^[[:digit:]].[[:digit:]]\(.[[:digit:]]\)\?' | head -n1)"
1849
+ version_number="${version_number//.\/}"
1850
+
1851
+ if [[ -n "$version_number" ]]; then
1852
+ ruby_lib_gem_path="${directory_name}/${version_number}"
1853
+ else
1854
+ ruby_lib_gem_path=""
1855
+ fi
1856
+
1857
+ else
1858
+ ruby_lib_gem_path="${directory_name}/${version_number}"
1859
+ fi
1860
+
1861
+ elif [[ -n "$(echo "$rvm_ruby_interpreter" | awk '/^rbx|jruby/')" ]] ; then
1862
+
1863
+ # Hands off rubygems for rbx & jruby
1864
+ if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
1865
+ "$rvm_path/scripts/log" "debug" \
1866
+ "Skipping rubygems update for $rvm_ruby_version"
1867
+ fi
1868
+
1869
+ ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/jruby"
1870
+
1871
+ else
1872
+
1873
+ "$rvm_path/scripts/log" "info" \
1874
+ "$rvm_ruby_string - #rubygems installing to $rvm_ruby_string"
1875
+
1876
+ rvm_rubygems_version="$(__rvm_db "${rvm_ruby_interpreter}_rubygems_version")"
1877
+ rvm_rubygems_version="${rvm_rubygems_version:-"$(__rvm_db "rubygems_version")"}"
1878
+ rvm_rubygems_url=$(__rvm_db "rubygems_${rvm_rubygems_version}_url")
1879
+ rvm_gem_package_name="rubygems-$rvm_rubygems_version"
1880
+ rvm_gem_url="$rvm_rubygems_url/$rvm_gem_package_name.tgz"
1881
+
1882
+ # Sanity check... If setup.rb is missing from the rubygems source path,
1883
+ # something went wrong. Cleanup, aisle 3!
1884
+ if [[ ! -f "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name/setup.rb" ]]; then
1885
+ rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name"
1886
+ fi
1887
+
1888
+ if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name" ]] ; then
1889
+
1890
+ "$rvm_path/scripts/log" "info" "Retrieving $rvm_gem_package_name"
1891
+
1892
+ "$rvm_path/scripts/fetch" "$rvm_gem_url"
1893
+ result=$?
1894
+
1895
+ if [[ "$result" -gt 0 ]] ; then
1896
+ "$rvm_path/scripts/log" "error" \
1897
+ "There has been an error while trying to fetch the source. Halting the installation." ; return $result
1898
+ fi
1899
+
1900
+ if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name" ]] ; then
1901
+ mkdir -p "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name"
1902
+ fi
1903
+
1904
+ __rvm_run "rubygems.extract" \
1905
+ "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_gem_package_name.tgz\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
1906
+ "Extracting $rvm_gem_package_name ..."
1907
+ fi
1908
+
1909
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name"
1910
+
1911
+ __rvm_run "rubygems.install" \
1912
+ "GEM_PATH='$rvm_ruby_gem_path:$rvm_ruby_global_gems_path' GEM_HOME='$rvm_ruby_gem_home' BUNDLE_PATH='$rvm_ruby_gem_home' $rvm_ruby_home/bin/ruby ${rvm_src_path:-"$rvm_path/src"}/$rvm_gem_package_name/setup.rb"
1913
+ result=$?
1914
+
1915
+ if [[ $result -gt 0 ]] ; then
1916
+ "$rvm_path/scripts/log" "warning" \
1917
+ "$rvm_ruby_string - #warning Installation of rubygems $rvm_ruby_package_name did not complete successfully."
1918
+ fi
1919
+
1920
+ __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/gem"
1921
+
1922
+ if [[ -n "$rvm_ruby_major_version" ]] ; then
1923
+ ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/${rvm_ruby_release_version}.$rvm_ruby_major_version"
1924
+ else
1925
+ ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/$interpreter"
1926
+ fi
1927
+ fi
1928
+
1929
+ if [[ -n "$ruby_lib_gem_path" ]]; then
1930
+ # Add ruby's gem path to ruby's lib direcotry.
1931
+
1932
+ if [[ -d "$ruby_lib_gem_path" ]] ; then
1933
+ rm -rf "$ruby_lib_gem_path"
1934
+ fi
1935
+
1936
+ mkdir -p ${ruby_lib_gem_path%\/*}
1937
+
1938
+ ln -nfs "$rvm_ruby_gem_home" "$ruby_lib_gem_path"
1939
+
1940
+ fi
1941
+
1942
+ if [[ -s "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/rdoc" ]] ; then
1943
+ __rvm_inject_ruby_shebang "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/rdoc"
1944
+ fi
1945
+
1946
+ if [[ -s "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/rake" ]] ; then
1947
+ __rvm_inject_ruby_shebang "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/bin/rake"
1948
+ fi
1949
+
1950
+ return ${result:-0}
1951
+ }
1952
+
1953
+ __rvm_inject_ruby_shebang()
1954
+ {
1955
+ local actual_file
1956
+
1957
+ __rvm_actual_file $1
1958
+
1959
+ if [[ -f "$actual_file" ]] ; then
1960
+ sed -e '1,1s=.*=#!'"/usr/bin/env ruby=" ${actual_file} > "${actual_file}.new"
1961
+
1962
+ mv "${actual_file}.new" "${actual_file}" ; chmod +x "$actual_file"
1963
+ fi
1964
+ }
1965
+
1966
+ __rvm_inject_gem_env()
1967
+ {
1968
+ local actual_file string
1969
+
1970
+ __rvm_actual_file $1
1971
+
1972
+ if [[ -s "$actual_file" ]] ; then
1973
+
1974
+ if [[ -n "$(head -n 1 "$actual_file" | awk '/[j]*ruby/')" ]] ; then
1975
+
1976
+ string="ENV['GEM_HOME']=ENV['GEM_HOME'] || '$rvm_ruby_gem_home'\nENV['GEM_PATH']=ENV['GEM_PATH'] || '$rvm_ruby_gem_path'\nENV['PATH']='$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin:$rvm_ruby_home/bin:' + ENV['PATH']\nENV['BUNDLE_PATH']=ENV['BUNDLE_PATH'] || '$rvm_ruby_gem_home'\n"
1977
+
1978
+ elif [[ -n "$(head -n 1 "$actual_file" | awk '/bash/')" ]] ; then
1979
+
1980
+ string="GEM_HOME=\${GEM_HOME:-'$rvm_ruby_gem_home'}\nGEM_PATH=\${GEM_PATH:-'$rvm_ruby_gem_home:$rvm_ruby_global_gems_path'}\nPATH=$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin:$rvm_ruby_home/bin:\$PATH\nBUNDLE_PATH=\${BUNDLE_PATH:-'$rvm_ruby_gem_home'}\n"
1981
+
1982
+ fi
1983
+
1984
+ if [[ -n "$string" ]] ; then
1985
+
1986
+ awk "NR==2 {print \"$string\"} {print}" "$actual_file" \
1987
+ > "$actual_file.new"
1988
+
1989
+ mv $actual_file.new $actual_file ; chmod +x "$actual_file"
1990
+
1991
+ fi
1992
+ fi
1993
+
1994
+ return 0
1995
+ }
1996
+
1997
+ __rvm_actual_file()
1998
+ {
1999
+ if [[ -L "$1" ]] ; then # If the file is a symlink,
2000
+
2001
+ actual_file="$(readlink $1)" # read the link target so we can preserve it.
2002
+
2003
+ else
2004
+
2005
+ actual_file="$1"
2006
+
2007
+ fi
2008
+
2009
+ return 0
2010
+ }
2011
+
2012
+ __rvm_manage_rubies()
2013
+ {
2014
+ local manage_result bin_line
2015
+
2016
+ manage_result=0
2017
+
2018
+ rvm_gemset_name=""
2019
+ rvm_ruby_selected_flag=0
2020
+
2021
+ rvm_ruby_gem_home="${rvm_ruby_gem_home:-""//${rvm_gemset_separator:-"@"}*}"
2022
+ rvm_ruby_string="${rvm_ruby_string:-""//${rvm_gemset_separator:-"@"}*}"
2023
+
2024
+ # Given list of ruby strings.
2025
+ if [[ -n "${rubies_string:-""}" ]] ;then
2026
+
2027
+ for rvm_ruby_string in "${rubies_string//,/ }" ; do
2028
+ current_manage_ruby_string="$rvm_ruby_string"
2029
+
2030
+ eval "__rvm_${action}_ruby"
2031
+ result="$?"
2032
+
2033
+ if [[ "$result" -gt 0 && "$manage_result" = 0 ]]; then
2034
+ manage_result="$result"
2035
+ fi
2036
+
2037
+ if [[ "$result" = 0 && "$action" = "install" ]] ; then
2038
+ __rvm_record_install "$current_manage_ruby_string"
2039
+ fi
2040
+
2041
+ unset current_manage_ruby_string
2042
+
2043
+ __rvm_unset_ruby_variables
2044
+ done
2045
+
2046
+ else # all
2047
+
2048
+ if [[ "$action" != "install" && "$action" != "remove" \
2049
+ && "$action" != "uninstall" ]] ; then
2050
+
2051
+ local ruby_string
2052
+
2053
+ while read -r ruby_string
2054
+ do # Keep this on second line damnit!
2055
+
2056
+ if [[ -x "$ruby_string" ]] ; then
2057
+ rvm_ruby_string="$ruby_string"
2058
+
2059
+ eval "__rvm_${action}_ruby"
2060
+ result="$?"
2061
+
2062
+ if [[ "$result" -gt 0 && "$manage_result" = 0 ]]; then
2063
+ manage_result="$result"
2064
+ fi
2065
+
2066
+ # record as current_manage_string to prevent it being overridden.
2067
+ if [[ "$result" = 0 && "$action" = "install" ]] ; then
2068
+ __rvm_record_install "$ruby_string"
2069
+ fi
2070
+
2071
+ __rvm_unset_ruby_variables
2072
+ fi
2073
+ done < <(builtin cd "$rvm_path/rubies" ; \
2074
+ find . -maxdepth 1 -mindepth 1 -type d 2> /dev/null | sed -e 's#./##g')
2075
+
2076
+ else
2077
+ "$rvm_path/scripts/log" "warn" \
2078
+ 'Really? '"$action"' all? See "rvm list known" and limit the selection to something more sane please :)'
2079
+ fi
2080
+ fi
2081
+
2082
+ # TODO: This should return the exit status of the command that got called.
2083
+ return $manage_result
2084
+ }
2085
+
2086
+ args=($*)
2087
+ action="${args[0]:-""}"
2088
+ rubies_string="${args[1]:-""}"
2089
+ args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
2090
+ binaries=()
2091
+
2092
+ __rvm_manage_rubies
2093
+
2094
+ exit $?