Gentoo Archives: gentoo-commits

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