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 ~arm ~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.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 epatch "${FILESDIR}"/exim-4.86-TMPDIR.patch # 63420
93 epatch "${FILESDIR}"/exim-4.20-maildir.patch
95 epatch "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
98 # user Exim believes it should be
101 if use prefix && [[ ${EUID} != 0 ]] ; then
108 # general config and paths
111 -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${EPREFIX}/etc/mail/aliases'" \
112 "${S}"/src/configure.default || die
114 sed -i -e 's/^buildname=.*/buildname=exim-gentoo/g' Makefile || die
116 sed -e "48i\CFLAGS=${CFLAGS}" \
117 -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=${EPREFIX}/usr/sbin:" \
118 -e "s:EXIM_USER=:EXIM_USER=${MAILUSER}:" \
119 -e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=${EPREFIX}/etc/exim/exim.conf:" \
120 -e "s:ZCAT_COMMAND=.*$:ZCAT_COMMAND=${EPREFIX}/bin/zcat:" \
121 -e "s:COMPRESS_COMMAND=.*$:COMPRESS_COMMAND=${EPREFIX}/bin/gzip:" \
122 src/EDITME > Local/Makefile
126 cat >> Makefile <<- EOC
127 INFO_DIRECTORY=${EPREFIX}/usr/share/info
128 PID_FILE_PATH=${EPREFIX}/run/exim.pid
129 SPOOL_DIRECTORY=${EPREFIX}/var/spool/exim
133 # if we use libiconv, now is the time to tell so
134 use !elibc_glibc && echo "EXTRALIBS_EXIM=-liconv" >> Makefile
138 cat >> Makefile <<- EOC
144 # mail storage formats
146 # mailstore is Exim's traditional storage format
147 cat >> Makefile <<- EOC
148 SUPPORT_MAILSTORE=yes
153 cat >> Makefile <<- EOC
160 cat >> Makefile <<- EOC
168 # use the "native" interfaces to the DBM and CDB libraries, support
169 # passwd and directory lookups by default
170 cat >> Makefile <<- EOC
179 # DNSDB lookup is enabled by default
180 sed -i "s:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:" Makefile
184 cat >> Makefile <<- EOC
186 LDAP_LIB_TYPE=OPENLDAP2
187 LOOKUP_INCLUDE += -I"${EROOT}"usr/include/ldap
188 LOOKUP_LIBS += -lldap -llber
193 cat >> Makefile <<- EOC
195 LOOKUP_INCLUDE += $(mysql_config --include)
196 LOOKUP_LIBS += $(mysql_config --libs)
201 cat >> Makefile <<- EOC
207 if use postgres; then
208 cat >> Makefile <<- EOC
210 LOOKUP_INCLUDE += -I$(pg_config --includedir)
211 LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
216 cat >> Makefile <<- EOC
218 LOOKUP_SQLITE_PC=sqlite3
223 cat >> Makefile <<- EOC
224 EXPERIMENTAL_REDIS=yes
225 LOOKUP_LIBS += -lhiredis
230 # Exim monitor, enabled by default, controlled via X USE-flag,
231 # disable if not requested, bug #46778
233 cp ../exim_monitor/EDITME eximon.conf || die
235 sed -i -e '/^EXIM_MONITOR=/s/^/# /' Makefile
241 # content scanning support
242 if use exiscan-acl; then
243 cat >> Makefile <<- EOC
244 WITH_CONTENT_SCAN=yes
249 # DomainKeys Identified Mail, RFC4871
251 # DKIM is enabled by default
252 cat >> Makefile <<- EOC
257 # Per-Recipient-Data-Response
259 # PRDR is enabled by default
260 cat >> Makefile <<- EOC
267 sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Makefile
268 cat >> Makefile <<- EOC
272 cat >> Makefile <<- EOC
273 LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
277 # starttls support (ssl)
279 echo "SUPPORT_TLS=yes" >> Makefile
281 echo "USE_GNUTLS=yes" >> Makefile
282 echo "USE_GNUTLS_PC=gnutls" >> Makefile
283 use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
285 echo "USE_OPENSSL_PC=openssl" >> Makefile
291 cat >> Makefile <<- EOC
293 EXTRALIBS_EXIM += -lwrap
297 # Light Mail Transport Protocol
299 cat >> Makefile <<- EOC
306 cat >> Makefile <<- EOC
313 cat >> Makefile <<- EOC
319 # experimental features
323 cat >> Makefile <<- EOC
324 EXPERIMENTAL_DANE=yes
328 # Distributed Checksum Clearinghouse
330 echo "EXPERIMENTAL_DCC=yes">> Makefile
333 # Sender Policy Framework
335 cat >> Makefile <<- EOC
337 EXTRALIBS_EXIM += -lspf2
341 # Sender Rewriting Scheme
343 cat >> Makefile <<- EOC
345 EXTRALIBS_EXIM += -lsrs_alt
351 cat >> Makefile <<- EOC
352 EXPERIMENTAL_DMARC=yes
353 EXTRALIBS_EXIM += -lopendmarc
357 # Transport post-delivery actions
359 cat >> Makefile <<- EOC
360 EXPERIMENTAL_EVENT=yes
366 cat >> Makefile <<- EOC
367 EXPERIMENTAL_PROXY=yes
371 # Delivery Sender Notifications
373 cat >> Makefile <<- EOC
379 # authentication (SMTP AUTH)
382 cat >> Makefile <<- EOC
390 cat >> Makefile <<- EOC
391 CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
398 if use dovecot-sasl; then
399 cat >> Makefile <<- EOC
404 # Pluggable Authentication Modules
406 cat >> Makefile <<- EOC
414 cat >> Makefile <<- EOC
415 RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
416 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
417 AUTH_LIBS += -lfreeradius-client
423 emake -j1 CC="$(tc-getCC)" HOSTCC="$(tc-getCC $CBUILD)" \
424 AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO='' \
429 cd "${S}"/build-exim-gentoo || die
435 fperms 4755 /usr/sbin/exim
437 dosym exim /usr/sbin/sendmail
438 dosym exim /usr/sbin/rsmtp
439 dosym exim /usr/sbin/rmail
440 dosym /usr/sbin/exim /usr/bin/mailq
441 dosym /usr/sbin/exim /usr/bin/newaliases
442 dosym /usr/sbin/sendmail /usr/lib/sendmail
444 for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
445 exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
446 convert4r3 convert4r4 exipick
452 doman "${S}"/doc/exim.8
453 use dsn && dodoc "${S}"/README.DSN
454 use doc && dohtml -r "${WORKDIR}"/${PN}-html-${PV//rc/RC}/doc/html/spec_html/*
458 newins "${S}"/src/configure.default exim.conf.dist
459 if use exiscan-acl; then
460 newins "${S}"/src/configure.default exim.conf.exiscan-acl
462 doins "${WORKDIR}"/system_filter.exim
463 doins "${FILESDIR}"/auth_conf.sub
465 pamd_mimic system-auth exim auth account
469 # fixup includes so they actually can be found when including
471 -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
473 insinto /usr/include/exim
474 doins {config,local_scan}.h ../src/{mytypes,store}.h
477 insinto /etc/logrotate.d
478 newins "${FILESDIR}/exim.logrotate" exim
480 newinitd "${FILESDIR}"/exim.rc9 exim
481 newconfd "${FILESDIR}"/exim.confd exim
483 systemd_dounit "${FILESDIR}"/{exim.service,exim.socket,exim-submission.socket}
484 systemd_newunit "${FILESDIR}"/exim_at.service 'exim@.service'
485 systemd_newunit "${FILESDIR}"/exim-submission_at.service 'exim-submission@.service'
487 diropts -m 0750 -o ${MAILUSER} -g ${MAILGROUP}
492 if [[ ! -f ${EROOT}etc/exim/exim.conf ]] ; then
493 einfo "${EROOT}etc/exim/system_filter.exim is a sample system_filter."
494 einfo "${EROOT}etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
495 einfo "Please create ${EROOT}etc/exim/exim.conf from ${EROOT}etc/exim/exim.conf.dist."
497 use dane && einfo "DANE support is experimental"
499 einfo "DCC support is experimental, you can find some limited"
500 einfo "documentation at the bottom of this prerelease message:"
501 einfo "http://article.gmane.org/gmane.mail.exim.devel/3579"
503 use spf && einfo "SPF support is experimental"
504 use srs && einfo "SRS support is experimental"
506 einfo "DMARC support is experimental. See global settings to"
507 einfo "configure DMARC, for usage see the documentation at "
508 einfo "experimental-spec.txt."
510 use tpda && einfo "TPDA/EVENT support is experimental"
511 use proxy && einfo "proxy support is experimental"
513 einfo "Starting from Exim 4.83, DSN support comes from upstream."
514 einfo "DSN support is an experimental feature. If you used DSN"
515 einfo "support prior to 4.83, make sure to remove all dsn_process"
516 einfo "switches from your routers, see https://bugs.gentoo.org/511818"
518 einfo "Exim maintains some db files under its spool directory that need"
519 einfo "cleaning from time to time. (${EROOT}var/spool/exim/db)"
520 einfo "Please use the exim_tidydb tool as documented in the Exim manual:"
521 einfo "http://www.exim.org/exim-html-current/doc/html/spec_html/ch-exim_utilities.html#SECThindatmai"