Gentoo Archives: gentoo-commits

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