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=[-bindist] )
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.87-as-needed-ldflags.patch # 352265, 391279
87 epatch "${FILESDIR}"/exim-4.76-crosscompile.patch # 266591
88 epatch "${FILESDIR}"/exim-4.86-TMPDIR.patch # 63420
91 epatch "${FILESDIR}"/exim-4.20-maildir.patch
93 epatch "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
96 # user Exim believes it should be
99 if use prefix && [[ ${EUID} != 0 ]] ; then
106 # general config and paths
109 -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${EPREFIX}/etc/mail/aliases'" \
110 "${S}"/src/configure.default || die
112 sed -i -e 's/^buildname=.*/buildname=exim-gentoo/g' Makefile || die
114 sed -e "48i\CFLAGS=${CFLAGS}" \
115 -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=${EPREFIX}/usr/sbin:" \
116 -e "s:EXIM_USER=:EXIM_USER=${MAILUSER}:" \
117 -e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=${EPREFIX}/etc/exim/exim.conf:" \
118 -e "s:ZCAT_COMMAND=.*$:ZCAT_COMMAND=${EPREFIX}/bin/zcat:" \
119 -e "s:COMPRESS_COMMAND=.*$:COMPRESS_COMMAND=${EPREFIX}/bin/gzip:" \
120 src/EDITME > Local/Makefile
124 cat >> Makefile <<- EOC
125 INFO_DIRECTORY=${EPREFIX}/usr/share/info
126 PID_FILE_PATH=${EPREFIX}/run/exim.pid
127 SPOOL_DIRECTORY=${EPREFIX}/var/spool/exim
131 # if we use libiconv, now is the time to tell so
132 use !elibc_glibc && echo "EXTRALIBS_EXIM=-liconv" >> Makefile
136 cat >> Makefile <<- EOC
142 # mail storage formats
144 # mailstore is Exim's traditional storage format
145 cat >> Makefile <<- EOC
146 SUPPORT_MAILSTORE=yes
151 cat >> Makefile <<- EOC
158 cat >> Makefile <<- EOC
166 # use the "native" interfaces to the DBM and CDB libraries, support
167 # passwd and directory lookups by default
168 cat >> Makefile <<- EOC
177 # DNSDB lookup is enabled by default
178 sed -i "s:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:" Makefile
182 cat >> Makefile <<- EOC
184 LDAP_LIB_TYPE=OPENLDAP2
185 LOOKUP_INCLUDE += -I"${EROOT}"usr/include/ldap
186 LOOKUP_LIBS += -lldap -llber
191 cat >> Makefile <<- EOC
193 LOOKUP_INCLUDE += $(mysql_config --include)
194 LOOKUP_LIBS += $(mysql_config --libs)
199 cat >> Makefile <<- EOC
205 if use postgres; then
206 cat >> Makefile <<- EOC
208 LOOKUP_INCLUDE += -I$(pg_config --includedir)
209 LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
214 cat >> Makefile <<- EOC
216 LOOKUP_SQLITE_PC=sqlite3
221 cat >> Makefile <<- EOC
222 EXPERIMENTAL_REDIS=yes
223 LOOKUP_LIBS += -lhiredis
228 # Exim monitor, enabled by default, controlled via X USE-flag,
229 # disable if not requested, bug #46778
231 cp ../exim_monitor/EDITME eximon.conf || die
233 sed -i -e '/^EXIM_MONITOR=/s/^/# /' Makefile
239 # content scanning support
240 if use exiscan-acl; then
241 cat >> Makefile <<- EOC
242 WITH_CONTENT_SCAN=yes
247 # DomainKeys Identified Mail, RFC4871
249 # DKIM is enabled by default
250 cat >> Makefile <<- EOC
255 # Per-Recipient-Data-Response
257 # PRDR is enabled by default
258 cat >> Makefile <<- EOC
265 sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Makefile
266 cat >> Makefile <<- EOC
270 cat >> Makefile <<- EOC
271 LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
275 # starttls support (ssl)
277 echo "SUPPORT_TLS=yes" >> Makefile
279 echo "USE_GNUTLS=yes" >> Makefile
280 echo "USE_GNUTLS_PC=gnutls" >> Makefile
281 use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
283 echo "USE_OPENSSL_PC=openssl" >> Makefile
289 cat >> Makefile <<- EOC
291 EXTRALIBS_EXIM += -lwrap
295 # Light Mail Transport Protocol
297 cat >> Makefile <<- EOC
304 cat >> Makefile <<- EOC
311 cat >> Makefile <<- EOC
317 # experimental features
321 cat >> Makefile <<- EOC
322 EXPERIMENTAL_DANE=yes
326 # Distributed Checksum Clearinghouse
328 echo "EXPERIMENTAL_DCC=yes">> Makefile
331 # Sender Policy Framework
333 cat >> Makefile <<- EOC
335 EXTRALIBS_EXIM += -lspf2
339 # Sender Rewriting Scheme
341 cat >> Makefile <<- EOC
343 EXTRALIBS_EXIM += -lsrs_alt
349 cat >> Makefile <<- EOC
350 EXPERIMENTAL_DMARC=yes
351 EXTRALIBS_EXIM += -lopendmarc
355 # Transport post-delivery actions
357 cat >> Makefile <<- EOC
358 EXPERIMENTAL_EVENT=yes
364 cat >> Makefile <<- EOC
365 EXPERIMENTAL_PROXY=yes
369 # Delivery Sender Notifications
371 cat >> Makefile <<- EOC
377 # authentication (SMTP AUTH)
380 cat >> Makefile <<- EOC
388 cat >> Makefile <<- EOC
389 CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
396 if use dovecot-sasl; then
397 cat >> Makefile <<- EOC
402 # Pluggable Authentication Modules
404 cat >> Makefile <<- EOC
412 cat >> Makefile <<- EOC
413 RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
414 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
415 AUTH_LIBS += -lfreeradius-client
421 emake -j1 CC="$(tc-getCC)" HOSTCC="$(tc-getCC $CBUILD)" \
422 AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO='' \
427 cd "${S}"/build-exim-gentoo || die
433 fperms 4755 /usr/sbin/exim
435 dosym exim /usr/sbin/sendmail
436 dosym exim /usr/sbin/rsmtp
437 dosym exim /usr/sbin/rmail
438 dosym /usr/sbin/exim /usr/bin/mailq
439 dosym /usr/sbin/exim /usr/bin/newaliases
440 dosym /usr/sbin/sendmail /usr/lib/sendmail
442 for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
443 exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
444 convert4r3 convert4r4 exipick
450 doman "${S}"/doc/exim.8
451 use dsn && dodoc "${S}"/README.DSN
452 use doc && dohtml -r "${WORKDIR}"/${PN}-html-${PV//rc/RC}/doc/html/spec_html/*
456 newins "${S}"/src/configure.default exim.conf.dist
457 if use exiscan-acl; then
458 newins "${S}"/src/configure.default exim.conf.exiscan-acl
460 doins "${WORKDIR}"/system_filter.exim
461 doins "${FILESDIR}"/auth_conf.sub
463 pamd_mimic system-auth exim auth account
467 # fixup includes so they actually can be found when including
469 -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
471 insinto /usr/include/exim
472 doins {config,local_scan}.h ../src/{mytypes,store}.h
475 insinto /etc/logrotate.d
476 newins "${FILESDIR}/exim.logrotate" exim
478 newinitd "${FILESDIR}"/exim.rc9 exim
479 newconfd "${FILESDIR}"/exim.confd exim
481 systemd_dounit "${FILESDIR}"/{exim.service,exim.socket,exim-submission.socket}
482 systemd_newunit "${FILESDIR}"/exim_at.service 'exim@.service'
483 systemd_newunit "${FILESDIR}"/exim-submission_at.service 'exim-submission@.service'
485 diropts -m 0750 -o ${MAILUSER} -g ${MAILGROUP}
490 if [[ ! -f ${EROOT}etc/exim/exim.conf ]] ; then
491 einfo "${EROOT}etc/exim/system_filter.exim is a sample system_filter."
492 einfo "${EROOT}etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
493 einfo "Please create ${EROOT}etc/exim/exim.conf from ${EROOT}etc/exim/exim.conf.dist."
495 use dane && einfo "DANE support is experimental"
497 einfo "DCC support is experimental, you can find some limited"
498 einfo "documentation at the bottom of this prerelease message:"
499 einfo "http://article.gmane.org/gmane.mail.exim.devel/3579"
501 use spf && einfo "SPF support is experimental"
502 use srs && einfo "SRS support is experimental"
504 einfo "DMARC support is experimental. See global settings to"
505 einfo "configure DMARC, for usage see the documentation at "
506 einfo "experimental-spec.txt."
508 use tpda && einfo "TPDA/EVENT support is experimental"
509 use proxy && einfo "proxy support is experimental"
511 einfo "Starting from Exim 4.83, DSN support comes from upstream."
512 einfo "DSN support is an experimental feature. If you used DSN"
513 einfo "support prior to 4.83, make sure to remove all dsn_process"
514 einfo "switches from your routers, see https://bugs.gentoo.org/511818"
516 einfo "Exim maintains some db files under its spool directory that need"
517 einfo "cleaning from time to time. (${EROOT}var/spool/exim/db)"
518 einfo "Please use the exim_tidydb tool as documented in the Exim manual:"
519 einfo "http://www.exim.org/exim-html-current/doc/html/spec_html/ch-exim_utilities.html#SECThindatmai"