profiles/arch/arm64: Unmask py3.8+3.9
[gentoo.git] / net-irc / rbot / rbot-0.9.15_p20160325-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5 USE_RUBY="ruby23 ruby24 ruby25"
6
7 GITHUB_COMMIT="e358601cc521d8aced941eb928fae2d8c53cf0c2"
8 inherit ruby-ng eutils user
9
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"
13
14 LICENSE="|| ( feh GPL-2 )"
15 SLOT="0"
16 KEYWORDS="~amd64"
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}"
21
22 RUBY_PATCHES=( rbot-rakefile-gettext.patch )
23
24 RDEPEND+="
25         spell? (
26                 aspell? ( app-text/aspell )
27                 !aspell? ( app-text/hunspell )
28         )
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 )"
35
36 ruby_add_bdepend "
37         test? (
38                 dev-ruby/sqlite3
39         )
40         nls? (
41                 >=dev-ruby/ruby-gettext-2
42                 dev-ruby/rake
43         )"
44
45 ruby_add_rdepend "
46         dev-ruby/tokyocabinet
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 )
51 "
52
53 pkg_setup() {
54         enewuser rbot -1 -1 /var/lib/rbot nobody
55 }
56
57 all_ruby_prepare() {
58         # Avoid tests that are only compatible with ruby22
59         rm -f test/test_journal.rb || die
60
61         # Fix deprecated code that was removed with ruby22
62         sed -i -e 's/::Config/::RbConfig/' setup.rb || die
63
64         # Avoid tests for optional dependencies that are not packaged.
65         sed -i -e '/RegistryDaybreakTest/,/^end/ s:^:#:' test/test_registry.rb || die
66
67         # Avoid broken tests that call code that doesn't exist
68         rm -f test/test_plugins_threshold.rb || die
69 }
70
71 all_ruby_compile() {
72         disable_rbot_plugin() {
73                 mv "${S}"/data/rbot/plugins/$1.rb{,.disabled}
74         }
75         use_rbot_plugin() {
76                 use $1 && return
77                 disable_rbot_plugin "$2"
78         }
79         rbot_conf() {
80                 echo "$1: $2" >> "${T}"/rbot.conf
81         }
82         use_rbot_conf_path() {
83                 use "$1" \
84                         && rbot_conf "$2" "$3" \
85                         || rbot_conf "$2" /bin/false
86         }
87
88         local spell_program="/usr/bin/hunspell -i"
89         if use !spell; then
90                 disable_rbot_plugin spell
91                 spell_program="/bin/false"
92         elif use aspell; then
93                 spell_program="/usr/bin/ispell-aspell"
94         fi
95
96         rbot_conf spell.program "${spell_program}"
97
98         if use !figlet && use !toilet; then
99                 disable_rbot_plugin figlet
100         fi
101
102         use_rbot_conf_path figlet figlet.path /usr/bin/figlet
103         use_rbot_conf_path toilet toilet.path /usr/bin/toilet
104
105         use_rbot_plugin timezone time
106         use_rbot_plugin translator translator
107         use_rbot_plugin shorturl shortenurls
108
109         use_rbot_plugin fortune fortune
110         use_rbot_conf_path fortune fortune.path /usr/bin/fortune
111
112         use_rbot_plugin cal cal
113         use_rbot_conf_path cal cal.path /usr/bin/cal
114
115         use_rbot_plugin host host
116         use_rbot_conf_path host host.path /usr/bin/host
117
118         local rbot_datadir="${D}"/usr/share/rbot
119
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.
125         if use nls; then
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"
140
141                         for lang in ${ILINGUAS}; do
142                                 has ${lang} ${LINGUAS} && continue
143
144                                 lang_varname="lang_rbot_${lang}"
145                                 lang_rbot=${!lang_varname}
146
147                                 rm -r \
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
153                         done
154                 fi
155
156                 ${RUBY} /usr/bin/rake makemo || die "locale generation failed"
157         fi
158 }
159
160 each_ruby_compile() {
161         ${RUBY} setup.rb config --prefix="/usr" \
162                 || die "setup.rb install failed"
163 }
164
165 each_ruby_test() {
166         pushd test || die
167         ${RUBY} -Ilib:. -e "Dir['test_*'].each{|f| require f}" || die
168         popd || die
169 }
170
171 each_ruby_install() {
172         ${RUBY} setup.rb install --prefix="${D}" \
173                 || die "setup.rb install failed"
174 }
175
176 all_ruby_install() {
177         diropts -o rbot -g nobody -m 0700
178         keepdir /var/lib/rbot
179
180         insinto /etc
181         doins "${T}"/rbot.conf
182
183         newinitd "${FILESDIR}/rbot.init2" rbot
184         newconfd "${FILESDIR}/rbot.conf2" rbot
185 }
186
187 pkg_postinst() {
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."
195 }