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