-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
manage
executable file
·2125 lines (1480 loc) · 64.1 KB
/
manage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
original_ruby_version=${rvm_ruby_version:-""}
original_ruby_string=${rvm_ruby_string:-""}
source "$rvm_path/scripts/base"
source "$rvm_path/scripts/patches"
unset RUBYLIB RUBYOPT # Sanity check.
__rvm_check_for_clang()
{
if [[ -n "${rvm_clang_flag:-""}" ]] && ! command -v clang >/dev/null ; then
"$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"
return 1
fi
}
# Checks for bison, returns zero iff it is found
__rvm_check_for_bison()
{
if [[ ${rvm_head_flag:-0} -gt 0 ]]; then
command -v bison > /dev/null
result=$?
if [[ $result -gt 0 ]] ; then
"$rvm_path/scripts/log" "fail" \
"\nbison is not available in your path. \nPlease ensure bison is installed before compiling from head.\n"
fi
fi
return ${result:-0}
}
# Emits a number of patches to STDOUT, each on a new name
# Expands patchsets etc.
__rvm_current_patch_names()
{
# TODO: Lookup default patches on rvm_ruby_string heirarchy.
local separator patches level name
separator="%"
patches="${rvm_patch_names:-""} default"
for patch_name in $(echo ${patches//,/ }); do
level=1
name="$patch_name"
if echo "$name" | grep -q "$separator"; then
level="${name/*${separator}/}"
name="${name//${separator}*/}"
fi
local expanded_name="$(__rvm_expand_patch_name "$name")"
echo "${expanded_name}${separator}${level}"
done
return 0
}
__rvm_apply_patches()
{
local patches patch_name patch_level_separator patch_fuzziness patch_level source_directory full_patch_path
result=0
patch_level_separator="%"
patch_fuzziness="25"
patch_level=1
source_directory="${1:-""}"
if [[ -z "$source_directory" ]] ; then
source_directory="${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
fi
(
builtin cd "$source_directory"
patches=($(__rvm_current_patch_names))
for patch_name in "${patches[@]}" ; do
# If set, extract the patch level from the patch name.
patch_level=1
if echo "$patch_name" | \grep -q "$patch_level_separator"; then
patch_level=${patch_name//*${patch_level_separator}/}
patch_name="${patch_name//${patch_level_separator}*/}"
fi
full_patch_path="$(__rvm_lookup_full_patch_path "$patch_name")"
# Expand paths, and for those we found we then apply the patches.
if [[ -n "${full_patch_path:-""}" ]]; then
if [[ -f "$full_patch_path" ]] ; then
__rvm_run "patch.apply.${patch_name/*\/}" \
"patch -F$patch_fuzziness -p$patch_level -f <\"$full_patch_path\"" \
"Applying patch '$patch_name' (located at $full_patch_path)"
[[ $? -gt 0 ]] && result=1 # Detect failed patches
fi
else
"$rvm_path/scripts/log" "warn" \
"Patch '$patch_name' not found."
result=1
fi
done
)
return ${result:-0}
}
__rvm_install_source()
{
local directory configure_parameters db_configure_flags
[[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] && __rvm_select
case ${rvm_ruby_string:-""} in
ruby-head|1.9.*-head) __rvm_ensure_has_18_compat_ruby || return 1 ;;
esac
"$rvm_path/scripts/log" "info" \
"Installing Ruby from source to: $rvm_ruby_home, this may take a while depending on your cpu(s)...\n"
builtin cd "${rvm_src_path:-"$rvm_path/src"}"
if [[ ${rvm_force_flag:-0} -eq 1 ]] ; then
for directory in "$rvm_ruby_home" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" ; do
if [[ -d "$directory" ]] ; then
rm -rf "$directory"
fi
done
fi
result=0
__rvm_fetch_ruby
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error fetching the ruby interpreter. Halting the installation."
return $result
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
result=$? ; if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"Source directory is missing. Did the download or extraction fail? Halting the installation."
return $result
fi
if [[ -d "${rvm_path}/usr" ]] ; then
export PATH="${rvm_path}/usr/bin:${PATH}"
builtin hash -r
fi
__rvm_apply_patches
result="$?"
if [[ $result -gt 0 ]]; then
"$rvm_path/scripts/log" "fail" \
"There has been an error applying the specified patches. Halting the installation."
return $result
fi
if [[ -z "${rvm_ruby_configure:-""}" \
&& ! -s "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/configure" ]] ; then
if command -v autoconf > /dev/null ; then
__rvm_run "autoconf" "autoconf" "Running autoconf"
else
"$rvm_path/scripts/log" "fail" \
"rvm requires autoconf to install the selected ruby interpreter however autoconf was not found in the PATH."
return 1
fi
fi
if [[ -n "${rvm_ruby_configure:-""}" ]] ; then
__rvm_run "configure" "$rvm_ruby_configure"
result=$?
if [[ $result -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while configuring. Halting the installation."
return $result
fi
elif [[ -s ./configure ]] ; then
# REE stores configure flags differently for head vs. the distributed release.
if [[ "ree" != "${rvm_ruby_interpreter:-""}" ]]; then
__rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
fi
# On 1.9.2, we manually set the --with-baseruby option
# to point to an expanded path.
if [[ "${rvm_ruby_string:-""}" = "ruby-1.9.2-head" ]] ; then
local compatible_baseruby="$rvm_path/wrappers/$(__rvm_18_compat_ruby)/ruby"
if [[ -x "$compatible_baseruby" ]] ; then
configure_parameters="--with-baseruby=$compatible_baseruby"
fi
fi
local configure_command="./configure --prefix=$rvm_ruby_home ${db_configure_flags:-""} ${rvm_configure_flags:-""} ${configure_parameters:-""}"
__rvm_run "configure" "$configure_command" "$rvm_ruby_string - #configuring "
result=$?
if [[ $result -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while running configure. Halting the installation."
return $result
fi
else
"$rvm_path/scripts/log" "error" \
"Skipping configure step, 'configure' does not exist, did autoconf not run successfully?"
fi
rvm_ruby_make=${rvm_ruby_make:-"make"}
__rvm_run "make" "$rvm_ruby_make ${rvm_make_flags:-""}" "$rvm_ruby_string - #compiling "
result=$?
if [[ $result -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while running make. Halting the installation."
return $result
fi
if [[ -d .ext/rdoc ]] ; then
rm -rf .ext/rdoc
fi
rvm_ruby_make_install=${rvm_ruby_make_install:-"make install"}
__rvm_run "install" "$rvm_ruby_make_install" "$rvm_ruby_string - #installing "
result=$?
if [[ $result -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while running make install. Halting the installation."
return $result
fi
export GEM_HOME="$rvm_ruby_gem_home"
export GEM_PATH="$rvm_ruby_gem_path"
__rvm_rubygems_setup
result=$?
__rvm_bin_script
__rvm_run "chmod.bin" "chmod +x $rvm_ruby_home/bin/*"
__rvm_post_install
result=$?
"$rvm_path/scripts/log" "info" \
"Install of $rvm_ruby_string - #complete "
return ${result:-0}
}
__rvm_install_ruby()
{
if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
if [[ -n "${RUBYOPT:-""}" ]] ; then ruby_options="$RUBYOPT" ; fi
unset RUBYOPT
# Check for clang if the flag is set
__rvm_check_for_clang
result=$?
[[ $result -gt 0 ]] && return $result
case "$rvm_ruby_interpreter" in
macruby)
if [[ "Darwin" = "$(uname)" ]] ; then
if [[ "$rvm_head_flag" = 1 ]] ; then
if [[ -n "$rvm_llvm_flag" ]] ; then
"$rvm_path/scripts/package" llvm install
fi
macruby_path="/usr/local/bin"
# TODO: configure & make variables should be set here.
rvm_ruby_configure=" true "
rvm_ruby_make="rake"
rvm_ruby_make_install="sudo rake install"
__rvm_db "${rvm_ruby_interpreter}_repo_url" "rvm_ruby_url"
rvm_ruby_repo_url=$rvm_ruby_url
__rvm_install_source $*
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to install from source. \
\nHalting the installation."
return $result
fi
elif [[ "nightly" = "$rvm_ruby_version" ]] ; then
macruby_path="/Library/Frameworks/MacRuby.framework/Versions/0.8/usr/bin"
# TODO: Separated nightly from head.
"$rvm_path/scripts/log" "info" "Retrieving the latest nightly macruby build..."
"$rvm_path/scripts/fetch" "$rvm_ruby_url"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to fetch the source. \
\nHalting the installation."
return $result
fi
mv "${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly-latest.pkg" \
"${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly.pkg"
__rvm_run "macruby/extract" \
"sudo /usr/sbin/installer -pkg '${rvm_archives_path:-"$rvm_path/archives"}/macruby_nightly.pkg' -target '/'"
mkdir -p "$rvm_ruby_home/bin"
else
macruby_path="/Library/Frameworks/MacRuby.framework/Versions/${rvm_ruby_version}/usr/bin"
# TODO: Separated nightly from head.
"$rvm_path/scripts/log" "info" "Retrieving MacRuby ${rvm_ruby_version} ..."
"$rvm_path/scripts/fetch" "$rvm_ruby_url"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to fetch the source. Halting the installation."
return $result
fi
mkdir -p ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string
unzip -o -j "${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file" \
"MacRuby ${rvm_ruby_version}/MacRuby ${rvm_ruby_version}.pkg" \
-d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
mv "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/MacRuby ${rvm_ruby_version}.pkg" \
"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/$rvm_ruby_string.pkg"
__rvm_run "macruby/extract" \
"sudo /usr/sbin/installer -pkg '${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/$rvm_ruby_string.pkg' -target '/'"
mkdir -p "$rvm_ruby_home/bin"
fi
binaries=(erb gem irb rake rdoc ri ruby testrb)
for binary_name in ${binaries[@]}; do
# TODO: This should be generated via an external script.
ruby_wrapper=$(cat <<RubyWrapper
#!/usr/bin/env bash
export GEM_HOME="$rvm_ruby_gem_home"
export GEM_PATH="$rvm_ruby_gem_path"
export MY_RUBY_HOME="$rvm_ruby_home"
export PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin:$rvm_ruby_home/bin:\$PATH"
exec "$macruby_path/mac$binary_name" "\$@"
RubyWrapper
)
file_name="$rvm_ruby_home/bin/$binary_name"
if [[ -f "$file_name" ]] ; then
rm -f "$file_name"
fi
echo "$ruby_wrapper" > "$file_name"
if [[ -f "$file_name" ]] ; then
chmod +x $file_name
fi
if [[ "$binary_name" = "ruby" ]] ; then
echo "$ruby_wrapper" \
> "${rvm_bin_path:-"$rvm_bin_path/bin"}/$rvm_ruby_string"
fi
done ; unset binaries
__rvm_irbrc
else
"$rvm_path/scripts/log" "fail" \
"MacRuby can only be installed on a Darwin OS."
fi
;;
ree)
if [[ -n "$(echo "$rvm_ruby_version" | awk '/^1\.8/')" \
&& $rvm_head_flag -eq 0 ]] ; then
rvm_ruby_url="$(__rvm_db "ree_${rvm_ruby_version}_url")/$rvm_ruby_package_file.tar.gz"
"$rvm_path/scripts/log" "info" \
"Installing Ruby Enterprise Edition from source to: $rvm_ruby_home"
builtin cd "${rvm_src_path:-"$rvm_path/src"}"
if [[ ${rvm_force_flag:-0} -eq 0 \
&& -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \
&& ! -x "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/installer" ]] ; then
"$rvm_path/scripts/log" \
"It appears that the archive has already been extracted. Skipping extract (use --force to force re-download and extract)."
else
"$rvm_path/scripts/log" \
"$rvm_ruby_string - #fetching ($rvm_ruby_package_file)"
"$rvm_path/scripts/fetch" \
"$rvm_ruby_url"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to fetch the source. \
\nHalting the installation."
return $result
fi
rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
__rvm_run "extract" \
"gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
"$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to extract the source. Halting the installation."
return $result
fi
mv "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_package_file" \
"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
# wait, what? v v v TODO: Investigate line smell.
mkdir -p "${rvm_ruby_home}/lib/ruby/gems/1.8/gems"
if [[ -n "$rvm_configure_flags" ]] ; then
rvm_configure_flags="${rvm_configure_flags//--/-c --}"
fi
if [[ "Darwin" = "$(uname)" && "1.8.6" = "$rvm_ruby_version" \
&& -z "$rvm_ree_options" ]] ; then
rvm_ree_options="${rvm_ree_options} --no-tcmalloc"
fi
__rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
__rvm_apply_patches "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/source"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to apply patches to ree. \
\nHalting the installation."
return $result
fi
__rvm_run "install" \
"./installer -a $rvm_path/rubies/$rvm_ruby_string $rvm_ree_options $db_configure_flags $rvm_configure_flags" "$rvm_ruby_string - #installing "
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to run the ree installer. Halting the installation."
return $result
fi
chmod +x "$rvm_ruby_home"/bin/*
__rvm_rubygems_setup
__rvm_irbrc
__rvm_bin_script
__rvm_post_install
else
__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_repo_url" "rvm_ruby_url"
if [[ -z "$rvm_ruby_url" ]] ; then
"$rvm_path/scripts/log" "fail" \
"rvm does not know the rvm repo url for '${rvm_ruby_interpreter}_${rvm_ruby_version}'"
result=1
else
rvm_ruby_repo_url="$rvm_ruby_url"
if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi
__rvm_install_source $*
fi
fi
;;
rbx|rubinius)
"$rvm_path/scripts/log" "info" "$rvm_ruby_string installing #dependencies "
# Ensure we have a 1.8.7 compatible ruby installed.
__rvm_ensure_has_18_compat_ruby || return 1
# TODO: use 'rvm gems load' here:
unset CFLAGS LDFLAGS ARCHFLAGS # Important.
unset GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
__rvm_remove_rvm_from_path
__rvm_conditionally_add_bin_path ; export PATH
builtin hash -r
if [[ -n "$(printf "${rvm_ruby_version:-""}" | awk '/^1\./')" \
&& ${rvm_head_flag:-0} -eq 0 ]] ; then
"$rvm_path/scripts/log" "info" \
"$rvm_ruby_string #downloading ($rvm_ruby_package_file), this may take a while depending on your connection..."
"$rvm_path/scripts/fetch" "$rvm_ruby_url"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to fetch the source. Halting the installation."
return $result
fi
__rvm_run "extract" \
"gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/$(basename $rvm_ruby_package_file)\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
"$rvm_ruby_string - #extracting"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to extract the source. \
\nHalting the installation."
return $result
fi
# Remove the left over folder first.
rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
mv "${rvm_src_path:-"$rvm_path/src"}/rubinius-${rvm_ruby_version}" \
"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
else
__rvm_db "rubinius_repo_url" "rvm_ruby_repo_url"
#rvm_ruby_home="$rvm_path/rubies/$rvm_ruby_interpreter-$rvm_ruby_version"
__rvm_fetch_from_github "rbx"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while fetching the rbx git repo. \
\nHalting the installation."
return $result
fi
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
chmod +x ./configure
__rvm_apply_patches
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to apply patches to rubinius. \
\nHalting the installation."
return $result
fi
__rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
export ruby="$(__rvm_18_compat_ruby)"
rvm_configure_flags="${rvm_configure_flags:-"--skip-system"}"
rvm_ruby_configure="$rvm_path/wrappers/$ruby/ruby ./configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_configure_flags"
message="$rvm_ruby_string - #configuring"
if [[ "$rvm_llvm_flag" = "0" ]] ; then
rvm_ruby_configure="$rvm_ruby_configure --disable-llvm"
else
if [[ "$rvm_ruby_patch_level" = "rc1" ]] ; then
rvm_ruby_configure="$rvm_ruby_configure --enable-llvm"
fi
fi
__rvm_run "configure" "$rvm_ruby_configure" "$message"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while running '$rvm_ruby_configure'. \
\nHalting the installation."
return $result
fi
if [[ "$rvm_trace_flag" -eq 1 ]] ; then
rvm_ruby_make="$rvm_path/wrappers/$ruby/rake install --trace"
message="$rvm_ruby_string - #compiling (with --trace)"
else
rvm_ruby_make="$rvm_path/wrappers/$ruby/rake install"
message="$rvm_ruby_string - #compiling"
fi
__rvm_run "rake" "$rvm_ruby_make" "$message"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while running '$rvm_ruby_configure'.\nHalting the installation."
return $result
fi ; unset ruby
# Symlink rubinius wrappers
ln -fs "$rvm_ruby_home/bin/rbx" "$rvm_ruby_home/bin/ruby"
# Install IRB Wrapper on Rubinius.
file_name="$rvm_ruby_home/bin/irb"
rm -f "$file_name"
printf '#!/usr/bin/env bash\n' > "$file_name"
printf "exec '$rvm_ruby_home/bin/rbx' 'irb' \"\$@\"\n" >> "$file_name"
[[ -f "$file_name" ]] && chmod +x "$file_name"
# Install Gem Wrapper on Rubinius.
file_name="$rvm_ruby_home/bin/gem"
cp -f "$rvm_ruby_home/lib/bin/gem.rb" "$file_name"
__rvm_inject_ruby_shebang "$file_name"
if [[ -f "$file_name" ]] ; then
chmod +x "$file_name"
fi
unset file_name
binaries=(erb ri rdoc)
__rvm_post_install
__rvm_irbrc
__rvm_bin_script
;;
jruby)
if ! command -v java > /dev/null; then
printf "java must be installed and in PATH in order to install JRuby."
return 1
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}"
__rvm_fetch_ruby
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to fetch the source. \
\nHalting the installation."
return $result
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
__rvm_apply_patches
__rvm_run "ant.dist" "ant dist" "$rvm_ruby_string - #ant dist"
fi
mkdir -p "$rvm_ruby_home/bin/"
case "$rvm_ruby_version" in
1.3|1.2)
__rvm_run "nailgun" \
"builtin cd \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/tool/nailgun\" && make $rvm_make_flags" \
"Building Nailgun"
;;
*)
__rvm_run "nailgun" \
"builtin cd \"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/tool/nailgun\" && ./configure --prefix=$rvm_ruby_home && make $rvm_make_flags" \
"Building Nailgun"
;;
esac
if [[ -z "${rvm_ruby_home:-""}" || "$rvm_ruby_home" = "/" ]] ; then
echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000
fi
rm -rf "$rvm_ruby_home"
__rvm_run "install" \
"/bin/cp -Rf ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string $rvm_ruby_home" "$rvm_ruby_string - #installing to $rvm_ruby_home"
(
builtin cd "$rvm_ruby_home/bin/"
for binary in jirb jruby jgem ; do
ln -nfs "$binary" "${binary#j}"
done ; unset binary
)
# -server is "a lot slower for short-lived scripts like rake tasks, and takes longer to load"
#sed -e 's#^JAVA_VM=-client#JAVA_VM=-server#' $rvm_ruby_home/bin/jruby > $rvm_ruby_home/bin/jruby.new &&
# mv $rvm_ruby_home/bin/jruby.new $rvm_ruby_home/bin/jruby
chmod +x "$rvm_ruby_home/bin/jruby"
binaries=(jrubyc jirb_swing jirb jgem rdoc ri spec autospec testrb ast generate_yaml_index.rb)
for binary in "${binaries[@]}" ; do
__rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
done
__rvm_inject_ruby_shebang "$rvm_ruby_home/bin/rake"
__rvm_rubygems_setup
__rvm_irbrc
__rvm_bin_script
__rvm_use
__rvm_post_install
# jruby ships with some built in gems, copy them in to place.
if [[ -d "$rvm_ruby_home/lib/ruby/gems/1.8" ]]; then
"$rvm_path/scripts/log" "info" "Copying across included gems"
cp -R "$rvm_ruby_home/lib/ruby/gems/1.8/" "$rvm_ruby_gem_home/"
fi
;;
maglev)
__rvm_ensure_has_18_compat_ruby
"$rvm_path/scripts/log" "info" \
"Running MagLev prereqs checking script."
"$rvm_path/scripts/maglev"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"Prerequisite checks have failed. Halting the installation."
return $result
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}"
if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \
|| ${rvm_force_flag:-0} -eq 1 ]] ; then
rm -rf "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/" \
"${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/"
__rvm_fetch_ruby
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to fetch the source. \
\nHalting the installation."
return $result
fi
fi
if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
rvm_gemstone_package_file="GemStone-$(\grep ^GEMSTONE version.txt | cut -f2 -d-).$(uname -sm | \tr ' ' '-')"
rvm_gemstone_url="${rvm_gemstone_url:-"$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"}"
fi
"$rvm_path/scripts/log" "info" \
"Downloading the GemStone package, this may take a while depending on your connection..."
"$rvm_path/scripts/fetch" "$rvm_gemstone_url"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to fetch the GemStone package. \
\nHalting the installation."
return $result
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}"
if [[ -s "$rvm_ruby_package_file" ]] ; then
mv "$rvm_ruby_package_file" "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
__rvm_run "gemstone.extract" \
"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"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to extract the GemStone package. \
\nHalting the installation."
return $result
fi
chmod -R 777 "$rvm_gemstone_package_file" # for now. # WTF?! Crack.smoke!(:huff)
ln -nfs "$rvm_gemstone_package_file" "gemstone"
if [[ -z "${rvm_ruby_home:-""}" || "$rvm_ruby_home" = "/" ]] ; then
echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000
else
rm -rf $rvm_ruby_home
fi
__rvm_run "install" \
"/bin/cp -Rf ${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string $rvm_ruby_home" \
"Installing maglev to $rvm_ruby_home"
(
builtin cd "$rvm_ruby_home/bin/"
for binary in maglev-irb maglev-ruby maglev-gem ; do
ln -nfs "$binary" "${binary#maglev-}"
done ; unset binary
)
binaries=(maglev-ruby maglev-irb maglev-gem)
for binary in "${binaries[@]}" ; do
__rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
done
builtin cd "$rvm_ruby_home"
if [[ $rvm_head_flag -eq 1 ]] ; then
git submodule update --init
"$rvm_ruby_home/bin/maglev" force-reload
ln -sf maglev.demo.key-$(uname -sm | \tr ' ' '-') etc/maglev.demo.key
fi
#ln -fs "$rvm_ruby_home/$(echo $rvm_gemstone_package_file | awk -F'.' '{print $1}')" "$rvm_ruby_home/gemstone"
compatible_ruby="$(__rvm_18_compat_ruby)"
if [[ ! -e ${rvm_ruby_home}/etc/conf.d/maglev.conf ]] ; then
"$rvm_path/scripts/log" "info" "Creating default 'maglev' repository."
"$rvm_path/wrappers/$compatible_ruby/rake" "stone:create[maglev]" >/dev/null 2>&1
fi
"$rvm_path/scripts/log" "info" "Generating maglev HTML documentation"
"$rvm_path/wrappers/$compatible_ruby/rake" rdoc >/dev/null 2>&1
"$rvm_path/scripts/log" "info" "Generating smalltalk FFI."
"$rvm_path/wrappers/$compatible_ruby/rake" stwrappers >/dev/null 2>&1
unset compatible_ruby
# TODO: Figure out if anything needs to be done with rubygems.
#__rvm_rubygems_setup
__rvm_irbrc
__rvm_bin_script
__rvm_use
;;
ironruby|ir)
if ! command -v mono > /dev/null ; then
printf "mono must be installed and in your path in order to install IronRuby." ; return 1
fi
if [[ $rvm_head_flag -eq 1 ]] ; then
mono_version="$(mono -V | head -n 1 | cut -d ' ' -f5)"
if "$rvm_path/scripts/match" "$mono_version" "([0-9]+)\.([0-9]+)\.?([0-9]+)?" ; then
mono_major_ver="$(echo "$mono_version" | cut -d '.' -f1)"
mono_minor_ver="$(echo "$mono_version" | cut -d '.' -f2)"
if [[ $mono_major_ver -lt 2 ]] \
|| ( [[ $mono_major_ver -eq 2 && $mono_minor_ver -lt 6 ]] ) ; then
printf "Mono 2.6 (or greater) must be installed and in your path in order to build IronRuby from the repository."
printf "Version detected: ${mono_version}"
return 1
fi
else
printf "Cannot recognize mono version."
return 1
fi
__rvm_ensure_has_18_compat_ruby
__rvm_fetch_ruby
if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string"
compatible_ruby="$(__rvm_18_compat_ruby)"
"$rvm_path/wrappers/$compatible_ruby/gem" install pathname2 --no-rdoc --no-ri
# MONO_LIB=/Library/Frameworks/Mono.framework/Versions/current/lib/
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"
__rvm_run "rake" "$rvm_ruby_make" "Building IronRuby..."
unset compatible_ruby
if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
rm -rf "$rvm_ruby_home"/*
mkdir -p "$rvm_ruby_home/bin" "$rvm_ruby_home/lib" \
"$rvm_ruby_home/lib/ruby" "$rvm_ruby_home/lib/IronRuby"
cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Bin/mono_release"/* "$rvm_ruby_home/bin/"
cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Languages/Ruby/Scripts/bin"/* "$rvm_ruby_home/bin/"
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"
cp -r "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string/Merlin/Main/Languages/Ruby/Libs"/* "$rvm_ruby_home/lib/IronRuby"
else
"$rvm_path/scripts/log" "info" \
"Retrieving IronRuby"
"$rvm_path/scripts/fetch" "$rvm_ruby_url" \
"$rvm_ruby_package_file"
result=$?
if [[ "$result" -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
"There has been an error while trying to fetch the source. Halting the installation."
return $result
fi
mkdir -p "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" "$rvm_ruby_home"
unzip -o -d "${rvm_src_path:-"$rvm_path/src"}/$rvm_ruby_string" \
"${rvm_archives_path:-"$rvm_path/archives"}/${rvm_ruby_package_file}" >> \
"${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/extract.log" 2>> \
"${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/extract.error.log"
result=$?
if [[ "$result" -gt 1 ]] ; then