mail-filter/spamassassin: new revision to fix tests and improve init script.

This commit adds an upstream patch to fix a test suite crash with
newer versions of perl. It also largely rewrites the init script:

  * Don't conditionally "use mysql" or "use postgres" in the
    OpenRC init script. Even if SpamAssassin is installed without
    e.g. MySQL support, if MySQL is present on the system, a user
    might store his SpamAssassin data in it.

  * Use a declarative style and drop the custom start() and stop()
    functions.

  * Run the spamd daemon as the "spamd" user.

  * Use /run/spamd.pid for the PID file to avoid a "checkpath".

Some updates were made to the ebuild to facilitate those changes:

  * Don't modify the init script for USE=mysql or USE=postgres.

  * Create a "spamd" user in pkg_preinst().

Package-Manager: Portage-2.3.6, Repoman-2.3.1
This commit is contained in:
Michael Orlitzky
2017-08-20 10:32:43 -04:00
parent e4293e3d5d
commit 52480637e8
3 changed files with 68 additions and 21 deletions
+34
View File
@@ -0,0 +1,34 @@
#!/sbin/openrc-run
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
command="/usr/sbin/spamd"
pidfile="/run/spamd.pid"
command_args="--username=spamd
--groupname=spamd
--pidfile=${pidfile}
${SPAMD_OPTS}"
command_args_background="--daemonize"
: ${SPAMD_NICELEVEL:=0}
start_stop_daemon_args="--nicelevel ${SPAMD_NICELEVEL}"
# Retry after SPAMD_TIMEOUT seconds because spamd can take a
# while to kill off all of its children. This was bug 322025.
: ${SPAMD_TIMEOUT:=15}
retry="${SPAMD_TIMEOUT}"
extra_started_commands="reload"
depend() {
before mta
use logger mysql postgres
}
reload() {
ebegin "Reloading configuration"
# Warning: reload causes the PID of the spamd process to
# change, but spamd does update its PID file afterwards.
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}
@@ -0,0 +1,23 @@
--- a/lib/Mail/SpamAssassin/PerMsgStatus.pm (revision 1790817)
+++ b/lib/Mail/SpamAssassin/PerMsgStatus.pm (working copy)
@@ -896,16 +896,16 @@
$str .= shift @{$ary};
}
undef $ary;
- chomp ($str); $str .= " [...]\n";
# in case the last line was huge, trim it back to around 200 chars
local $1;
- $str =~ s/^(.{,200}).*$/$1/gs;
+ $str =~ s/^(.{200}).+$/$1 [...]/gm;
+ chomp ($str); $str .= "\n";
# now, some tidy-ups that make things look a bit prettier
- $str =~ s/-----Original Message-----.*$//gs;
+ $str =~ s/-----Original Message-----.*$//gm;
$str =~ s/This is a multi-part message in MIME format\.//gs;
- $str =~ s/[-_\*\.]{10,}//gs;
+ $str =~ s/[-_*.]{10,}//gs;
$str =~ s/\s+/ /gs;
# add "Content preview:" ourselves, so that the text aligns
@@ -3,7 +3,7 @@
EAPI=6
inherit perl-functions systemd toolchain-funcs
inherit perl-functions systemd toolchain-funcs user
MY_P="Mail-SpamAssassin-${PV//_/-}"
S="${WORKDIR}/${MY_P}"
@@ -83,6 +83,7 @@ PATCHES=(
"${FILESDIR}/spamassassin-3.4.1-bug_7231.patch"
"${FILESDIR}/spamassassin-3.4.1-bug_7265.patch"
"${FILESDIR}/spamassassin-3.4.1-bug_7231-extra.patch"
"${FILESDIR}/spamassassin-3.4.1-bug_7404.patch"
"${FILESDIR}/spamassassin-3.4.1-perl526.patch"
)
@@ -153,31 +154,14 @@ src_install () {
|| die "failed to disable plugins by default"
# Add the init and config scripts.
newinitd "${FILESDIR}/3.4.1-spamd.init" spamd
newinitd "${FILESDIR}/3.4.1-spamd.init-r1" spamd
newconfd "${FILESDIR}/3.4.1-spamd.conf" spamd
systemd_newunit "${FILESDIR}/${PN}.service-r1" "${PN}.service"
systemd_install_serviced "${FILESDIR}/${PN}.service.conf"
# The sed statements in the following conditionals alter the init
# script to depend (or not) on the database being running before
# spamd is started. The sed commands either enable the dependency,
# or delete the line entirely.
if use postgres; then
sed -i -e 's:@USEPOSTGRES@::' "${ED}/etc/init.d/spamd" || die
dodoc sql/*_pg.sql
else
sed -i -e '/@USEPOSTGRES@/d' "${ED}/etc/init.d/spamd" || die
fi
if use mysql; then
sed -i -e 's:@USEMYSQL@::' "${ED}/etc/init.d/spamd" || die
dodoc sql/*_mysql.sql
else
sed -i -e '/@USEMYSQL@/d' "${ED}/etc/init.d/spamd" || die
fi
use postgres && dodoc sql/*_pg.sql
use mysql && dodoc sql/*_mysql.sql
dodoc NOTICE TRADEMARK CREDITS UPGRADE USAGE sql/README.bayes \
sql/README.awl procmailrc.example sample-nonspam.txt \
@@ -232,6 +216,12 @@ src_test() {
default
}
pkg_preinst() {
# The spamd daemon runs as this user. Use a real home directory so
# that it can hold SA configuration.
enewuser spamd -1 -1 /home/spamd
}
pkg_postinst() {
elog
elog 'No rules are installed by default. You will need to run sa-update'