Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: mail-filter/spamassassin/
Date: Sun, 19 Mar 2023 03:22:57
Message-Id: 1679195163.e1b5e2c00f0849411d482dc1af43fe9120903da3.sam@gentoo
1 commit: e1b5e2c00f0849411d482dc1af43fe9120903da3
2 Author: Philippe Chaintreuil <gentoo_bugs_peep <AT> parallaxshift <DOT> com>
3 AuthorDate: Sat Mar 18 00:49:53 2023 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sun Mar 19 03:06:03 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e1b5e2c0
7
8 mail-filter/spamassassin: eautoreconf spamc
9
10 To deal with "implicit function declarations" in configure logs coming
11 out of a standard autoconf test, run eautoreconf on spamc. Word is that
12 the standard test is fixed in the next autoconf release, so this may not
13 need to stick around for too long.
14
15 Closes: https://bugs.gentoo.org/899782
16 Closes: https://github.com/gentoo/gentoo/pull/30200
17 Signed-off-by: Philippe Chaintreuil <gentoo_bugs_peep <AT> parallaxshift.com>
18 Signed-off-by: Sam James <sam <AT> gentoo.org>
19
20 .../spamassassin/spamassassin-4.0.0-r2.ebuild | 338 +++++++++++++++++++++
21 1 file changed, 338 insertions(+)
22
23 diff --git a/mail-filter/spamassassin/spamassassin-4.0.0-r2.ebuild b/mail-filter/spamassassin/spamassassin-4.0.0-r2.ebuild
24 new file mode 100644
25 index 000000000000..575cc1c184be
26 --- /dev/null
27 +++ b/mail-filter/spamassassin/spamassassin-4.0.0-r2.ebuild
28 @@ -0,0 +1,338 @@
29 +# Copyright 1999-2023 Gentoo Authors
30 +# Distributed under the terms of the GNU General Public License v2
31 +
32 +EAPI=8
33 +
34 +inherit perl-functions systemd toolchain-funcs verify-sig autotools
35 +
36 +MY_P="Mail-SpamAssassin-${PV//_/-}"
37 +DESCRIPTION="An extensible mail filter which can identify and tag spam"
38 +HOMEPAGE="https://spamassassin.apache.org/"
39 +SRC_URI="mirror://apache/spamassassin/source/${MY_P}.tar.bz2
40 + verify-sig? (
41 + https://downloads.apache.org/spamassassin/source/${MY_P}.tar.bz2.asc
42 + )
43 +"
44 +S="${WORKDIR}/${MY_P}"
45 +
46 +LICENSE="Apache-2.0 GPL-2"
47 +SLOT="0"
48 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
49 +IUSE="berkdb cron ipv6 ldap mysql postgres qmail sqlite ssl test"
50 +RESTRICT="!test? ( test )"
51 +
52 +# The Makefile.PL script checks for dependencies, but only fails if a
53 +# required (i.e. not optional) dependency is missing. We therefore
54 +# require most of the optional modules only at runtime.
55 +REQDEPEND="acct-user/spamd
56 + acct-group/spamd
57 + dev-lang/perl:=
58 + dev-perl/HTML-Parser
59 + dev-perl/Net-DNS
60 + dev-perl/NetAddr-IP
61 + virtual/perl-Digest-SHA
62 + ssl? (
63 + dev-libs/openssl:0=
64 + )"
65 +
66 +# SpamAssassin doesn't use libwww-perl except as a fallback for when
67 +# curl/wget are missing, so we depend on one of those instead. Some
68 +# mirrors use https, so we need those utilities to support SSL.
69 +#
70 +# re2c is needed to compile the rules (sa-compile).
71 +#
72 +# We still need the old Digest-SHA1 because razor2 has not been ported
73 +# to Digest-SHA.
74 +OPTDEPEND="app-crypt/gnupg
75 + dev-perl/Archive-Zip
76 + dev-perl/BSD-Resource
77 + dev-perl/Digest-SHA1
78 + dev-perl/Email-Address-XS
79 + dev-perl/Encode-Detect
80 + || ( dev-perl/GeoIP2 dev-perl/Geo-IP )
81 + dev-perl/IO-String
82 + dev-perl/Mail-DKIM
83 + dev-perl/Mail-DMARC
84 + dev-perl/Mail-SPF
85 + dev-perl/Net-Patricia
86 + dev-perl/Net-LibIDN2
87 + dev-util/re2c
88 + || ( net-misc/wget[ssl] net-misc/curl[ssl] )
89 + virtual/perl-MIME-Base64
90 + dev-perl/Pod-Parser
91 + berkdb? ( virtual/perl-DB_File )
92 + ipv6? ( dev-perl/IO-Socket-INET6 )
93 + ldap? ( dev-perl/perl-ldap )
94 + mysql? (
95 + dev-perl/DBI
96 + dev-perl/DBD-mysql
97 + )
98 + postgres? (
99 + dev-perl/DBI
100 + dev-perl/DBD-Pg
101 + )
102 + sqlite? (
103 + dev-perl/DBI
104 + dev-perl/DBD-SQLite
105 + )
106 + ssl? ( dev-perl/IO-Socket-SSL )"
107 +
108 +DEPEND="${REQDEPEND}
109 + test? (
110 + ${OPTDEPEND}
111 + virtual/perl-Test-Harness
112 + )"
113 +RDEPEND="${REQDEPEND} ${OPTDEPEND}"
114 +BDEPEND="${RDEPEND}
115 + verify-sig? ( sec-keys/openpgp-keys-spamassassin )"
116 +
117 +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/spamassassin.apache.org.asc
118 +
119 +PATCHES=(
120 + "${FILESDIR}/mention-geoip.cf-in-init.pre.patch"
121 + "${FILESDIR}/4.0.0-tests-dnsbl_subtests.t.patch"
122 + "${FILESDIR}/4.0.0-tests-strip2.t.patch"
123 +)
124 +
125 +# There are a few renames and use-dependent ones in src_install as well.
126 +DOCS=(
127 + NOTICE TRADEMARK CREDITS UPGRADE USAGE sql/README.bayes
128 + sql/README.awl procmailrc.example sample-nonspam.txt
129 + sample-spam.txt spamd/PROTOCOL spamd/README.vpopmail
130 + spamd-apache2/README.apache
131 +)
132 +
133 +src_prepare() {
134 + default
135 +
136 + # The sa_compile test does some weird stuff like hopping around in
137 + # the directory tree and calling "make" to create a dist tarball
138 + # from ${S}. It fails, and is more trouble than it's worth...
139 + perl_rm_files t/sa_compile.t
140 +
141 + # The spamc tests (which need the networked spamd daemon) fail for
142 + # irrelevant reasons. It's too hard to disable them (unlike the
143 + # spamd tests themselves -- see src_test), so use a crude
144 + # workaround.
145 + perl_rm_files t/spamc_*.t
146 +
147 + # Some tests need extra dependencies
148 + # e.g. t/sql_based_whitelist.t needs DBD
149 + # This is kinder than REQUIRED_USE for tests which hurts automation
150 + if ! use mysql && ! use postgres && ! use sqlite ; then
151 + perl_rm_files t/sql_based_whitelist.t
152 + fi
153 +
154 + # Disable plugin by default
155 + sed -i -e 's/^loadplugin/\#loadplugin/g' \
156 + "rules/init.pre" \
157 + || die "failed to disable plugins by default"
158 +}
159 +
160 +src_configure() {
161 + # This is how and where the perl-module eclass disables the
162 + # MakeMaker interactive prompt.
163 + export PERL_MM_USE_DEFAULT=1
164 +
165 + # Set SYSCONFDIR explicitly so we can't get bitten by bug 48205 again
166 + # (just to be sure, nobody knows how it could happen in the first place).
167 + #
168 + # We also set the path to the perl executable explictly. This will be
169 + # used to create the initial shebang line in the scripts (bug 62276).
170 + perl Makefile.PL \
171 + PREFIX="${EPREFIX}/usr" \
172 + INSTALLDIRS=vendor \
173 + SYSCONFDIR="${EPREFIX}/etc" \
174 + DATADIR="${EPREFIX}/usr/share/spamassassin" \
175 + PERL_BIN="${EPREFIX}/usr/bin/perl" \
176 + ENABLE_SSL="$(usex ssl)" \
177 + DESTDIR="${D}" \
178 + || die 'failed to create a Makefile using Makefile.PL'
179 +
180 + # Now configure spamc.
181 +
182 + # Run autoreconf to avoid some issues caused by a standard test in the
183 + # current autoconf. Expected to be fixed in next autoconf release, so
184 + # these next 3 lines might not be needed for long. See bug #899782.
185 + pushd spamc >/dev/null
186 + eautoreconf
187 + popd >/dev/null
188 + emake CC="$(tc-getCC)" LDFLAGS="${LDFLAGS}" spamc/Makefile
189 +}
190 +
191 +src_compile() {
192 + emake
193 + use qmail && emake spamc/qmail-spamc
194 +}
195 +
196 +src_install () {
197 + default
198 +
199 + # Create the stub dir used by sa-update and friends
200 + keepdir /var/lib/spamassassin
201 +
202 + # Move spamd to sbin where it belongs.
203 + dodir /usr/sbin
204 + mv "${ED}"/usr/bin/spamd "${ED}"/usr/sbin/spamd || die "move spamd failed"
205 +
206 + if use qmail; then
207 + dobin spamc/qmail-spamc
208 + fi
209 +
210 + dosym mail/spamassassin /etc/spamassassin
211 +
212 + # Add the init and config scripts.
213 + newinitd "${FILESDIR}/3.4.1-spamd.init-r3" spamd
214 + newconfd "${FILESDIR}/3.4.1-spamd.conf-r1" spamd
215 +
216 + systemd_newunit "${FILESDIR}/${PN}.service-r4" "${PN}.service"
217 + systemd_install_serviced "${FILESDIR}/${PN}.service.conf-r2" \
218 + "${PN}.service"
219 +
220 + use postgres && dodoc sql/*_pg.sql
221 + use mysql && dodoc sql/*_mysql.sql
222 + use qmail && dodoc spamc/README.qmail
223 +
224 + # Rename some files so that they don't clash with others.
225 + newdoc spamd/README README.spamd
226 + newdoc sql/README README.sql
227 + newdoc ldap/README README.ldap
228 +
229 + insinto /etc/mail/spamassassin/
230 + newins "${FILESDIR}"/geoip-4.0.0.cf geoip.cf
231 + insopts -m0400
232 + newins "${FILESDIR}"/secrets.cf secrets.cf.example
233 +
234 + # Create the directory where sa-update stores its GPG key (if you
235 + # choose to import one). If this directory does not exist, the
236 + # import will fail. This is bug 396307. We expect that the import
237 + # will be performed as root, and making the directory accessible
238 + # only to root prevents a warning on the command-line.
239 + diropts -m0700
240 + dodir /etc/mail/spamassassin/sa-update-keys
241 +
242 + if use cron; then
243 + # Install the cron job if they want it.
244 + exeinto /etc/cron.daily
245 + newexe "${FILESDIR}/update-spamassassin-rules-r1.cron" \
246 + update-spamassassin-rules
247 + fi
248 +
249 + # Remove perllocal.pod to avoid file collisions (bug #603338).
250 + perl_delete_localpod
251 +
252 + # The perl-module eclass calls three other functions to clean
253 + # up in src_install. The first fixes references to ${D} in the
254 + # packlist, and is useful to us, too. The other two functions,
255 + # perl_delete_emptybsdir and perl_remove_temppath, don't seem
256 + # to be needed: there are no empty directories, *.bs files, or
257 + # ${D} paths remaining in our installed image.
258 + perl_fix_packlist
259 +}
260 +
261 +src_test() {
262 + # Trick the test suite into skipping the spamd tests. Setting
263 + # SPAMD_HOST to a non-localhost value causes SKIP_SPAMD_TESTS to be
264 + # set in SATest.pm.
265 + export SPAMD_HOST=disabled
266 + default
267 +}
268 +
269 +pkg_preinst() {
270 + if use mysql || use postgres ; then
271 + local _awlwarn=0
272 + local _v
273 + for _v in ${REPLACING_VERSIONS}; do
274 + if ver_test "${_v}" -lt "3.4.3"; then
275 + _awlwarn=1
276 + break
277 + fi
278 + done
279 + if [[ ${_awlwarn} == 1 ]] ; then
280 + ewarn 'If you used AWL before 3.4.3, the SQL schema has changed.'
281 + ewarn 'You will need to manually ALTER your tables for them to'
282 + ewarn 'continue working. See the UPGRADE documentation for'
283 + ewarn 'details.'
284 + ewarn
285 + fi
286 + fi
287 +}
288 +
289 +pkg_postinst() {
290 + elog
291 + elog 'No rules are installed by default. You will need to run sa-update'
292 + elog 'at least once, and most likely configure SpamAssassin before it'
293 + elog 'will work.'
294 +
295 + if ! use cron; then
296 + elog
297 + elog 'You should consider a cron job for sa-update. One is provided'
298 + elog 'for daily updates if you enable the "cron" USE flag.'
299 + fi
300 + elog
301 + elog 'Configuration and update help can be found on the wiki:'
302 + elog
303 + elog ' https://wiki.gentoo.org/wiki/SpamAssassin'
304 + elog
305 +
306 + if use mysql || use postgres ; then
307 + local _v
308 + for _v in ${REPLACING_VERSIONS}; do
309 + if ver_test "${_v}" -lt "3.4.3"; then
310 + ewarn
311 + ewarn 'If you used AWL before 3.4.3, the SQL schema has changed.'
312 + ewarn 'You will need to manually ALTER your tables for them to'
313 + ewarn 'continue working. See the UPGRADE documentation for'
314 + ewarn 'details.'
315 + ewarn
316 +
317 + # show this only once
318 + break
319 + fi
320 + done
321 + fi
322 +
323 + ewarn 'If this version of SpamAssassin causes permissions issues'
324 + ewarn 'with your user configurations or bayes databases, then you'
325 + ewarn 'may need to set SPAMD_RUN_AS_ROOT=true in your OpenRC service'
326 + ewarn 'configuration file, or remove the --username and --groupname'
327 + ewarn 'flags from the SPAMD_OPTS variable in your systemd service'
328 + ewarn 'configuration file.'
329 +
330 + if [[ ! ~spamd -ef "${ROOT}/var/lib/spamd" ]] ; then
331 + ewarn "The spamd user's home folder has been moved to a new location."
332 + elog
333 + elog "The acct-user/spamd package should have relocated it for you,"
334 + elog "but may have failed because your spamd daemon was running."
335 + elog
336 + elog "To fix this:"
337 + elog " - Stop your spamd daemon"
338 + elog " - emerge -1 acct-user/spamd"
339 + elog " - Restart your spamd daemon"
340 + elog " - Remove the old home folder if you want"
341 + elog " rm -rf \"${ROOT}/home/spamd\""
342 + fi
343 + if [[ -e "${ROOT}/home/spamd" ]] ; then
344 + ewarn
345 + ewarn "The spamd user's home folder has been moved to a new location."
346 + elog
347 + elog " Old Home: ${ROOT}/home/spamd"
348 + elog " New Home: ${ROOT}/var/lib/spamd"
349 + elog
350 + elog "You may wish to migrate your data to the new location:"
351 + elog " - Stop your spamd daemon"
352 + elog " - Re-emerge acct-user/spamd to ensure the home folder has been"
353 + elog " updated to the new location, now that the daemon isn't running:"
354 + elog " # emerge -1 acct-user/spamd"
355 + elog " # echo ~spamd"
356 + elog " - Migrate the contents from the old location to the new home"
357 + elog " For example:"
358 + elog " # cp -Rpi \"${ROOT}/home/spamd/\" \"${ROOT}/var/lib/\""
359 + elog " - Remove the old home folder"
360 + elog " # rm -rf \"${ROOT}/home/spamd\""
361 + elog " - Restart your spamd daemon"
362 + elog
363 + elog "If you do not wish to migrate data, you should remove the old"
364 + elog "home folder from your system as it is not used."
365 + fi
366 +}