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