1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 USE_RUBY="ruby23 ruby24 ruby25"
7 GITHUB_COMMIT="e358601cc521d8aced941eb928fae2d8c53cf0c2"
8 inherit ruby-ng eutils user
10 DESCRIPTION="A ruby IRC bot"
11 HOMEPAGE="https://ruby-rbot.org/"
12 SRC_URI="https://github.com/ruby-rbot/rbot/archive/${GITHUB_COMMIT}.tar.gz -> ${P}.tar.gz"
14 LICENSE="|| ( feh GPL-2 )"
17 IUSE="spell aspell timezone translator shorturl nls figlet
18 fortune cal host sqlite toilet"
19 ILINGUAS="zh_CN zh_TW ru nl de fi fr it ja"
20 RUBY_S="${PN}-${GITHUB_COMMIT}"
22 RUBY_PATCHES=( rbot-rakefile-gettext.patch )
26 aspell? ( app-text/aspell )
27 !aspell? ( app-text/hunspell )
29 figlet? ( app-misc/figlet )
30 sqlite? ( dev-ruby/sqlite3 )
31 toilet? ( app-misc/toilet )
32 fortune? ( games-misc/fortune-mod )
33 cal? ( sys-apps/util-linux )
34 host? ( net-dns/bind-tools )"
41 >=dev-ruby/ruby-gettext-2
47 timezone? ( dev-ruby/tzinfo:* )
48 translator? ( dev-ruby/mechanize )
49 shorturl? ( dev-ruby/shorturl )
50 nls? ( dev-ruby/ruby-gettext >=dev-ruby/locale-2.0.5-r2 )
54 enewuser rbot -1 -1 /var/lib/rbot nobody
58 # Avoid tests that are only compatible with ruby22
59 rm -f test/test_journal.rb || die
61 # Fix deprecated code that was removed with ruby22
62 sed -i -e 's/::Config/::RbConfig/' setup.rb || die
64 # Avoid tests for optional dependencies that are not packaged.
65 sed -i -e '/RegistryDaybreakTest/,/^end/ s:^:#:' test/test_registry.rb || die
67 # Avoid broken tests that call code that doesn't exist
68 rm -f test/test_plugins_threshold.rb || die
72 disable_rbot_plugin() {
73 mv "${S}"/data/rbot/plugins/$1.rb{,.disabled}
77 disable_rbot_plugin "$2"
80 echo "$1: $2" >> "${T}"/rbot.conf
82 use_rbot_conf_path() {
84 && rbot_conf "$2" "$3" \
85 || rbot_conf "$2" /bin/false
88 local spell_program="/usr/bin/hunspell -i"
90 disable_rbot_plugin spell
91 spell_program="/bin/false"
93 spell_program="/usr/bin/ispell-aspell"
96 rbot_conf spell.program "${spell_program}"
98 if use !figlet && use !toilet; then
99 disable_rbot_plugin figlet
102 use_rbot_conf_path figlet figlet.path /usr/bin/figlet
103 use_rbot_conf_path toilet toilet.path /usr/bin/toilet
105 use_rbot_plugin timezone time
106 use_rbot_plugin translator translator
107 use_rbot_plugin shorturl shortenurls
109 use_rbot_plugin fortune fortune
110 use_rbot_conf_path fortune fortune.path /usr/bin/fortune
112 use_rbot_plugin cal cal
113 use_rbot_conf_path cal cal.path /usr/bin/cal
115 use_rbot_plugin host host
116 use_rbot_conf_path host host.path /usr/bin/host
118 local rbot_datadir="${D}"/usr/share/rbot
120 # This is unfortunately pretty manual at the moment, but it's just
121 # to avoid having to run special scripts to package new versions
122 # of rbot. The default if new languages are added that are not
123 # considered for an opt-out here is to install them, so you just
124 # need to add them later.
126 strip-linguas ${ILINGUAS}
127 if [[ -n ${LINGUAS+set} ]]; then
128 # As the the language name used by the rbot data files does
129 # not correspond to the ISO codes we usually use for LINGUAS,
130 # the following list of local varables will work as a
131 # dictionary to get the name used by rbot from the ISO code.
132 local lang_rbot_zh_CN="traditional_chinese"
133 local lang_rbot_ru="russian"
134 local lang_rbot_nl="dutch"
135 local lang_rbot_de="german"
136 local lang_rbot_fi="finnish"
137 local lang_rbot_fr="french"
138 local lang_rbot_it="italian"
139 local lang_rbot_ja="japanese"
141 for lang in ${ILINGUAS}; do
142 has ${lang} ${LINGUAS} && continue
144 lang_varname="lang_rbot_${lang}"
145 lang_rbot=${!lang_varname}
148 "${S}"/data/rbot/languages/${lang_rbot}.lang \
149 "${S}"/data/rbot/templates/lart/larts-${lang_rbot} \
150 "${S}"/data/rbot/templates/lart/praises-${lang_rbot} \
151 "${S}"/data/rbot/templates/salut/salut-${lang_rbot} \
152 "${S}"/po/${lang} &>/dev/null
156 ${RUBY} /usr/bin/rake makemo || die "locale generation failed"
160 each_ruby_compile() {
161 ${RUBY} setup.rb config --prefix="/usr" \
162 || die "setup.rb install failed"
167 ${RUBY} -Ilib:. -e "Dir['test_*'].each{|f| require f}" || die
171 each_ruby_install() {
172 ${RUBY} setup.rb install --prefix="${D}" \
173 || die "setup.rb install failed"
177 diropts -o rbot -g nobody -m 0700
178 keepdir /var/lib/rbot
181 doins "${T}"/rbot.conf
183 newinitd "${FILESDIR}/rbot.init2" rbot
184 newconfd "${FILESDIR}/rbot.conf2" rbot
188 elog "rbot can be started as a normal service."
189 elog "Check /etc/conf.d/rbot file for more information about this feature."
190 ewarn "DEPRECATION NOTICE:"
191 ewarn "The bdb database backend is deprecated and only available on Ruby 1.8."
192 ewarn "To migrate to the new tokyocabinet-based backend, change the core.db"
193 ewarn "parameter in your bot's conf.yaml to 'tc' and restart rbot."
194 ewarn "This procedure requires a Ruby version supporting both BDB and TC."