centos 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. #!/usr/bin/env bash
  2. requirements_centos_lib_installed()
  3. {
  4. rpm -q --whatprovides "$1" >/dev/null || return $?
  5. }
  6. requirements_centos_lib_available()
  7. {
  8. yum list --cacheonly --quiet "$1" >/dev/null 2>&1 || return $?
  9. }
  10. # required only for libyaml-devel check as fedora is broken ...
  11. requirements_centos_lib_available_no_caching()
  12. {
  13. yum list --quiet "$1" >/dev/null 2>&1 || return $?
  14. }
  15. requirements_centos_version_list()
  16. {
  17. rpm -q --whatprovides "$1" | sed -e "s#^$1-##"
  18. }
  19. requirements_centos_install_custom()
  20. {
  21. requirements_rvm_pkg_libs_install "$@" || return $?
  22. }
  23. requirements_centos_libs_install()
  24. {
  25. __rvm_try_sudo yum install -y "$@" || return $?
  26. }
  27. requirements_centos_before_update_check_repos_missing_error()
  28. {
  29. rvm_error "There is no '$*' package available for installation and RVM does not know how to make that happen,
  30. please tell us how to install '$*' on '${_system_name}-${_system_version}' here: https://github.com/rvm/rvm/issues"
  31. return 49
  32. }
  33. requirements_centos_before_update_check_rhn_channel()
  34. {
  35. __rvm_try_sudo rhn-channel -l | grep optional >/dev/null ||
  36. {
  37. \typeset __package_name="$(
  38. __rvm_try_sudo rhn-channel -l |
  39. awk '/^rhel-'"${_system_arch}"'-(server|client|workstation)-[0-9]+$/{print gensub(/(-[0-9]+)$/, "-optional\\1", "g")}'
  40. )"
  41. rvm_log "Enabling optional repository"
  42. rvm_requiremnts_fail_or_run_action 2 \
  43. "It is not possible to enable optional repository for $*, enable it using: rhn-channel -a -c ${__package_name}" \
  44. __rvm_try_sudo rhn-channel -a -c "${__package_name}" ||
  45. return $?
  46. }
  47. }
  48. requirements_centos_before_install_epel()
  49. {
  50. "${rvm_scripts_path}/fetch" "${epel_key}"
  51. "${rvm_scripts_path}/fetch" "${epel_rpm}"
  52. __rvm_try_sudo rpm --import "${rvm_archives_path}/${epel_key##*/}"
  53. __rvm_try_sudo rpm --quiet -i "${rvm_archives_path}/${epel_rpm##*/}" ||
  54. {
  55. \typeset __ret=$?
  56. rvm_error "Error installing EPEL, it is required for libyaml-devel,
  57. either there was an error installing EPEL package,
  58. or there was problem checking if libyaml-devel is available / installed."
  59. return ${__ret}
  60. }
  61. }
  62. requirements_centos_before_update_check_epel()
  63. {
  64. [[ " $* " == *" libyaml-devel "* ]] || return 0
  65. # if you change this, change the scripts/functions/pkg version too
  66. [[ -f /etc/yum.repos.d/epel.repo ]] ||
  67. {
  68. \typeset version="${_system_version%%.*}"
  69. __rvm_db "epel${version}_key" "epel_key"
  70. __rvm_db "epel${version}_${_system_arch}_rpm" "epel_rpm"
  71. if
  72. [[ -z "$epel_rpm" || -z "$epel_key" ]]
  73. then
  74. requirements_centos_before_update_check_repos_missing_error $* || return $?
  75. fi
  76. rvm_requiremnts_fail_or_run_action 2 \
  77. "It is not possible to install EPEL repository for YAML, install it using: $epel_rpm" \
  78. __rvm_log_command centos_install_epel "Installing EPEL repository" requirements_centos_before_install_epel ||
  79. return $?
  80. }
  81. }
  82. # return 0 when found missing packages
  83. # return >0 when no missing packages
  84. requirements_centos_before_update_check_missing_packages()
  85. {
  86. \typeset -a __packages_to_check
  87. \typeset __package_name
  88. case "${_system_name_lowercase}" in
  89. (redhat)
  90. __packages_to_check=( libyaml-devel libffi-devel )
  91. ;;
  92. (centos)
  93. __packages_to_check=( libyaml-devel )
  94. ;;
  95. (*)
  96. return 1
  97. ;;
  98. esac
  99. __missing_packages=()
  100. for __package_name in "${__packages_to_check[@]}"
  101. do
  102. if
  103. [[ " ${packages_to_install[*]} " == *" ${__package_name} "* ]] &&
  104. ! requirements_centos_lib_installed "${__package_name}" &&
  105. ! requirements_centos_lib_available_no_caching "${__package_name}"
  106. then
  107. __missing_packages+=( "${__package_name}" )
  108. fi
  109. done
  110. [[ ${#__missing_packages[*]} -gt 0 ]] || return 2
  111. }
  112. requirements_centos_before_update_check_repos()
  113. {
  114. \typeset -a __missing_packages
  115. requirements_centos_before_update_check_missing_packages || return 0
  116. case "${_system_name_lowercase}" in
  117. (redhat)
  118. requirements_centos_before_update_check_rhn_channel "${__missing_packages[@]}" || return $?
  119. ;;
  120. (centos)
  121. requirements_centos_before_update_check_epel "${__missing_packages[@]}" || return $?
  122. ;;
  123. (*)
  124. requirements_centos_before_update_check_repos_missing_error "${__missing_packages[@]}" || return $?
  125. ;;
  126. esac
  127. }
  128. requirements_centos_before_update()
  129. {
  130. case "$1" in
  131. (ruby-1*)
  132. requirements_centos_before_update_check_repos || return $?
  133. ;;
  134. esac
  135. }
  136. requirements_centos_check_binary()
  137. {
  138. {
  139. __rvm_which update-alternatives >/dev/null &&
  140. update-alternatives --display "$1" >/dev/null 2>&1
  141. } ||
  142. __rvm_which "$1" >/dev/null || return $?
  143. }
  144. requirements_centos_define_glibc()
  145. {
  146. requirements_check glibc-headers glibc-devel
  147. }
  148. requirements_centos_define_libyaml()
  149. {
  150. case "$1" in
  151. (ruby-1*) requirements_check libyaml-devel ;;
  152. esac
  153. }
  154. requirements_centos_define_openssl()
  155. {
  156. requirements_check openssl-devel
  157. }
  158. requirements_centos_define()
  159. {
  160. case "$1" in
  161. (rvm)
  162. requirements_check bash curl patch
  163. ;;
  164. (jruby*)
  165. requirements_check make
  166. if
  167. is_head_or_disable_binary "$1"
  168. then
  169. requirements_centos_check_binary javac ||
  170. requirements_check_fallback java-1.8.0-openjdk-devel java-devel ||
  171. requirements_check_fallback java-1.7.0-openjdk-devel java-devel
  172. requirements_check git
  173. case $( jruby_installation_method "$1" ) in
  174. mvn) requirements_check_custom_after mvn=maven ;;
  175. esac
  176. else
  177. requirements_centos_check_binary java ||
  178. requirements_check_fallback java-1.8.0-openjdk java ||
  179. requirements_check_fallback java-1.7.0-openjdk java
  180. fi
  181. ;;
  182. (rbx*|rubinius*)
  183. requirements_check automake bison clang-3.6 flex gdbm-devel git libyaml-devel llvm-devel llvm-static \
  184. make ncurses-devel openssl-devel readline-devel ruby-devel rubygems zlib-devel
  185. ;;
  186. (truffleruby*)
  187. requirements_check zlib-devel make gcc libxml2
  188. requirements_${_system_name_lowercase}_define_openssl $1
  189. ;;
  190. (ir*)
  191. true # not that easy
  192. ;;
  193. (opal)
  194. true # not that easy
  195. ;;
  196. (*-head)
  197. requirements_check git
  198. requirements_centos_define "${1%-head}"
  199. requirements_version_minimal autoconf 2.67
  200. ;;
  201. (*)
  202. if [[ ${#rvm_patch_names[@]} -gt 0 ]]
  203. then requirements_version_minimal autoconf 2.67
  204. fi
  205. requirements_check autoconf automake bison bzip2 gcc-c++ libffi-devel libtool make patch readline \
  206. readline-devel ruby sqlite-devel zlib zlib-devel
  207. requirements_${_system_name_lowercase}_define_glibc $1
  208. requirements_${_system_name_lowercase}_define_libyaml $1
  209. requirements_${_system_name_lowercase}_define_openssl $1
  210. ;;
  211. esac
  212. }