Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: mail-filter/spamassassin/files/, mail-filter/spamassassin/
Date: Sun, 05 Jun 2016 22:38:07
Message-Id: 1465165980.bd452f87c73fb1dfb3050d980cdbf53f0382b216.mjo@gentoo
1 commit: bd452f87c73fb1dfb3050d980cdbf53f0382b216
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 5 22:20:19 2016 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Sun Jun 5 22:33:00 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bd452f87
7
8 mail-filter/spamassassin: new revision with an optional sa-update cron job.
9
10 To make life easier for our users, a cron job that runs sa-update
11 nightly has been provided. It is only installed with USE=cron, but an
12 elog will mention its existence when that USE flag is disabled. The
13 cron job will also attempt to restart or reload spamd/amavisd if the
14 signatures have been updated.
15
16 Alongside that new feature, some of the dependencies have been cleaned
17 up. Pointless version bounds were removed, and an obsolete perl module
18 or two was pruned. The libwww-perl dependency was replaced by
19 wget/curl.
20
21 Gentoo-Bug: 532094
22
23 Package-Manager: portage-2.2.28
24
25 .../files/update-spamassassin-rules.cron | 38 ++++
26 mail-filter/spamassassin/metadata.xml | 15 +-
27 .../spamassassin/spamassassin-3.4.1-r6.ebuild | 215 +++++++++++++++++++++
28 3 files changed, 262 insertions(+), 6 deletions(-)
29
30 diff --git a/mail-filter/spamassassin/files/update-spamassassin-rules.cron b/mail-filter/spamassassin/files/update-spamassassin-rules.cron
31 new file mode 100644
32 index 0000000..1b36af0
33 --- /dev/null
34 +++ b/mail-filter/spamassassin/files/update-spamassassin-rules.cron
35 @@ -0,0 +1,38 @@
36 +#!/bin/bash
37 +#
38 +# Update SpamAssassin rules and reload daemons that use them.
39 +#
40 +
41 +# First, redirect stdout to /dev/null.
42 +exec 1>/dev/null
43 +
44 +# Try to update the rules.
45 +sa-update
46 +
47 +# Exit code 0: all new updates were installed.
48 +# Exit code 1: we were already up-to-date.
49 +# Exit code 3: some updates were installed, but some weren't.
50 +# Any other exit code indicates failure.
51 +if (( $? == 0 || $? == 3 )); then
52 + # Compilation spits out its progress onto stderr.
53 + sa-compile 2>/dev/null
54 +
55 + # Do you run spamd or amavisd? Both daemons need to be reloaded
56 + # in order to pick up the newly-updated rules.
57 + if command -v rc-service 2>/dev/null; then
58 + # OpenRC is installed. These "status" checks should succeed
59 + # only when the daemon is running under OpenRC. We redirect
60 + # stderr to hide the lecture that OpenRC gives you if you
61 + # try this on a system running systemd.
62 + rc-service spamd status 2>/dev/null && rc-service spamd reload
63 + rc-service amavisd status 2>/dev/null && rc-service amavisd reload
64 + fi
65 +
66 + if command -v systemctl 2>/dev/null; then
67 + # The systemctl (systemd) executable is installed, so try to
68 + # use it to restart spamd and amavisd. These are safe to run
69 + # if systemd is installed but not in use.
70 + systemctl try-restart spamassassin
71 + systemctl try-restart amavisd
72 + fi
73 +fi
74
75 diff --git a/mail-filter/spamassassin/metadata.xml b/mail-filter/spamassassin/metadata.xml
76 index c24a432..e3f1239 100644
77 --- a/mail-filter/spamassassin/metadata.xml
78 +++ b/mail-filter/spamassassin/metadata.xml
79 @@ -3,10 +3,13 @@
80 <pkgmetadata>
81 <!-- maintainer-needed -->
82 <use>
83 - <flag name="qmail">Build qmail functionality and docs</flag>
84 - <flag name="bayes">
85 - Require a database (MySQL, SQLite, Postgres, or BerkDB) backend to
86 - enable the Bayesian filtering database.
87 - </flag>
88 -</use>
89 + <flag name="bayes">
90 + Require a database (MySQL, SQLite, Postgres, or BerkDB) backend
91 + to enable the Bayesian filtering database.
92 + </flag>
93 + <flag name="cron">
94 + Install a cron job to update SpamAssassin's rules daily.
95 + </flag>
96 + <flag name="qmail">Build qmail functionality and docs</flag>
97 + </use>
98 </pkgmetadata>
99
100 diff --git a/mail-filter/spamassassin/spamassassin-3.4.1-r6.ebuild b/mail-filter/spamassassin/spamassassin-3.4.1-r6.ebuild
101 new file mode 100644
102 index 0000000..461de34
103 --- /dev/null
104 +++ b/mail-filter/spamassassin/spamassassin-3.4.1-r6.ebuild
105 @@ -0,0 +1,215 @@
106 +# Copyright 1999-2016 Gentoo Foundation
107 +# Distributed under the terms of the GNU General Public License v2
108 +# $Id$
109 +
110 +EAPI=6
111 +
112 +inherit toolchain-funcs systemd
113 +
114 +MY_P=Mail-SpamAssassin-${PV//_/-}
115 +S=${WORKDIR}/${MY_P}
116 +DESCRIPTION="An extensible mail filter which can identify and tag spam"
117 +HOMEPAGE="http://spamassassin.apache.org/"
118 +SRC_URI="mirror://apache/spamassassin/source/${MY_P}.tar.bz2"
119 +
120 +LICENSE="Apache-2.0 GPL-2"
121 +SLOT="0"
122 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~x86-macos"
123 +IUSE="+bayes berkdb cron ipv6 ldap libressl mysql postgres qmail sqlite ssl test"
124 +
125 +# You can do without a database unless you need the Bayes features.
126 +REQUIRED_USE="bayes? ( || ( berkdb mysql postgres sqlite ) )"
127 +
128 +# SpamAssassin doesn't use libwww-perl except as a fallback for when
129 +# curl/wget are missing, so we depend on one of those instead. Some
130 +# mirrors use https, so we need those utilities to support SSL.
131 +#
132 +# re2c is needed to compile the rules (sa-compile).
133 +#
134 +DEPEND="app-crypt/gnupg
135 + dev-lang/perl
136 + dev-perl/Digest-SHA1
137 + dev-perl/Encode-Detect
138 + dev-perl/Geo-IP
139 + dev-perl/HTML-Parser
140 + dev-perl/HTTP-Date
141 + dev-perl/Mail-DKIM
142 + dev-perl/Mail-SPF
143 + dev-perl/Net-DNS
144 + dev-perl/Net-Patricia
145 + dev-perl/NetAddr-IP
146 + dev-util/re2c
147 + || ( net-misc/wget[ssl] net-misc/curl[ssl] )
148 + virtual/perl-Archive-Tar
149 + virtual/perl-IO-Zlib
150 + virtual/perl-MIME-Base64
151 + virtual/perl-Pod-Parser
152 + virtual/perl-Time-HiRes
153 + berkdb? ( virtual/perl-DB_File )
154 + ipv6? ( dev-perl/IO-Socket-INET6 )
155 + ldap? ( dev-perl/perl-ldap )
156 + mysql? (
157 + dev-perl/DBI
158 + dev-perl/DBD-mysql
159 + )
160 + postgres? (
161 + dev-perl/DBI
162 + dev-perl/DBD-Pg
163 + )
164 + sqlite? (
165 + dev-perl/DBI
166 + dev-perl/DBD-SQLite
167 + )
168 + ssl? (
169 + dev-perl/IO-Socket-SSL
170 + !libressl? ( dev-libs/openssl:0 )
171 + libressl? ( dev-libs/libressl )
172 + )"
173 +
174 +RDEPEND="${DEPEND}"
175 +
176 +# Some spamd tests fail, and it looks like the whole suite eventually
177 +# hangs.
178 +RESTRICT=test
179 +
180 +PATCHES=(
181 + "${FILESDIR}/spamassassin-3.4.1-bug_7199.patch"
182 + "${FILESDIR}/spamassassin-3.4.1-bug_7223.patch"
183 + "${FILESDIR}/spamassassin-3.4.1-bug_7231.patch"
184 + "${FILESDIR}/spamassassin-3.4.1-bug_7265.patch"
185 +)
186 +
187 +src_configure() {
188 + # spamc can be built with ssl support.
189 + local use_ssl="no"
190 + if use ssl; then
191 + use_ssl="yes"
192 + fi
193 +
194 + # Set SYSCONFDIR explicitly so we can't get bitten by bug 48205 again
195 + # (just to be sure, nobody knows how it could happen in the first place).
196 + #
197 + # We also set the path to the perl executable explictly. This will be
198 + # used to create the initial shebang line in the scripts (bug 62276).
199 + perl Makefile.PL \
200 + PREFIX="${EPREFIX}/usr" \
201 + INSTALLDIRS=vendor \
202 + SYSCONFDIR="${EPREFIX}/etc" \
203 + DATADIR="${EPREFIX}/usr/share/spamassassin" \
204 + PERL_BIN="${EPREFIX}/usr/bin/perl" \
205 + ENABLE_SSL="${use_ssl}" \
206 + DESTDIR="${D}" \
207 + || die "Unable to build!"
208 +
209 + # Now configure spamc.
210 + emake CC="$(tc-getCC)" LDFLAGS="${LDFLAGS}" spamc/Makefile
211 +}
212 +
213 +src_compile() {
214 + PERL_MM_USE_DEFAULT=1 emake
215 +
216 + if use qmail; then
217 + emake spamc/qmail-spamc
218 + fi
219 +}
220 +
221 +src_install () {
222 + emake install
223 + einstalldocs
224 +
225 + # Create the stub dir used by sa-update and friends
226 + keepdir /var/lib/spamassassin
227 +
228 + # Move spamd to sbin where it belongs.
229 + dodir /usr/sbin
230 + mv "${ED}"/usr/bin/spamd "${ED}"/usr/sbin/spamd || die "move spamd failed"
231 +
232 + if use qmail; then
233 + dobin spamc/qmail-spamc
234 + fi
235 +
236 + ln -s mail/spamassassin "${ED}"/etc/spamassassin || die
237 +
238 + # Disable plugin by default
239 + sed -i -e 's/^loadplugin/\#loadplugin/g' \
240 + "${ED}"/etc/mail/spamassassin/init.pre \
241 + || die "failed to disable plugins by default"
242 +
243 + # Add the init and config scripts.
244 + newinitd "${FILESDIR}"/3.4.1-spamd.init spamd
245 + newconfd "${FILESDIR}"/3.4.1-spamd.conf spamd
246 +
247 + systemd_newunit "${FILESDIR}"/${PN}.service-r1 ${PN}.service
248 + systemd_install_serviced "${FILESDIR}"/${PN}.service.conf
249 +
250 + # The sed statements in the following conditionals alter the init
251 + # script to depend (or not) on the database being running before
252 + # spamd is started. The sed commands either enable the dependency,
253 + # or delete the line entirely.
254 + if use postgres; then
255 + sed -i -e 's:@USEPOSTGRES@::' "${ED}/etc/init.d/spamd" || die
256 +
257 + dodoc sql/*_pg.sql
258 + else
259 + sed -i -e '/@USEPOSTGRES@/d' "${ED}/etc/init.d/spamd" || die
260 + fi
261 +
262 + if use mysql; then
263 + sed -i -e 's:@USEMYSQL@::' "${ED}/etc/init.d/spamd" || die
264 +
265 + dodoc sql/*_mysql.sql
266 + else
267 + sed -i -e '/@USEMYSQL@/d' "${ED}/etc/init.d/spamd" || die
268 + fi
269 +
270 + dodoc NOTICE TRADEMARK CREDITS UPGRADE USAGE sql/README.bayes \
271 + sql/README.awl procmailrc.example sample-nonspam.txt \
272 + sample-spam.txt spamd/PROTOCOL spamd/README.vpopmail \
273 + spamd-apache2/README.apache
274 +
275 + # Rename some files so that they don't clash with others.
276 + newdoc spamd/README README.spamd
277 + newdoc sql/README README.sql
278 + newdoc ldap/README README.ldap
279 +
280 + if use qmail; then
281 + dodoc spamc/README.qmail
282 + fi
283 +
284 + insinto /etc/mail/spamassassin/
285 + insopts -m0400
286 + newins "${FILESDIR}"/secrets.cf secrets.cf.example
287 +
288 + # Create the directory where sa-update stores its GPG key (if you
289 + # choose to import one). If this directory does not exist, the
290 + # import will fail. This is bug 396307. We expect that the import
291 + # will be performed as root, and making the directory accessible
292 + # only to root prevents a warning on the command-line.
293 + diropts -m0700
294 + dodir /etc/mail/spamassassin/sa-update-keys
295 +
296 + if use cron; then
297 + # Install the cron job if they want it.
298 + exeinto /etc/cron.daily
299 + newexe "${FILESDIR}/update-spamassassin-rules.cron" \
300 + update-spamassassin-rules
301 + fi
302 +}
303 +
304 +pkg_postinst() {
305 + elog
306 + elog 'No rules are installed by default. You will need to run sa-update'
307 + elog 'at least once, and most likely configure SpamAssassin before it'
308 + elog 'will work.'
309 +
310 + if ! use cron; then
311 + elog
312 + elog 'You should consider a cron job for sa-update. One is provided'
313 + elog 'for daily updates if you enable the "cron" USE flag.'
314 + fi
315 + elog
316 + elog 'Configuration and update help can be found on the wiki:'
317 + elog
318 + elog ' https://wiki.gentoo.org/wiki/SpamAssassin'
319 + elog
320 +}