Merge github#881: dev-python/spyder: Version bump.
[gentoo.git] / mail-mta / exim / exim-4.86-r2.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit eutils toolchain-funcs multilib pam systemd
8
9 IUSE="dane dcc +dkim dlfunc dmarc +dnsdb doc dovecot-sasl dsn exiscan-acl gnutls ipv6 ldap libressl lmtp maildir mbx mysql nis pam perl pkcs11 postgres +prdr proxy radius redis sasl selinux spf sqlite srs ssl syslog tcpd tpda X"
10 REQUIRED_USE="spf? ( exiscan-acl ) srs? ( exiscan-acl ) dmarc? ( spf dkim ) pkcs11? ( gnutls )"
11
12 COMM_URI="ftp://ftp.exim.org/pub/exim/exim4$([[ ${PV} == *_rc* ]] && echo /test)"
13
14 DESCRIPTION="A highly configurable, drop-in replacement for sendmail"
15 SRC_URI="${COMM_URI}/${P//rc/RC}.tar.bz2
16         mirror://gentoo/system_filter.exim.gz
17         doc? ( ${COMM_URI}/${PN}-html-${PV//rc/RC}.tar.bz2 )"
18 HOMEPAGE="http://www.exim.org/"
19
20 SLOT="0"
21 LICENSE="GPL-2"
22 KEYWORDS="~amd64 ~arm ~hppa ~ppc64 ~x86"
23
24 COMMON_DEPEND=">=sys-apps/sed-4.0.5
25         >=sys-libs/db-3.2
26         dev-libs/libpcre
27         perl? ( dev-lang/perl:= )
28         pam? ( virtual/pam )
29         tcpd? ( sys-apps/tcp-wrappers )
30         ssl? (
31                 !libressl? ( dev-libs/openssl:0=[-bindist] )
32                 libressl? ( dev-libs/libressl:= )
33         )
34         gnutls? ( net-libs/gnutls[pkcs11?]
35                           dev-libs/libtasn1 )
36         ldap? ( >=net-nds/openldap-2.0.7 )
37         mysql? ( virtual/mysql )
38         postgres? ( dev-db/postgresql )
39         sasl? ( >=dev-libs/cyrus-sasl-2.1.26-r2 )
40         redis? ( dev-libs/hiredis )
41         spf? ( >=mail-filter/libspf2-1.2.5-r1 )
42         dmarc? ( mail-filter/opendmarc )
43         srs? ( mail-filter/libsrs_alt )
44         X? ( x11-proto/xproto
45                 x11-libs/libX11
46                 x11-libs/libXmu
47                 x11-libs/libXt
48                 x11-libs/libXaw
49         )
50         sqlite? ( dev-db/sqlite )
51         radius? ( net-dialup/freeradius-client )
52         virtual/libiconv
53         "
54         # added X check for #57206
55 DEPEND="${COMMON_DEPEND}
56         virtual/pkgconfig"
57 RDEPEND="${COMMON_DEPEND}
58         !mail-mta/courier
59         !mail-mta/esmtp
60         !mail-mta/mini-qmail
61         !<mail-mta/msmtp-1.4.19-r1
62         !>=mail-mta/msmtp-1.4.19-r1[mta]
63         !mail-mta/netqmail
64         !mail-mta/nullmailer
65         !mail-mta/postfix
66         !mail-mta/qmail-ldap
67         !mail-mta/sendmail
68         !mail-mta/opensmtpd
69         !<mail-mta/ssmtp-2.64-r2
70         !>=mail-mta/ssmtp-2.64-r2[mta]
71         !net-mail/mailwrapper
72         >=net-mail/mailbase-0.00-r5
73         virtual/logger
74         dcc? ( mail-filter/dcc )
75         selinux? ( sec-policy/selinux-exim )
76         "
77
78 S=${WORKDIR}/${P//rc/RC}
79
80 src_prepare() {
81         epatch "${FILESDIR}"/exim-4.14-tail.patch
82         epatch "${FILESDIR}"/exim-4.74-localscan_dlopen.patch
83         epatch "${FILESDIR}"/exim-4.69-r1.27021.patch
84         epatch "${FILESDIR}"/exim-4.74-radius-db-ENV-clash.patch # 287426
85         epatch "${FILESDIR}"/exim-4.82-makefile-freebsd.patch # 235785
86         epatch "${FILESDIR}"/exim-4.77-as-needed-ldflags.patch # 352265, 391279
87         epatch "${FILESDIR}"/exim-4.76-crosscompile.patch # 266591
88         epatch "${FILESDIR}"/exim-4.86-radius-type-fix.patch
89         epatch "${FILESDIR}"/exim-4.86-radius-include.patch
90         epatch "${FILESDIR}"/exim-4.86-TMPDIR.patch # 63420
91
92         if use maildir ; then
93                 epatch "${FILESDIR}"/exim-4.20-maildir.patch
94         else
95                 epatch "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
96         fi
97
98         # user Exim believes it should be
99         MAILUSER=mail
100         MAILGROUP=mail
101         if use prefix && [[ ${EUID} != 0 ]] ; then
102                 MAILUSER=$(id -un)
103                 MAILGROUP=$(id -gn)
104         fi
105 }
106
107 src_configure() {
108         # general config and paths
109
110         sed -i.orig \
111                 -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${EPREFIX}/etc/mail/aliases'" \
112                 "${S}"/src/configure.default || die
113
114         sed -i -e 's/^buildname=.*/buildname=exim-gentoo/g' Makefile || die
115
116         sed -e "48i\CFLAGS=${CFLAGS}" \
117                 -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=${EPREFIX}/usr/sbin:" \
118                 -e "s:EXIM_USER=:EXIM_USER=${MAILUSER}:" \
119                 -e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=${EPREFIX}/etc/exim/exim.conf:" \
120                 -e "s:ZCAT_COMMAND=.*$:ZCAT_COMMAND=${EPREFIX}/bin/zcat:" \
121                 -e "s:COMPRESS_COMMAND=.*$:COMPRESS_COMMAND=${EPREFIX}/bin/gzip:" \
122                 src/EDITME > Local/Makefile
123
124         cd Local
125
126         cat >> Makefile <<- EOC
127                 INFO_DIRECTORY=${EPREFIX}/usr/share/info
128                 PID_FILE_PATH=${EPREFIX}/run/exim.pid
129                 SPOOL_DIRECTORY=${EPREFIX}/var/spool/exim
130                 HAVE_ICONV=yes
131         EOC
132
133         # if we use libiconv, now is the time to tell so
134         use !elibc_glibc && echo "EXTRALIBS_EXIM=-liconv" >> Makefile
135
136         # support for IPv6
137         if use ipv6; then
138                 cat >> Makefile <<- EOC
139                         HAVE_IPV6=YES
140                 EOC
141         fi
142
143         #
144         # mail storage formats
145
146         # mailstore is Exim's traditional storage format
147         cat >> Makefile <<- EOC
148                 SUPPORT_MAILSTORE=yes
149         EOC
150
151         # mbox
152         if use mbx; then
153                 cat >> Makefile <<- EOC
154                         SUPPORT_MBX=yes
155                 EOC
156         fi
157
158         # maildir
159         if use maildir; then
160                 cat >> Makefile <<- EOC
161                         SUPPORT_MAILDIR=yes
162                 EOC
163         fi
164
165         #
166         # lookup methods
167
168         # use the "native" interfaces to the DBM and CDB libraries, support
169         # passwd and directory lookups by default
170         cat >> Makefile <<- EOC
171                 USE_DB=yes
172                 DBMLIB=-ldb
173                 LOOKUP_CDB=yes
174                 LOOKUP_PASSWD=yes
175                 LOOKUP_DSEARCH=yes
176         EOC
177
178         if ! use dnsdb; then
179                 # DNSDB lookup is enabled by default
180                 sed -i "s:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:" Makefile
181         fi
182
183         if use ldap; then
184                 cat >> Makefile <<- EOC
185                         LOOKUP_LDAP=yes
186                         LDAP_LIB_TYPE=OPENLDAP2
187                         LOOKUP_INCLUDE += -I"${EROOT}"usr/include/ldap
188                         LOOKUP_LIBS += -lldap -llber
189                 EOC
190         fi
191
192         if use mysql; then
193                 cat >> Makefile <<- EOC
194                         LOOKUP_MYSQL=yes
195                         LOOKUP_INCLUDE += $(mysql_config --include)
196                         LOOKUP_LIBS += $(mysql_config --libs)
197                 EOC
198         fi
199
200         if use nis; then
201                 cat >> Makefile <<- EOC
202                         LOOKUP_NIS=yes
203                         LOOKUP_NISPLUS=yes
204                 EOC
205         fi
206
207         if use postgres; then
208                 cat >> Makefile <<- EOC
209                         LOOKUP_PGSQL=yes
210                         LOOKUP_INCLUDE += -I$(pg_config --includedir)
211                         LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
212                 EOC
213         fi
214
215         if use sqlite; then
216                 cat >> Makefile <<- EOC
217                         LOOKUP_SQLITE=yes
218                         LOOKUP_SQLITE_PC=sqlite3
219                 EOC
220         fi
221
222         if use redis; then
223                 cat >> Makefile <<- EOC
224                         EXPERIMENTAL_REDIS=yes
225                         LOOKUP_LIBS += -lhiredis
226                 EOC
227         fi
228
229         #
230         # Exim monitor, enabled by default, controlled via X USE-flag,
231         # disable if not requested, bug #46778
232         if use X; then
233                 cp ../exim_monitor/EDITME eximon.conf || die
234         else
235                 sed -i -e '/^EXIM_MONITOR=/s/^/# /' Makefile
236         fi
237
238         #
239         # features
240
241         # content scanning support
242         if use exiscan-acl; then
243                 cat >> Makefile <<- EOC
244                         WITH_CONTENT_SCAN=yes
245                         WITH_OLD_DEMIME=yes
246                 EOC
247         fi
248
249         # DomainKeys Identified Mail, RFC4871
250         if ! use dkim; then
251                 # DKIM is enabled by default
252                 cat >> Makefile <<- EOC
253                         DISABLE_DKIM=yes
254                 EOC
255         fi
256
257         # Per-Recipient-Data-Response
258         if ! use prdr; then
259                 # PRDR is enabled by default
260                 cat >> Makefile <<- EOC
261                         DISABLE_PRDR=yes
262                 EOC
263         fi
264
265         # log to syslog
266         if use syslog; then
267                 sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Makefile
268                 cat >> Makefile <<- EOC
269                         LOG_FILE_PATH=syslog
270                 EOC
271         else
272                 cat >> Makefile <<- EOC
273                         LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
274                 EOC
275         fi
276
277         # starttls support (ssl)
278         if use ssl; then
279                 echo "SUPPORT_TLS=yes" >> Makefile
280                 if use gnutls; then
281                         echo "USE_GNUTLS=yes" >> Makefile
282                         echo "USE_GNUTLS_PC=gnutls" >> Makefile
283                         use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
284                 else
285                         echo "USE_OPENSSL_PC=openssl" >> Makefile
286                 fi
287         fi
288
289         # TCP wrappers
290         if use tcpd; then
291                 cat >> Makefile <<- EOC
292                         USE_TCP_WRAPPERS=yes
293                         EXTRALIBS_EXIM += -lwrap
294                 EOC
295         fi
296
297         # Light Mail Transport Protocol
298         if use lmtp; then
299                 cat >> Makefile <<- EOC
300                         TRANSPORT_LMTP=yes
301                 EOC
302         fi
303
304         # embedded Perl
305         if use perl; then
306                 cat >> Makefile <<- EOC
307                         EXIM_PERL=perl.o
308                 EOC
309         fi
310
311         # dlfunc
312         if use dlfunc; then
313                 cat >> Makefile <<- EOC
314                         EXPAND_DLFUNC=yes
315                 EOC
316         fi
317
318         #
319         # experimental features
320
321         # DANE
322         if use dane; then
323                 cat >> Makefile <<- EOC
324                         EXPERIMENTAL_DANE=yes
325                 EOC
326         fi
327
328         # Distributed Checksum Clearinghouse
329         if use dcc; then
330                 echo "EXPERIMENTAL_DCC=yes">> Makefile
331         fi
332
333         # Sender Policy Framework
334         if use spf; then
335                 cat >> Makefile <<- EOC
336                         EXPERIMENTAL_SPF=yes
337                         EXTRALIBS_EXIM += -lspf2
338                 EOC
339         fi
340
341         # Sender Rewriting Scheme
342         if use srs; then
343                 cat >> Makefile <<- EOC
344                         EXPERIMENTAL_SRS=yes
345                         EXTRALIBS_EXIM += -lsrs_alt
346                 EOC
347         fi
348
349         # DMARC
350         if use dmarc; then
351                 cat >> Makefile <<- EOC
352                         EXPERIMENTAL_DMARC=yes
353                         EXTRALIBS_EXIM += -lopendmarc
354                 EOC
355         fi
356
357         # Transport post-delivery actions
358         if use tpda; then
359                 cat >> Makefile <<- EOC
360                         EXPERIMENTAL_EVENT=yes
361                 EOC
362         fi
363
364         # Proxy Protocol
365         if use proxy; then
366                 cat >> Makefile <<- EOC
367                         EXPERIMENTAL_PROXY=yes
368                 EOC
369         fi
370
371         # Delivery Sender Notifications
372         if use dsn; then
373                 cat >> Makefile <<- EOC
374                         EXPERIMENTAL_DSN=yes
375                 EOC
376         fi
377
378         #
379         # authentication (SMTP AUTH)
380
381         # standard bits
382         cat >> Makefile <<- EOC
383                 AUTH_SPA=yes
384                 AUTH_CRAM_MD5=yes
385                 AUTH_PLAINTEXT=yes
386         EOC
387
388         # Cyrus SASL
389         if use sasl; then
390                 cat >> Makefile <<- EOC
391                         CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
392                         AUTH_CYRUS_SASL=yes
393                         AUTH_LIBS += -lsasl2
394                 EOC
395         fi
396
397         # Dovecot
398         if use dovecot-sasl; then
399                 cat >> Makefile <<- EOC
400                         AUTH_DOVECOT=yes
401                 EOC
402         fi
403
404         # Pluggable Authentication Modules
405         if use pam; then
406                 cat >> Makefile <<- EOC
407                         SUPPORT_PAM=yes
408                         AUTH_LIBS += -lpam
409                 EOC
410         fi
411
412         # Radius
413         if use radius; then
414                 cat >> Makefile <<- EOC
415                         RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
416                         RADIUS_LIB_TYPE=RADIUSCLIENTNEW
417                         AUTH_LIBS += -lfreeradius-client
418                 EOC
419         fi
420 }
421
422 src_compile() {
423         emake -j1 CC="$(tc-getCC)" HOSTCC="$(tc-getCC $CBUILD)" \
424                 AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO='' \
425                 || die "make failed"
426 }
427
428 src_install () {
429         cd "${S}"/build-exim-gentoo || die
430         dosbin exim
431         if use X; then
432                 dosbin eximon.bin
433                 dosbin eximon
434         fi
435         fperms 4755 /usr/sbin/exim
436
437         dosym exim /usr/sbin/sendmail
438         dosym exim /usr/sbin/rsmtp
439         dosym exim /usr/sbin/rmail
440         dosym /usr/sbin/exim /usr/bin/mailq
441         dosym /usr/sbin/exim /usr/bin/newaliases
442         dosym /usr/sbin/sendmail /usr/lib/sendmail
443
444         for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
445                 exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
446                 convert4r3 convert4r4 exipick
447         do
448                 dosbin $i
449         done
450
451         dodoc "${S}"/doc/*
452         doman "${S}"/doc/exim.8
453         use dsn && dodoc "${S}"/README.DSN
454         use doc && dohtml -r "${WORKDIR}"/${PN}-html-${PV//rc/RC}/doc/html/spec_html/*
455
456         # conf files
457         insinto /etc/exim
458         newins "${S}"/src/configure.default exim.conf.dist
459         if use exiscan-acl; then
460                 newins "${S}"/src/configure.default exim.conf.exiscan-acl
461         fi
462         doins "${WORKDIR}"/system_filter.exim
463         doins "${FILESDIR}"/auth_conf.sub
464
465         pamd_mimic system-auth exim auth account
466
467         # headers, #436406
468         if use dlfunc ; then
469                 # fixup includes so they actually can be found when including
470                 sed -i \
471                         -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
472                         local_scan.h || die
473                 insinto /usr/include/exim
474                 doins {config,local_scan}.h ../src/{mytypes,store}.h
475         fi
476
477         insinto /etc/logrotate.d
478         newins "${FILESDIR}/exim.logrotate" exim
479
480         newinitd "${FILESDIR}"/exim.rc9 exim
481         newconfd "${FILESDIR}"/exim.confd exim
482
483         systemd_dounit "${FILESDIR}"/{exim.service,exim.socket,exim-submission.socket}
484         systemd_newunit "${FILESDIR}"/exim_at.service 'exim@.service'
485         systemd_newunit "${FILESDIR}"/exim-submission_at.service 'exim-submission@.service'
486
487         diropts -m 0750 -o ${MAILUSER} -g ${MAILGROUP}
488         dodir /var/log/${PN}
489 }
490
491 pkg_postinst() {
492         if [[ ! -f ${EROOT}etc/exim/exim.conf ]] ; then
493                 einfo "${EROOT}etc/exim/system_filter.exim is a sample system_filter."
494                 einfo "${EROOT}etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
495                 einfo "Please create ${EROOT}etc/exim/exim.conf from ${EROOT}etc/exim/exim.conf.dist."
496         fi
497         use dane && einfo "DANE support is experimental"
498         if use dcc ; then
499                 einfo "DCC support is experimental, you can find some limited"
500                 einfo "documentation at the bottom of this prerelease message:"
501                 einfo "http://article.gmane.org/gmane.mail.exim.devel/3579"
502         fi
503         use spf && einfo "SPF support is experimental"
504         use srs && einfo "SRS support is experimental"
505         if use dmarc ; then
506                 einfo "DMARC support is experimental.  See global settings to"
507                 einfo "configure DMARC, for usage see the documentation at "
508                 einfo "experimental-spec.txt."
509         fi
510         use tpda && einfo "TPDA/EVENT support is experimental"
511         use proxy && einfo "proxy support is experimental"
512         if use dsn ; then
513                 einfo "Starting from Exim 4.83, DSN support comes from upstream."
514                 einfo "DSN support is an experimental feature.  If you used DSN"
515                 einfo "support prior to 4.83, make sure to remove all dsn_process"
516                 einfo "switches from your routers, see https://bugs.gentoo.org/511818"
517         fi
518         einfo "Exim maintains some db files under its spool directory that need"
519         einfo "cleaning from time to time.  (${EROOT}var/spool/exim/db)"
520         einfo "Please use the exim_tidydb tool as documented in the Exim manual:"
521         einfo "http://www.exim.org/exim-html-current/doc/html/spec_html/ch-exim_utilities.html#SECThindatmai"
522 }