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