1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils toolchain-funcs multilib pam systemd
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 )"
12 COMM_URI="ftp://ftp.exim.org/pub/exim/exim4$([[ ${PV} == *_rc* ]] && echo /test)"
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/"
22 KEYWORDS="~amd64 ~hppa ~ppc64 ~x86"
24 COMMON_DEPEND=">=sys-apps/sed-4.0.5
27 perl? ( dev-lang/perl:= )
29 tcpd? ( sys-apps/tcp-wrappers )
31 !libressl? ( dev-libs/openssl:0= )
32 libressl? ( dev-libs/libressl:= )
34 gnutls? ( net-libs/gnutls[pkcs11?]
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 )
50 sqlite? ( dev-db/sqlite )
51 radius? ( net-dialup/freeradius-client )
54 # added X check for #57206
55 DEPEND="${COMMON_DEPEND}
57 RDEPEND="${COMMON_DEPEND}
61 !<mail-mta/msmtp-1.4.19-r1
62 !>=mail-mta/msmtp-1.4.19-r1[mta]
69 !<mail-mta/ssmtp-2.64-r2
70 !>=mail-mta/ssmtp-2.64-r2[mta]
72 >=net-mail/mailbase-0.00-r5
74 dcc? ( mail-filter/dcc )
75 selinux? ( sec-policy/selinux-exim )
78 S=${WORKDIR}/${P//rc/RC}
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
92 epatch "${FILESDIR}"/exim-4.20-maildir.patch
94 epatch "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
97 # user Exim believes it should be
100 if use prefix && [[ ${EUID} != 0 ]] ; then
107 # general config and paths
110 -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${EPREFIX}/etc/mail/aliases'" \
111 "${S}"/src/configure.default || die
113 sed -i -e 's/^buildname=.*/buildname=exim-gentoo/g' Makefile || die
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
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
132 # if we use libiconv, now is the time to tell so
133 use !elibc_glibc && echo "EXTRALIBS_EXIM=-liconv" >> Makefile
137 cat >> Makefile <<- EOC
143 # mail storage formats
145 # mailstore is Exim's traditional storage format
146 cat >> Makefile <<- EOC
147 SUPPORT_MAILSTORE=yes
152 cat >> Makefile <<- EOC
159 cat >> Makefile <<- EOC
167 # use the "native" interfaces to the DBM and CDB libraries, support
168 # passwd and directory lookups by default
169 cat >> Makefile <<- EOC
178 # DNSDB lookup is enabled by default
179 sed -i "s:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:" Makefile
183 cat >> Makefile <<- EOC
185 LDAP_LIB_TYPE=OPENLDAP2
186 LOOKUP_INCLUDE += -I"${EROOT}"usr/include/ldap
187 LOOKUP_LIBS += -lldap -llber
192 cat >> Makefile <<- EOC
194 LOOKUP_INCLUDE += $(mysql_config --include)
195 LOOKUP_LIBS += $(mysql_config --libs)
200 cat >> Makefile <<- EOC
206 if use postgres; then
207 cat >> Makefile <<- EOC
209 LOOKUP_INCLUDE += -I$(pg_config --includedir)
210 LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
215 cat >> Makefile <<- EOC
217 LOOKUP_SQLITE_PC=sqlite3
222 cat >> Makefile <<- EOC
223 EXPERIMENTAL_REDIS=yes
224 LOOKUP_LIBS += -lhiredis
229 # Exim monitor, enabled by default, controlled via X USE-flag,
230 # disable if not requested, bug #46778
232 cp ../exim_monitor/EDITME eximon.conf || die
234 sed -i -e '/^EXIM_MONITOR=/s/^/# /' Makefile
240 # content scanning support
241 if use exiscan-acl; then
242 cat >> Makefile <<- EOC
243 WITH_CONTENT_SCAN=yes
248 # DomainKeys Identified Mail, RFC4871
250 # DKIM is enabled by default
251 cat >> Makefile <<- EOC
256 # Per-Recipient-Data-Response
258 # PRDR is enabled by default
259 cat >> Makefile <<- EOC
266 sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Makefile
267 cat >> Makefile <<- EOC
271 cat >> Makefile <<- EOC
272 LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
276 # starttls support (ssl)
278 echo "SUPPORT_TLS=yes" >> Makefile
280 echo "USE_GNUTLS=yes" >> Makefile
281 echo "USE_GNUTLS_PC=gnutls" >> Makefile
282 use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
284 echo "USE_OPENSSL_PC=openssl" >> Makefile
290 cat >> Makefile <<- EOC
292 EXTRALIBS_EXIM += -lwrap
296 # Light Mail Transport Protocol
298 cat >> Makefile <<- EOC
305 cat >> Makefile <<- EOC
312 cat >> Makefile <<- EOC
318 # experimental features
322 cat >> Makefile <<- EOC
323 EXPERIMENTAL_DANE=yes
327 # Distributed Checksum Clearinghouse
329 echo "EXPERIMENTAL_DCC=yes">> Makefile
332 # Sender Policy Framework
334 cat >> Makefile <<- EOC
336 EXTRALIBS_EXIM += -lspf2
340 # Sender Rewriting Scheme
342 cat >> Makefile <<- EOC
344 EXTRALIBS_EXIM += -lsrs_alt
350 cat >> Makefile <<- EOC
351 EXPERIMENTAL_DMARC=yes
352 EXTRALIBS_EXIM += -lopendmarc
356 # Transport post-delivery actions
358 cat >> Makefile <<- EOC
359 EXPERIMENTAL_EVENT=yes
365 cat >> Makefile <<- EOC
366 EXPERIMENTAL_PROXY=yes
370 # Delivery Sender Notifications
372 cat >> Makefile <<- EOC
378 # authentication (SMTP AUTH)
381 cat >> Makefile <<- EOC
389 cat >> Makefile <<- EOC
390 CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
397 if use dovecot-sasl; then
398 cat >> Makefile <<- EOC
403 # Pluggable Authentication Modules
405 cat >> Makefile <<- EOC
413 cat >> Makefile <<- EOC
414 RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
415 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
416 AUTH_LIBS += -lfreeradius-client
422 emake -j1 CC="$(tc-getCC)" HOSTCC="$(tc-getCC $CBUILD)" \
423 AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO='' \
428 cd "${S}"/build-exim-gentoo || die
434 fperms 4755 /usr/sbin/exim
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
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
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/*
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
461 doins "${WORKDIR}"/system_filter.exim
462 doins "${FILESDIR}"/auth_conf.sub
464 pamd_mimic system-auth exim auth account
468 # fixup includes so they actually can be found when including
470 -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
472 insinto /usr/include/exim
473 doins {config,local_scan}.h ../src/{mytypes,store}.h
476 insinto /etc/logrotate.d
477 newins "${FILESDIR}/exim.logrotate" exim
479 newinitd "${FILESDIR}"/exim.rc9 exim
480 newconfd "${FILESDIR}"/exim.confd exim
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'
486 diropts -m 0750 -o ${MAILUSER} -g ${MAILGROUP}
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."
496 use dane && einfo "DANE support is experimental"
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"
502 use spf && einfo "SPF support is experimental"
503 use srs && einfo "SRS support is experimental"
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."
509 use tpda && einfo "TPDA/EVENT support is experimental"
510 use proxy && einfo "proxy support is experimental"
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"
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"