1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
7 DESCRIPTION="High-performance interface between the MTA and content checkers"
8 HOMEPAGE="https://gitlab.com/amavis/amavis"
9 SRC_URI="https://gitlab.com/amavis/amavis/-/archive/${P}/amavis-${P}.tar.gz"
13 KEYWORDS="amd64 hppa ~ppc ppc64 sparc x86"
14 IUSE="clamav courier dkim ldap mysql postgres qmail razor snmp spamassassin zmq"
16 DEPEND=">=sys-apps/sed-4
17 >=dev-lang/perl-5.10.0"
20 >=sys-apps/coreutils-5.0-r3
37 >=dev-perl/Archive-Zip-1.14
38 >=virtual/perl-IO-Compress-1.35
39 >=virtual/perl-Compress-Raw-Zlib-2.017
41 virtual/perl-MIME-Base64
42 >=dev-perl/MIME-tools-5.415
43 >=dev-perl/MailTools-1.58
44 >=dev-perl/Net-Server-0.91
45 virtual/perl-Digest-MD5
47 virtual/perl-IO-Socket-IP
48 >=virtual/perl-Time-HiRes-1.49
51 dev-perl/File-LibMagic
54 dev-perl/Convert-BinHex
55 >=dev-perl/Mail-DKIM-0.31
56 virtual/perl-File-Temp
58 dev-perl/IO-Socket-SSL
60 clamav? ( app-antivirus/clamav )
61 ldap? ( >=dev-perl/perl-ldap-0.33 )
62 mysql? ( dev-perl/DBD-mysql )
63 postgres? ( dev-perl/DBD-Pg )
64 razor? ( mail-filter/razor )
65 snmp? ( net-analyzer/net-snmp[perl] )
66 spamassassin? ( mail-filter/spamassassin dev-perl/Image-Info )
67 zmq? ( dev-perl/ZMQ-LibZMQ3 )"
69 AMAVIS_ROOT="/var/amavis"
70 S="${WORKDIR}/amavis-${P}"
73 # Create the user beforehand so that we can install the config file
74 # (and some directories) with group "amavis" in src_install().
76 enewuser amavis -1 -1 "${AMAVIS_ROOT}" amavis
80 # amavisd-new version 2.11.0 breaks DKIM signing of outbound mail,
81 # see https://bugs.gentoo.org/603582
82 eapply "${FILESDIR}/amavisd-2.11.0-dkim.patch"
85 eapply -p0 amavisd-new-courier.patch
89 eapply -p0 amavisd-new-qmqpqq.patch
92 # We need to fix the daemon_user and daemon_group in amavis-mc even
93 # though we're going to run it in the foreground, because it calls
94 # "drop_priv" unconditionally and will crash if its user/group
97 -e '/daemon/s/vscan/amavis/' \
98 -e "s:'/var/virusmails':\"\$MYHOME/quarantine\":" \
99 "${S}/amavisd.conf" "${S}/amavis-mc" || die "missing conf file"
102 sed -i -e '/enable_dkim/s/1/0/' "${S}/amavisd.conf" \
103 || die "missing conf file - dkim"
107 sed -i -e '/enable_zmq/s/# //' "${S}/amavisd.conf" \
108 || die "missing conf file - zmq"
111 if ! use spamassassin ; then
113 "/^#[[:space:]]*@bypass_spam_checks_maps[[:space:]]*=[[:space:]]*(1)/s/^#//" \
114 "${S}/amavisd.conf" || die "missing conf file - sa"
121 dosbin amavisd{,-agent,-nanny,-release,-signer,-status}
122 dobin p0f-analyzer.pl amavisd-submit
125 dosbin amavisd-snmp-subagent
126 newinitd "${FILESDIR}/amavisd-snmp-subagent.initd" \
127 amavisd-snmp-subagent
131 dosbin amavisd-snmp-subagent-zmq
132 newinitd "${FILESDIR}/amavisd-snmp-subagent-zmq.initd" \
133 amavisd-snmp-subagent-zmq
138 dosbin amavis-services amavis-mc
139 newinitd "${FILESDIR}/amavis-mc.initd-r1" amavis-mc
143 dodir /etc/openldap/schema
144 insinto /etc/openldap/schema
145 newins LDAP.schema "${PN}.schema"
148 # The config file should be root:amavis so that the amavis user can
149 # read (only) it after dropping privileges. And of course he should
150 # own everything in his home directory.
152 insopts -m0640 -g amavis
155 # Implementation detail? Keepdir calls dodir under the hood.
156 diropts -o amavis -g amavis
157 keepdir "${AMAVIS_ROOT}"/{,db,quarantine,tmp,var}
161 # Anything below this line is using the mangled insopts/diropts from
165 newinitd "${FILESDIR}/amavisd.initd-r2" amavisd
167 systemd_newunit "${FILESDIR}/amavisd.service-r1" amavisd.service
169 dodoc AAAREADME.first INSTALL MANIFEST RELEASE_NOTES TODO \
170 amavisd.conf-default amavisd-custom.conf
173 dodoc README_FILES/README*
174 dodoc -r README_FILES/*.{html,css}
175 docinto README_FILES/images
176 dodoc README_FILES/images/*.png
177 docinto README_FILES/images/callouts
178 dodoc README_FILES/images/callouts/*.png
180 docinto test-messages
181 dodoc test-messages/README
182 dodoc test-messages/sample.tar.gz.compl
186 # TODO: the following is done as root, but should probably be done
187 # as the amavis user.
189 if [ ! -d "${ROOT}${AMAVIS_ROOT}/.razor" ] ; then
190 elog "Setting up initial razor config files..."
192 razor-admin -create -home="${D}/${AMAVIS_ROOT}/.razor"
193 sed -i -e "s:debuglevel\([ ]*\)= .:debuglevel\1= 0:g" \
194 "${D}/${AMAVIS_ROOT}/.razor/razor-agent.conf" || die