ruby 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #!/usr/bin/env bash
  2. ruby_install_baseruby_check()
  3. {
  4. __rvm_ensure_has_mri_ruby || return $?
  5. \typeset compatible_baseruby
  6. if
  7. compatible_baseruby="$rvm_wrappers_path/$(__rvm_mri_ruby)/ruby" &&
  8. [[ -x "$compatible_baseruby" ]]
  9. then
  10. rvm_configure_flags+=( --with-baseruby="$compatible_baseruby" )
  11. else
  12. return $?
  13. fi
  14. }
  15. ruby_install()
  16. {
  17. \typeset result temp_flags _iterator
  18. case ${rvm_ruby_string:-""} in
  19. ruby-1.8.*-head)
  20. __rvm_ensure_has_mri_ruby "ree-|ruby-1.8.|ruby-1.8.7-p|ruby-1.8.7-p374" || return $?
  21. ;;
  22. ruby-1.8.*)
  23. if (( ${rvm_head_flag:-0} == 1 ))
  24. then __rvm_ensure_has_mri_ruby "ree-|ruby-1.8.|ruby-1.8.7-p|ruby-1.8.7-p374" || return $?
  25. fi
  26. ;;
  27. ruby*-head)
  28. ruby_install_baseruby_check || return $?
  29. ;;
  30. ruby*)
  31. if (( ${rvm_head_flag:-0} == 1 ))
  32. then ruby_install_baseruby_check || return $?
  33. fi
  34. ;;
  35. esac
  36. # TODO: needed on some 1.9.3, confirm with http://bugs.ruby-lang.org/issues/6903
  37. if
  38. [[ " ${rvm_configure_flags[*]}" == *" --enable-load-relative"* ]]
  39. then
  40. case ${rvm_ruby_string} in
  41. ruby-1.9.3-p125|ruby-1.9.3-p286|ruby-1.9.3-p327|ruby-1.9.3-p362|ruby-1.9.3-p374|ruby-1.9.3-p385)
  42. rvm_patch_names+=( ruby-multilib )
  43. ;;
  44. esac
  45. fi
  46. (
  47. __rvm_setup_compile_environment "${rvm_ruby_string}" &&
  48. __rvm_install_source $* &&
  49. ruby_install_warn_clang
  50. ) || return $?
  51. ruby_install_warnings
  52. }
  53. ruby_install_warn_clang()
  54. {
  55. if
  56. ! __ruby_clang_ok ${rvm_ruby_string} &&
  57. [[ -n "${initially_selected_compiler:-}" ]] &&
  58. __rvm_compiler_is_llvm "${initially_selected_compiler:-}"
  59. then
  60. rvm_warn "Ruby '${rvm_ruby_string}' was built using clang - but it's not (fully) supported, expect errors."
  61. fi
  62. }
  63. ruby_install_warnings()
  64. {
  65. \typeset patches_count
  66. patches_count=$(
  67. rvm_ruby_string="${rvm_ruby_string}" lookup_patchset default | wc -l
  68. )
  69. \typeset _default _version _patch _memo _unmaintained_ruby _unmaintained_date
  70. _unmaintained_ruby=$(__rvm_db "ruby_unmaintained_version")
  71. _default=$(__rvm_db "default_ruby")
  72. _version=$(__rvm_db "${_default}_version")
  73. _patch=$(__rvm_db "${_default}_${_version}_patch_level")
  74. _version="${_default}-${_version}${_patch:+-}${_patch:-}"
  75. _memo="Please consider upgrading to ${_version} which will have all of the latest security patches."
  76. if
  77. (( ${rvm_head_flag:-0} == 0 )) &&
  78. [[ "$rvm_ruby_version" != "head" ]] &&
  79. __rvm_version_compare "$rvm_ruby_version" -le "${_unmaintained_ruby}"
  80. then
  81. _unmaintained_date=$(__rvm_db "ruby_unmaintained_date")
  82. if
  83. __rvm_version_compare "$rvm_ruby_version" -eq "${_unmaintained_ruby}" &&
  84. __rvm_version_compare "$(date +%F)" -lt "${_unmaintained_date}"
  85. then
  86. rvm_error "WARNING: Please be aware that you just installed a ruby that will finish normal maintenance on ${_unmaintained_date}, for a list of maintained rubies visit:
  87. http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
  88. ${_memo}"
  89. else
  90. rvm_error "WARNING: Please be aware that you just installed a ruby that is no longer maintained (${_unmaintained_date}), for a list of maintained rubies visit:
  91. http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
  92. ${_memo}"
  93. fi
  94. elif
  95. [[ "${rvm_ruby_string}" != *"${_version}"* ]] && (( patches_count > 0 ))
  96. then
  97. rvm_warn "Please be aware that you just installed a ruby that requires ${patches_count} patches just to be compiled on an up to date linux system.
  98. This may have known and unaccounted for security vulnerabilities.
  99. ${_memo}"
  100. fi
  101. if (( ${rvm_docs_flag:-0} == 1 ))
  102. then rvm_log "Ruby was built with documentation, to read it try: ri String"
  103. else rvm_log "Ruby was built without documentation, to build it run: rvm docs generate-ri"
  104. fi
  105. }
  106. __rvm_post_configure_ruby()
  107. {
  108. __rvm_post_configure_ruby_fix_athlon_sse2
  109. __rvm_post_configure_ruby_update_setup
  110. }
  111. __rvm_post_configure_ruby_fix_athlon_sse2()
  112. {
  113. if
  114. [[ -f /proc/cpuinfo && -f Makefile ]] &&
  115. __rvm_grep "^XCFLAGS = .*-msse2" Makefile >/dev/null &&
  116. ! __rvm_grep "^flags.*sse2" /proc/cpuinfo
  117. then
  118. __rvm_sed_i Makefile -e '/^XCFLAGS =/s/-msse2//'
  119. fi
  120. }
  121. __rvm_post_configure_ruby_update_setup()
  122. {
  123. \typeset option
  124. if
  125. (( ${rvm_static_flag:-0} == 1 )) && (( ${rvm_dynamic_extensions_flag:-0} == 0 ))
  126. then
  127. for option in 'option nodynamic' openssl psych zlib readline
  128. do
  129. __rvm_update_ext_setup ${option}
  130. done
  131. fi
  132. }
  133. __rvm_update_ext_setup()
  134. {
  135. echo "extension setup: $1"
  136. if
  137. __rvm_grep "$1" ext/Setup >/dev/null
  138. then
  139. __rvm_sed_i ext/Setup -e "s/#$1/$1/"
  140. else
  141. echo "$1" >> ext/Setup
  142. fi
  143. }