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