arch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #!/usr/bin/env bash
  2. requirements_arch_lib_installed_all_missing()
  3. {
  4. pacman -T "$@" || true
  5. }
  6. requirements_arch_lib_installed() {
  7. pacman -Qq "$1" >/dev/null 2>&1 || return $?
  8. }
  9. requirements_arch_lib_available()
  10. {
  11. pacman -Ssq "^${1}$" >/dev/null 2>&1 || return $?
  12. }
  13. requirements_arch_libs_install()
  14. {
  15. __rvm_try_sudo pacman -Sy --needed --noconfirm "$@" || return $?
  16. }
  17. requirements_arch_libs_remove()
  18. {
  19. __rvm_try_sudo pacman -Rs --noconfirm "$@" || return $?
  20. }
  21. requirements_arch_update_system()
  22. {
  23. # Has to be ran separately so new version can be used for installing missing libs
  24. requirements_arch_libs_install pacman || return $?
  25. }
  26. requirements_arch_define_check_raspberry_pi()
  27. {
  28. if
  29. [[ "${_system_arch}" == "arm"* ]]
  30. then
  31. # assuming all arm will need this fix
  32. requirements_check_fallback ntp openntpd chrony
  33. fi
  34. }
  35. requirements_arch_define_openssl()
  36. {
  37. case "$1" in
  38. (ruby-2.3*|ruby-2.2*|ruby-2.1*|ruby-2.0*|ruby-1.9*)
  39. requirements_check openssl-1.0
  40. # Ruby should respect pkg-config in case of openssl (it does not have to be the case with other extensions)
  41. # https://github.com/ruby/ruby/blob/trunk/ext/openssl/extconf.rb#L38
  42. export PKG_CONFIG_PATH="/usr/lib/openssl-1.0/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH:-}"
  43. ;;
  44. (*)
  45. requirements_check openssl
  46. ;;
  47. esac
  48. }
  49. requirements_arch_define()
  50. {
  51. requirements_arch_define_check_raspberry_pi
  52. case "$1" in
  53. (rvm)
  54. requirements_check bash curl patch
  55. ;;
  56. (jruby*)
  57. requirements_check curl make
  58. if
  59. is_head_or_disable_binary "$1"
  60. then
  61. requirements_check_fallback jdk8-openjdk jdk7-openjdk
  62. requirements_check git
  63. case $( jruby_installation_method "$1" ) in
  64. ant) __rvm_which ant >/dev/null || requirements_check apache-ant ;;
  65. mvn) __rvm_which mvn >/dev/null || requirements_check maven ;;
  66. esac
  67. else
  68. requirements_check_fallback jre8-openjdk jre7-openjdk
  69. fi
  70. ;;
  71. (ir*)
  72. requirements_check mono
  73. ;;
  74. (opal)
  75. requirements_check nodejs
  76. ;;
  77. (rbx*head|rubinius*head)
  78. undesired_check clang35 llvm35 llvm35-libs
  79. requirements_check clang llvm llvm-libs patch curl zlib readline autoconf automake diffutils make libtool bison git
  80. ;;
  81. (rbx-3*|rubinius-3*)
  82. undesired_check clang35 llvm35 llvm35-libs
  83. requirements_check clang llvm llvm-libs patch curl zlib readline autoconf automake diffutils make libtool bison
  84. ;;
  85. (rbx-2*|rubinius-2*)
  86. undesired_check clang llvm llvm-libs
  87. requirements_check clang35 llvm35 llvm35-libs patch curl zlib readline autoconf automake diffutils make libtool bison
  88. ;;
  89. (rbx-1*|rubinius-1*)
  90. undesired_check clang llvm llvm-libs
  91. requirements_check clang35 llvm35 llvm35-libs patch curl zlib readline autoconf automake diffutils make libtool bison
  92. ;;
  93. (truffleruby*)
  94. requirements_check zlib make gcc libxml2
  95. requirements_arch_define_openssl "$1"
  96. ;;
  97. (ruby-2.3*|ruby-2.2*|ruby-2.1*|ruby-2.0*|ruby-1.9*)
  98. requirements_check gcc patch curl zlib readline autoconf automake diffutils make libtool bison sqlite git
  99. requirements_arch_define_openssl "$1"
  100. ;;
  101. (*-head)
  102. requirements_check gcc patch curl zlib readline autoconf automake diffutils make libtool bison sqlite git
  103. requirements_arch_define_openssl "$1"
  104. ;;
  105. (*)
  106. requirements_check gcc patch curl zlib readline autoconf automake diffutils make libtool bison sqlite
  107. requirements_arch_define_openssl "$1"
  108. ;;
  109. esac
  110. }
  111. requirements_arch_service()
  112. {
  113. systemctl $1 $3 >/dev/null ||
  114. if __rvm_try_sudo systemctl $2 $3
  115. then true
  116. else
  117. \typeset __arch_status=$?
  118. rvm_error "There was a problem running 'systemctl $2 $3' with exit status '$__arch_status'."
  119. return $__arch_status
  120. fi
  121. }
  122. requirements_arch_after_check_raspberry_pi()
  123. {
  124. if
  125. [[ "${_system_arch}" == "arm"* ]]
  126. then
  127. ntp_servers=( ntpd systemd-timesyncd openntpd chronyd )
  128. for ntp_server in "${ntp_servers[@]}"
  129. do
  130. if
  131. systemctl list-unit-files | grep -Fq "$ntp_server.service" &&
  132. systemctl is-active $ntp_server
  133. then
  134. return 0
  135. fi
  136. done
  137. for ntp_server in "${ntp_servers[@]}"
  138. do
  139. if
  140. systemctl list-unit-files | grep -Fq "$ntp_server.service"
  141. then
  142. requirements_arch_service is-enabled enable $ntp_server &&
  143. requirements_arch_service is-active start $ntp_server ||
  144. return $?
  145. fi
  146. done
  147. fi
  148. }
  149. requirements_arch_after()
  150. {
  151. requirements_arch_after_check_raspberry_pi
  152. }
  153. requirements_manjaro_define()
  154. {
  155. __lib_type=arch
  156. requirements_arch_define "$@" || return $?
  157. }