rbot-0.9.15_p20160325.ebuild 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. USE_RUBY="ruby20 ruby21 ruby22"
  5. GITHUB_COMMIT="e358601cc521d8aced941eb928fae2d8c53cf0c2"
  6. inherit ruby-ng eutils user
  7. DESCRIPTION="A ruby IRC bot"
  8. HOMEPAGE="http://ruby-rbot.org/"
  9. SRC_URI="https://github.com/ruby-rbot/rbot/archive/${GITHUB_COMMIT}.tar.gz -> ${P}.tar.gz"
  10. LICENSE="|| ( feh GPL-2 )"
  11. SLOT="0"
  12. KEYWORDS="~amd64 ~ppc ~x86"
  13. IUSE="spell aspell timezone translator shorturl nls figlet
  14. fortune cal host toilet"
  15. ILINGUAS="zh_CN zh_TW ru nl de fi fr it ja"
  16. RUBY_S="${PN}-${GITHUB_COMMIT}"
  17. for lang in $ILINGUAS; do
  18. IUSE="${IUSE} linguas_${lang}"
  19. done
  20. RUBY_PATCHES=( rbot-rakefile-gettext.patch )
  21. RDEPEND+="
  22. spell? (
  23. aspell? ( app-text/aspell )
  24. !aspell? ( app-text/hunspell )
  25. )
  26. figlet? ( app-misc/figlet )
  27. toilet? ( app-misc/toilet )
  28. fortune? ( games-misc/fortune-mod )
  29. cal? ( || ( sys-apps/util-linux sys-freebsd/freebsd-ubin ) )
  30. host? ( net-dns/bind-tools )"
  31. ruby_add_bdepend "
  32. nls? (
  33. >=dev-ruby/ruby-gettext-2
  34. dev-ruby/rake
  35. )"
  36. ruby_add_rdepend "
  37. dev-ruby/tokyocabinet
  38. timezone? ( dev-ruby/tzinfo:* )
  39. translator? ( dev-ruby/mechanize )
  40. shorturl? ( dev-ruby/shorturl )
  41. nls? ( dev-ruby/ruby-gettext >=dev-ruby/locale-2.0.5-r2 )
  42. "
  43. pkg_setup() {
  44. enewuser rbot -1 -1 /var/lib/rbot nobody
  45. }
  46. all_ruby_prepare() {
  47. # Avoid tests that are only compatible with ruby22
  48. rm -f test/test_journal.rb || die
  49. # Fix deprecated code that was removed with ruby22
  50. sed -i -e 's/::Config/::RbConfig/' setup.rb || die
  51. }
  52. all_ruby_compile() {
  53. disable_rbot_plugin() {
  54. mv "${S}"/data/rbot/plugins/$1.rb{,.disabled}
  55. }
  56. use_rbot_plugin() {
  57. use $1 && return
  58. disable_rbot_plugin "$2"
  59. }
  60. rbot_conf() {
  61. echo "$1: $2" >> "${T}"/rbot.conf
  62. }
  63. use_rbot_conf_path() {
  64. use "$1" \
  65. && rbot_conf "$2" "$3" \
  66. || rbot_conf "$2" /bin/false
  67. }
  68. local spell_program="/usr/bin/hunspell -i"
  69. if use !spell; then
  70. disable_rbot_plugin spell
  71. spell_program="/bin/false"
  72. elif use aspell; then
  73. spell_program="/usr/bin/ispell-aspell"
  74. fi
  75. rbot_conf spell.program "${spell_program}"
  76. if use !figlet && use !toilet; then
  77. disable_rbot_plugin figlet
  78. fi
  79. use_rbot_conf_path figlet figlet.path /usr/bin/figlet
  80. use_rbot_conf_path toilet toilet.path /usr/bin/toilet
  81. use_rbot_plugin timezone time
  82. use_rbot_plugin translator translator
  83. use_rbot_plugin shorturl shortenurls
  84. use_rbot_plugin fortune fortune
  85. use_rbot_conf_path fortune fortune.path /usr/bin/fortune
  86. use_rbot_plugin cal cal
  87. use_rbot_conf_path cal cal.path /usr/bin/cal
  88. use_rbot_plugin host host
  89. use_rbot_conf_path host host.path /usr/bin/host
  90. local rbot_datadir="${D}"/usr/share/rbot
  91. # This is unfortunately pretty manual at the moment, but it's just
  92. # to avoid having to run special scripts to package new versions
  93. # of rbot. The default if new languages are added that are not
  94. # considered for an opt-out here is to install them, so you just
  95. # need to add them later.
  96. if use nls; then
  97. strip-linguas ${ILINGUAS}
  98. if [[ -n ${LINGUAS} ]]; then
  99. # As the the language name used by the rbot data files does
  100. # not correspond to the ISO codes we usually use for LINGUAS,
  101. # the following list of local varables will work as a
  102. # dictionary to get the name used by rbot from the ISO code.
  103. local lang_rbot_zh_CN="traditional_chinese"
  104. local lang_rbot_ru="russian"
  105. local lang_rbot_nl="dutch"
  106. local lang_rbot_de="german"
  107. local lang_rbot_fi="finnish"
  108. local lang_rbot_fr="french"
  109. local lang_rbot_it="italian"
  110. local lang_rbot_ja="japanese"
  111. for lang in ${ILINGUAS}; do
  112. use linguas_${lang} && continue
  113. lang_varname="lang_rbot_${lang}"
  114. lang_rbot=${!lang_varname}
  115. rm -r \
  116. "${S}"/data/rbot/languages/${lang_rbot}.lang \
  117. "${S}"/data/rbot/templates/lart/larts-${lang_rbot} \
  118. "${S}"/data/rbot/templates/lart/praises-${lang_rbot} \
  119. "${S}"/data/rbot/templates/salut/salut-${lang_rbot} \
  120. "${S}"/po/${lang} &>/dev/null
  121. done
  122. fi
  123. ${RUBY} /usr/bin/rake makemo || die "locale generation failed"
  124. fi
  125. }
  126. each_ruby_compile() {
  127. ${RUBY} setup.rb config --prefix="/usr" \
  128. || die "setup.rb install failed"
  129. }
  130. each_ruby_test() {
  131. pushd test || die
  132. ${RUBY} -Ilib:. -e "Dir['test_*'].each{|f| require f}" || die
  133. popd || die
  134. }
  135. each_ruby_install() {
  136. ${RUBY} setup.rb install --prefix="${D}" \
  137. || die "setup.rb install failed"
  138. }
  139. all_ruby_install() {
  140. diropts -o rbot -g nobody -m 0700
  141. keepdir /var/lib/rbot
  142. insinto /etc
  143. doins "${T}"/rbot.conf
  144. newinitd "${FILESDIR}/rbot.init2" rbot
  145. newconfd "${FILESDIR}/rbot.conf2" rbot
  146. }
  147. pkg_postinst() {
  148. elog "rbot can be started as a normal service."
  149. elog "Check /etc/conf.d/rbot file for more information about this feature."
  150. ewarn "DEPRECATION NOTICE:"
  151. ewarn "The bdb database backend is deprecated and only available on Ruby 1.8."
  152. ewarn "To migrate to the new tokyocabinet-based backend, change the core.db"
  153. ewarn "parameter in your bot's conf.yaml to 'tc' and restart rbot."
  154. ewarn "This procedure requires a Ruby version supporting both BDB and TC."
  155. }