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="dcc +dkim dlfunc dmarc +dnsdb doc dovecot-sasl dsn exiscan-acl gnutls ipv6 ldap 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="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~x86-solaris"
24 COMMON_DEPEND=">=sys-apps/sed-4.0.5
27 perl? ( dev-lang/perl:= )
29 tcpd? ( sys-apps/tcp-wrappers )
30 ssl? ( dev-libs/openssl )
31 gnutls? ( net-libs/gnutls[pkcs11?]
33 ldap? ( >=net-nds/openldap-2.0.7 )
34 mysql? ( virtual/mysql )
35 postgres? ( dev-db/postgresql )
36 sasl? ( >=dev-libs/cyrus-sasl-2.1.26-r2 )
37 redis? ( dev-libs/hiredis )
38 spf? ( >=mail-filter/libspf2-1.2.5-r1 )
39 dmarc? ( mail-filter/opendmarc )
40 srs? ( mail-filter/libsrs_alt )
47 sqlite? ( dev-db/sqlite )
48 radius? ( net-dialup/radiusclient )
51 # added X check for #57206
52 DEPEND="${COMMON_DEPEND}
54 RDEPEND="${COMMON_DEPEND}
58 !<mail-mta/msmtp-1.4.19-r1
59 !>=mail-mta/msmtp-1.4.19-r1[mta]
66 !<mail-mta/ssmtp-2.64-r2
67 !>=mail-mta/ssmtp-2.64-r2[mta]
69 >=net-mail/mailbase-0.00-r5
71 dcc? ( mail-filter/dcc )
72 selinux? ( sec-policy/selinux-exim )
75 S=${WORKDIR}/${P//rc/RC}
78 epatch "${FILESDIR}"/exim-4.14-tail.patch
79 epatch "${FILESDIR}"/exim-4.74-localscan_dlopen.patch
80 epatch "${FILESDIR}"/exim-4.69-r1.27021.patch
81 epatch "${FILESDIR}"/exim-4.74-radius-db-ENV-clash.patch # 287426
82 epatch "${FILESDIR}"/exim-4.82-makefile-freebsd.patch # 235785
83 epatch "${FILESDIR}"/exim-4.77-as-needed-ldflags.patch # 352265, 391279
84 epatch "${FILESDIR}"/exim-4.76-crosscompile.patch # 266591
87 epatch "${FILESDIR}"/exim-4.20-maildir.patch
89 epatch "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
92 # user Exim believes it should be
95 if use prefix && [[ ${EUID} != 0 ]] ; then
102 # general config and paths
105 -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${EPREFIX}/etc/mail/aliases'" \
106 "${S}"/src/configure.default || die
108 sed -i -e 's/^buildname=.*/buildname=exim-gentoo/g' Makefile || die
110 sed -e "48i\CFLAGS=${CFLAGS}" \
111 -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=${EPREFIX}/usr/sbin:" \
112 -e "s:EXIM_USER=:EXIM_USER=${MAILUSER}:" \
113 -e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=${EPREFIX}/etc/exim/exim.conf:" \
114 -e "s:ZCAT_COMMAND=.*$:ZCAT_COMMAND=${EPREFIX}/bin/zcat:" \
115 -e "s:COMPRESS_COMMAND=.*$:COMPRESS_COMMAND=${EPREFIX}/bin/gzip:" \
116 src/EDITME > Local/Makefile
120 cat >> Makefile <<- EOC
121 INFO_DIRECTORY=${EPREFIX}/usr/share/info
122 PID_FILE_PATH=${EPREFIX}/run/exim.pid
123 SPOOL_DIRECTORY=${EPREFIX}/var/spool/exim
127 # if we use libiconv, now is the time to tell so
128 use !elibc_glibc && echo "EXTRALIBS_EXIM=-liconv" >> Makefile
132 cat >> Makefile <<- EOC
138 # mail storage formats
140 # mailstore is Exim's traditional storage format
141 cat >> Makefile <<- EOC
142 SUPPORT_MAILSTORE=yes
147 cat >> Makefile <<- EOC
154 cat >> Makefile <<- EOC
162 # use the "native" interfaces to the DBM and CDB libraries, support
163 # passwd and directory lookups by default
164 cat >> Makefile <<- EOC
173 # DNSDB lookup is enabled by default
174 sed -i "s:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:" Makefile
178 cat >> Makefile <<- EOC
180 LDAP_LIB_TYPE=OPENLDAP2
181 LOOKUP_INCLUDE += -I"${EROOT}"usr/include/ldap
182 LOOKUP_LIBS += -lldap -llber
187 cat >> Makefile <<- EOC
189 LOOKUP_INCLUDE += $(mysql_config --include)
190 LOOKUP_LIBS += $(mysql_config --libs)
195 cat >> Makefile <<- EOC
201 if use postgres; then
202 cat >> Makefile <<- EOC
204 LOOKUP_INCLUDE += -I$(pg_config --includedir)
205 LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
210 cat >> Makefile <<- EOC
212 LOOKUP_SQLITE_PC=sqlite3
217 cat >> Makefile <<- EOC
218 EXPERIMENTAL_REDIS=yes
219 LOOKUP_LIBS += -lhiredis
224 # Exim monitor, enabled by default, controlled via X USE-flag,
225 # disable if not requested, bug #46778
227 cp ../exim_monitor/EDITME eximon.conf || die
229 sed -i -e '/^EXIM_MONITOR=/s/^/# /' Makefile
235 # content scanning support
236 if use exiscan-acl; then
237 cat >> Makefile <<- EOC
238 WITH_CONTENT_SCAN=yes
243 # DomainKeys Identified Mail, RFC4871
245 # DKIM is enabled by default
246 cat >> Makefile <<- EOC
251 # Per-Recipient-Data-Response
253 # PRDR is enabled by default
254 cat >> Makefile <<- EOC
261 sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Makefile
262 cat >> Makefile <<- EOC
266 cat >> Makefile <<- EOC
267 LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
271 # starttls support (ssl)
273 echo "SUPPORT_TLS=yes" >> Makefile
275 echo "USE_GNUTLS=yes" >> Makefile
276 echo "USE_GNUTLS_PC=gnutls" >> Makefile
277 use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
279 echo "USE_OPENSSL_PC=openssl" >> Makefile
285 cat >> Makefile <<- EOC
287 EXTRALIBS_EXIM += -lwrap
291 # Light Mail Transport Protocol
293 cat >> Makefile <<- EOC
300 cat >> Makefile <<- EOC
307 cat >> Makefile <<- EOC
313 # experimental features
315 # Distributed Checksum Clearinghouse
317 echo "EXPERIMENTAL_DCC=yes">> Makefile
320 # Sender Policy Framework
322 cat >> Makefile <<- EOC
324 EXTRALIBS_EXIM += -lspf2
328 # Sender Rewriting Scheme
330 cat >> Makefile <<- EOC
332 EXTRALIBS_EXIM += -lsrs_alt
338 cat >> Makefile <<- EOC
339 EXPERIMENTAL_DMARC=yes
340 EXTRALIBS_EXIM += -lopendmarc
344 # Transport post-delivery actions
346 cat >> Makefile <<- EOC
347 EXPERIMENTAL_EVENT=yes
353 cat >> Makefile <<- EOC
354 EXPERIMENTAL_PROXY=yes
358 # Delivery Sender Notifications
360 cat >> Makefile <<- EOC
366 # authentication (SMTP AUTH)
369 cat >> Makefile <<- EOC
377 cat >> Makefile <<- EOC
378 CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
385 if use dovecot-sasl; then
386 cat >> Makefile <<- EOC
391 # Pluggable Authentication Modules
393 cat >> Makefile <<- EOC
401 cat >> Makefile <<- EOC
402 RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
403 RADIUS_LIB_TYPE=RADIUSCLIENT
404 AUTH_LIBS += -lradiusclient
410 emake -j1 CC="$(tc-getCC)" HOSTCC="$(tc-getCC $CBUILD)" \
411 AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO='' \
416 cd "${S}"/build-exim-gentoo || die
422 fperms 4755 /usr/sbin/exim
424 dosym exim /usr/sbin/sendmail
425 dosym exim /usr/sbin/rsmtp
426 dosym exim /usr/sbin/rmail
427 dosym /usr/sbin/exim /usr/bin/mailq
428 dosym /usr/sbin/exim /usr/bin/newaliases
429 dosym /usr/sbin/sendmail /usr/lib/sendmail
431 for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
432 exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
433 convert4r3 convert4r4 exipick
439 doman "${S}"/doc/exim.8
440 use dsn && dodoc "${S}"/README.DSN
441 use doc && dohtml -r "${WORKDIR}"/${PN}-html-${PV//rc/RC}/doc/html/spec_html/*
445 newins "${S}"/src/configure.default exim.conf.dist
446 if use exiscan-acl; then
447 newins "${S}"/src/configure.default exim.conf.exiscan-acl
449 doins "${WORKDIR}"/system_filter.exim
450 doins "${FILESDIR}"/auth_conf.sub
452 pamd_mimic system-auth exim auth account
456 # fixup includes so they actually can be found when including
458 -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
460 insinto /usr/include/exim
461 doins {config,local_scan}.h ../src/{mytypes,store}.h
464 insinto /etc/logrotate.d
465 newins "${FILESDIR}/exim.logrotate" exim
467 newinitd "${FILESDIR}"/exim.rc9 exim
468 newconfd "${FILESDIR}"/exim.confd exim
470 systemd_dounit "${FILESDIR}"/{exim.service,exim.socket,exim-submission.socket}
471 systemd_newunit "${FILESDIR}"/exim_at.service 'exim@.service'
472 systemd_newunit "${FILESDIR}"/exim-submission_at.service 'exim-submission@.service'
474 diropts -m 0750 -o ${MAILUSER} -g ${MAILGROUP}
479 if [[ ! -f ${EROOT}etc/exim/exim.conf ]] ; then
480 einfo "${EROOT}etc/exim/system_filter.exim is a sample system_filter."
481 einfo "${EROOT}etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
482 einfo "Please create ${EROOT}etc/exim/exim.conf from ${EROOT}etc/exim/exim.conf.dist."
485 einfo "DCC support is experimental, you can find some limited"
486 einfo "documentation at the bottom of this prerelease message:"
487 einfo "http://article.gmane.org/gmane.mail.exim.devel/3579"
489 use spf && einfo "SPF support is experimental"
490 use srs && einfo "SRS support is experimental"
492 einfo "DMARC support is experimental. See global settings to"
493 einfo "configure DMARC, for usage see the documentation at "
494 einfo "experimental-spec.txt."
496 use tpda && einfo "TPDA/EVENT support is experimental"
497 use proxy && einfo "proxy support is experimental"
499 einfo "Starting from Exim 4.83, DSN support comes from upstream."
500 einfo "DSN support is an experimental feature. If you used DSN"
501 einfo "support prior to 4.83, make sure to remove all dsn_process"
502 einfo "switches from your routers, see https://bugs.gentoo.org/511818"
504 einfo "Exim maintains some db files under its spool directory that need"
505 einfo "cleaning from time to time. (${EROOT}var/spool/exim/db)"
506 einfo "Please use the exim_tidydb tool as documented in the Exim manual:"
507 einfo "http://www.exim.org/exim-html-current/doc/html/spec_html/ch-exim_utilities.html#SECThindatmai"