1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit perl-functions systemd toolchain-funcs user
8 MY_P="Mail-SpamAssassin-${PV//_/-}"
10 DESCRIPTION="An extensible mail filter which can identify and tag spam"
11 HOMEPAGE="https://spamassassin.apache.org/"
12 SRC_URI="mirror://apache/spamassassin/source/${MY_P}.tar.bz2"
14 LICENSE="Apache-2.0 GPL-2"
16 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~x86-macos"
17 IUSE="berkdb cron ipv6 ldap libressl mysql postgres qmail sqlite ssl test"
19 # The Makefile.PL script checks for dependencies, but only fails if a
20 # required (i.e. not optional) dependency is missing. We therefore
21 # require most of the optional modules only at runtime.
22 REQDEPEND="dev-lang/perl:=
26 virtual/perl-Archive-Tar
27 virtual/perl-Digest-SHA
29 virtual/perl-Time-HiRes
31 !libressl? ( dev-libs/openssl:0 )
32 libressl? ( dev-libs/libressl )
35 # SpamAssassin doesn't use libwww-perl except as a fallback for when
36 # curl/wget are missing, so we depend on one of those instead. Some
37 # mirrors use https, so we need those utilities to support SSL.
39 # re2c is needed to compile the rules (sa-compile).
41 # We still need the old Digest-SHA1 because razor2 has not been ported
43 OPTDEPEND="app-crypt/gnupg
45 dev-perl/Encode-Detect
51 dev-perl/Net-CIDR-Lite
53 || ( net-misc/wget[ssl] net-misc/curl[ssl] )
54 virtual/perl-MIME-Base64
55 virtual/perl-Pod-Parser
56 berkdb? ( virtual/perl-DB_File )
57 ipv6? ( dev-perl/IO-Socket-INET6 )
58 ldap? ( dev-perl/perl-ldap )
71 ssl? ( dev-perl/IO-Socket-SSL )"
76 virtual/perl-Test-Harness
78 RDEPEND="${REQDEPEND} ${OPTDEPEND}"
81 "${FILESDIR}/spamassassin-3.4.1-bug_7199.patch"
82 "${FILESDIR}/spamassassin-3.4.1-bug_7223.patch"
83 "${FILESDIR}/spamassassin-3.4.1-bug_7231.patch"
84 "${FILESDIR}/spamassassin-3.4.1-bug_7265.patch"
85 "${FILESDIR}/spamassassin-3.4.1-bug_7231-extra.patch"
86 "${FILESDIR}/spamassassin-3.4.1-bug_7404.patch"
87 "${FILESDIR}/spamassassin-3.4.1-bug_7462.patch"
88 "${FILESDIR}/spamassassin-3.4.1-perl526.patch"
89 "${FILESDIR}/spamassassin-3.4.1-bug_7361.patch"
95 # The sa_compile test does some weird stuff like hopping around in
96 # the directory tree and calling "make" to create a dist tarball
97 # from ${S}. It fails, and is more trouble than it's worth...
98 perl_rm_files t/sa_compile.t || die 'failed to remove sa_compile test'
100 # The spamc tests (which need the networked spamd daemon) fail for
101 # irrelevant reasons. It's too hard to disable them (unlike the
102 # spamd tests themselves -- see src_test), so use a crude
104 perl_rm_files t/spamc_*.t || die 'failed to remove spamc tests'
108 # This is how and where the perl-module eclass disables the
109 # MakeMaker interactive prompt.
110 export PERL_MM_USE_DEFAULT=1
112 # Set SYSCONFDIR explicitly so we can't get bitten by bug 48205 again
113 # (just to be sure, nobody knows how it could happen in the first place).
115 # We also set the path to the perl executable explictly. This will be
116 # used to create the initial shebang line in the scripts (bug 62276).
118 PREFIX="${EPREFIX}/usr" \
120 SYSCONFDIR="${EPREFIX}/etc" \
121 DATADIR="${EPREFIX}/usr/share/spamassassin" \
122 PERL_BIN="${EPREFIX}/usr/bin/perl" \
123 ENABLE_SSL="$(usex ssl)" \
125 || die 'failed to create a Makefile using Makefile.PL'
127 # Now configure spamc.
128 emake CC="$(tc-getCC)" LDFLAGS="${LDFLAGS}" spamc/Makefile
133 use qmail && emake spamc/qmail-spamc
140 # Create the stub dir used by sa-update and friends
141 keepdir /var/lib/spamassassin
143 # Move spamd to sbin where it belongs.
145 mv "${ED}"/usr/bin/spamd "${ED}"/usr/sbin/spamd || die "move spamd failed"
148 dobin spamc/qmail-spamc
151 ln -s mail/spamassassin "${ED}"/etc/spamassassin || die
153 # Disable plugin by default
154 sed -i -e 's/^loadplugin/\#loadplugin/g' \
155 "${ED}/etc/mail/spamassassin/init.pre" \
156 || die "failed to disable plugins by default"
158 # Add the init and config scripts.
159 newinitd "${FILESDIR}/3.4.1-spamd.init-r2" spamd
160 newconfd "${FILESDIR}/3.4.1-spamd.conf-r1" spamd
162 systemd_newunit "${FILESDIR}/${PN}.service-r3" "${PN}.service"
163 systemd_install_serviced "${FILESDIR}/${PN}.service.conf-r1" \
166 use postgres && dodoc sql/*_pg.sql
167 use mysql && dodoc sql/*_mysql.sql
169 dodoc NOTICE TRADEMARK CREDITS UPGRADE USAGE sql/README.bayes \
170 sql/README.awl procmailrc.example sample-nonspam.txt \
171 sample-spam.txt spamd/PROTOCOL spamd/README.vpopmail \
172 spamd-apache2/README.apache
174 # Rename some files so that they don't clash with others.
175 newdoc spamd/README README.spamd
176 newdoc sql/README README.sql
177 newdoc ldap/README README.ldap
180 dodoc spamc/README.qmail
183 insinto /etc/mail/spamassassin/
185 newins "${FILESDIR}"/secrets.cf secrets.cf.example
187 # Create the directory where sa-update stores its GPG key (if you
188 # choose to import one). If this directory does not exist, the
189 # import will fail. This is bug 396307. We expect that the import
190 # will be performed as root, and making the directory accessible
191 # only to root prevents a warning on the command-line.
193 dodir /etc/mail/spamassassin/sa-update-keys
196 # Install the cron job if they want it.
197 exeinto /etc/cron.daily
198 newexe "${FILESDIR}/update-spamassassin-rules.cron" \
199 update-spamassassin-rules
202 # Remove perllocal.pod to avoid file collisions (bug #603338).
203 perl_delete_localpod || die "failed to remove perllocal.pod"
205 # The perl-module eclass calls three other functions to clean
206 # up in src_install. The first fixes references to ${D} in the
207 # packlist, and is useful to us, too. The other two functions,
208 # perl_delete_emptybsdir and perl_remove_temppath, don't seem
209 # to be needed: there are no empty directories, *.bs files, or
210 # ${D} paths remaining in our installed image.
211 perl_fix_packlist || die "failed to fix paths in packlist"
215 # Trick the test suite into skipping the spamd tests. Setting
216 # SPAMD_HOST to a non-localhost value causes SKIP_SPAMD_TESTS to be
218 export SPAMD_HOST=disabled
223 # The spamd daemon runs as this user. Use a real home directory so
224 # that it can hold SA configuration.
225 enewuser spamd -1 -1 /home/spamd
230 elog 'No rules are installed by default. You will need to run sa-update'
231 elog 'at least once, and most likely configure SpamAssassin before it'
236 elog 'You should consider a cron job for sa-update. One is provided'
237 elog 'for daily updates if you enable the "cron" USE flag.'
240 elog 'Configuration and update help can be found on the wiki:'
242 elog ' https://wiki.gentoo.org/wiki/SpamAssassin'
245 ewarn 'If this version of SpamAssassin causes permissions issues'
246 ewarn 'with your user configurations or bayes databases, you may'
247 ewarn 'need to set SPAMD_RUN_AS_ROOT=true in your OpenRC service'
248 ewarn 'configuration file.'