1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit db-use toolchain-funcs multilib pam systemd
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"
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.
27 SDIR=$([[ ${PV} == *_rc* ]] && echo /test
28 [[ ${PV} == *.*.*.* ]] && echo /fixes)
29 COMM_URI="https://downloads.exim.org/exim4${SDIR}"
31 DESCRIPTION="A highly configurable, drop-in replacement for sendmail"
32 SRC_URI="${COMM_URI}/${P//rc/RC}.tar.xz
33 mirror://gentoo/system_filter.exim.gz
34 doc? ( ${COMM_URI}/${PN}-pdf-${PV//rc/RC}.tar.xz )"
35 HOMEPAGE="https://www.exim.org/"
39 KEYWORDS="~alpha amd64 arm ~arm64 ~hppa ~ia64 ppc ppc64 sparc x86 ~x86-solaris"
41 COMMON_DEPEND=">=sys-apps/sed-4.0.5
42 ( >=sys-libs/db-3.2:= <sys-libs/db-6:= )
44 idn? ( net-dns/libidn:= net-dns/libidn2:= )
45 perl? ( dev-lang/perl:= )
47 tcpd? ( sys-apps/tcp-wrappers )
50 net-libs/gnutls:0=[pkcs11?]
54 !libressl? ( dev-libs/openssl:0= )
55 libressl? ( dev-libs/libressl:= )
58 ldap? ( >=net-nds/openldap-2.0.7 )
65 mysql? ( dev-db/mysql-connector-c:= )
66 postgres? ( dev-db/postgresql:= )
67 sasl? ( >=dev-libs/cyrus-sasl-2.1.26-r2 )
68 redis? ( dev-libs/hiredis )
69 spf? ( >=mail-filter/libspf2-1.2.5-r1 )
70 dmarc? ( mail-filter/opendmarc )
71 srs? ( mail-filter/libsrs_alt )
78 sqlite? ( dev-db/sqlite )
79 radius? ( net-dialup/freeradius-client )
81 elibc_glibc? ( net-libs/libnsl )
83 # added X check for #57206
84 BDEPEND="virtual/pkgconfig"
85 DEPEND="${COMMON_DEPEND}"
86 RDEPEND="${COMMON_DEPEND}
90 !<mail-mta/msmtp-1.4.19-r1
91 !>=mail-mta/msmtp-1.4.19-r1[mta]
98 !<mail-mta/ssmtp-2.64-r2
99 !>=mail-mta/ssmtp-2.64-r2[mta]
100 !net-mail/mailwrapper
101 >=net-mail/mailbase-0.00-r5
103 dcc? ( mail-filter/dcc )
104 selinux? ( sec-policy/selinux-exim )
107 S=${WORKDIR}/${P//rc/RC}
110 # Legacy patches which need a respin for -p1
111 eapply -p0 "${FILESDIR}"/exim-4.14-tail.patch
112 eapply -p0 "${FILESDIR}"/exim-4.74-radius-db-ENV-clash.patch # 287426
113 eapply "${FILESDIR}"/exim-4.93-as-needed-ldflags.patch # 352265, 391279
114 eapply -p0 "${FILESDIR}"/exim-4.76-crosscompile.patch # 266591
115 eapply "${FILESDIR}"/exim-4.69-r1.27021.patch
116 eapply "${FILESDIR}"/exim-4.93-localscan_dlopen.patch
117 eapply -p2 "${FILESDIR}"/exim-4.93-radius.patch # 720364
118 eapply "${FILESDIR}"/exim-4.93-CVE-2020-12783.patch # 722484
120 if use maildir ; then
121 eapply "${FILESDIR}"/exim-4.20-maildir.patch
123 eapply -p0 "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
128 # user Exim believes it should be
131 if use prefix && [[ ${EUID} != 0 ]] ; then
138 # general config and paths
140 local aliases="${EPREFIX}/etc/mail/aliases"
142 -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${aliases}'" \
143 src/configure.default || die
145 sed -i -e 's/^buildname=.*/buildname=exim-gentoo/' Makefile || die
147 if use elibc_musl; then
148 sed -i -e 's/^LIBS = -lnsl/LIBS =/g' OS/Makefile-Linux || die
151 local conffile="${EPREFIX}/etc/exim/exim.conf"
152 sed -e "48i\CFLAGS=${CFLAGS}" \
153 -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=${EPREFIX}/usr/sbin:" \
154 -e "s;EXIM_USER=;EXIM_USER=ref:${MAILUSER};" \
155 -e "s:CONFIGURE_FILE=.*$:CONFIGURE_FILE=${conffile}:" \
156 -e "s:ZCAT_COMMAND=.*$:ZCAT_COMMAND=${EPREFIX}/bin/zcat:" \
157 -e "s:COMPRESS_COMMAND=.*$:COMPRESS_COMMAND=${EPREFIX}/bin/gzip:" \
158 src/EDITME > Local/Makefile || die
160 # work on Local/Makefile from now on
163 cat >> Makefile <<- EOC
164 INFO_DIRECTORY=${EPREFIX}/usr/share/info
165 PID_FILE_PATH=${EPREFIX}/run/exim.pid
166 SPOOL_DIRECTORY=${EPREFIX}/var/spool/exim
170 # if we use libiconv, now is the time to tell so
171 if use !elibc_glibc && use !elibc_musl ; then
172 cat >> Makefile <<- EOC
173 EXTRALIBS_EXIM=-liconv
179 cat >> Makefile <<- EOC
186 cat >> Makefile <<- EOC
188 SUPPORT_I18N_2008=yes
189 EXTRALIBS_EXIM += -lidn -lidn2
194 # mail storage formats
197 # mailstore is Exim's traditional storage format
198 cat >> Makefile <<- EOC
199 SUPPORT_MAILSTORE=yes
204 cat >> Makefile <<- EOC
211 cat >> Makefile <<- EOC
219 # use the "native" interfaces to the DBM and CDB libraries, support
220 # passwd and directory lookups by default
221 local DB_VERS="5.3 5.1 4.8 4.7 4.6 4.5 4.4 4.3 4.2 3.2"
222 cat >> Makefile <<- EOC
227 # keep include in CFLAGS because exim.h -> dbstuff.h -> db.h
228 CFLAGS += -I$(db_includedir ${DB_VERS})
229 DBMLIB = -l$(db_libname ${DB_VERS})
233 # DNSDB lookup is enabled by default
234 sed -i -e 's:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:' Makefile || die
238 cat >> Makefile <<- EOC
240 LDAP_LIB_TYPE=OPENLDAP2
241 LOOKUP_INCLUDE += -I"${EPREFIX}"/usr/include/ldap
242 LOOKUP_LIBS += -lldap -llber
247 cat >> Makefile <<- EOC
249 LOOKUP_INCLUDE += $(mysql_config --include)
250 LOOKUP_LIBS += $(mysql_config --libs)
255 cat >> Makefile <<- EOC
259 if use elibc_glibc ; then
260 cat >> Makefile <<- EOC
261 LOOKUP_INCLUDE += -I"${EPREFIX}"/usr/include/tirpc
267 if use postgres; then
268 cat >> Makefile <<- EOC
270 LOOKUP_INCLUDE += -I$(pg_config --includedir)
271 LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
276 cat >> Makefile <<- EOC
278 LOOKUP_SQLITE_PC=sqlite3
283 cat >> Makefile <<- EOC
285 LOOKUP_LIBS += -lhiredis
289 # Exim monitor, enabled by default, controlled via X USE-flag,
290 # disable if not requested, bug #46778
292 cp ../exim_monitor/EDITME eximon.conf || die
293 cat >> Makefile <<- EOC
294 EXIM_MONITOR=eximon.bin
302 # content scanning support
303 if use exiscan-acl; then
304 cat >> Makefile <<- EOC
305 WITH_CONTENT_SCAN=yes
309 # DomainKeys Identified Mail, RFC4871
311 # DKIM is enabled by default
312 cat >> Makefile <<- EOC
317 # Per-Recipient-Data-Response
319 # PRDR is enabled by default
320 cat >> Makefile <<- EOC
325 # Transport post-delivery actions
326 if use !tpda && use !dane; then
327 # EVENT is enabled by default
328 cat >> Makefile <<- EOC
335 local eximlog="${EPREFIX}/var/log/exim/exim_%s.log"
337 -e "s:LOG_FILE_PATH=${eximlog}:LOG_FILE_PATH=syslog:" \
339 cat >> Makefile <<- EOC
343 cat >> Makefile <<- EOC
344 LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
348 # starttls support (ssl)
351 echo "USE_GNUTLS=yes" >> Makefile
352 echo "USE_GNUTLS_PC=gnutls $(use dane && echo gnutls-dane)" \
354 use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
356 echo "USE_OPENSSL=yes" >> Makefile
357 echo "USE_OPENSSL_PC=openssl" >> Makefile
360 echo "DISABLE_TLS=yes" >> Makefile
365 cat >> Makefile <<- EOC
367 EXTRALIBS_EXIM += -lwrap
371 # Light Mail Transport Protocol
373 cat >> Makefile <<- EOC
380 cat >> Makefile <<- EOC
387 cat >> Makefile <<- EOC
390 DLOPEN_LOCAL_SCAN=yes
396 cat >> Makefile <<- EOC
403 # DANE is enabled by default
404 sed -i -e 's:^SUPPORT_DANE=yes:# SUPPORT_DANE=yes:' Makefile || die
409 cat >> Makefile <<- EOC
411 EXTRALIBS_EXIM += -lopendmarc
415 # Sender Policy Framework
417 cat >> Makefile <<- EOC
419 EXTRALIBS_EXIM += -lspf2
424 # experimental features
427 # Authenticated Receive Chain
429 echo "EXPERIMENTAL_ARC=yes">> Makefile
432 # Distributed Checksum Clearinghouse
434 echo "EXPERIMENTAL_DCC=yes">> Makefile
437 # Sender Rewriting Scheme
439 cat >> Makefile <<- EOC
441 EXTRALIBS_EXIM += -lsrs_alt
445 # Delivery Sender Notifications extra information in fail message
447 cat >> Makefile <<- EOC
448 EXPERIMENTAL_DSN_INFO=yes
453 # authentication (SMTP AUTH)
457 cat >> Makefile <<- EOC
465 cat >> Makefile <<- EOC
466 CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
473 if use dovecot-sasl; then
474 cat >> Makefile <<- EOC
479 # Pluggable Authentication Modules
481 cat >> Makefile <<- EOC
489 cat >> Makefile <<- EOC
490 RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
491 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
492 AUTH_LIBS += -lfreeradius-client
498 emake CC="$(tc-getCC)" HOSTCC="$(tc-getBUILD_CC)" \
499 AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO=''
503 cd "${S}"/build-exim-gentoo || die
509 fperms 4755 /usr/sbin/exim
511 dosym exim /usr/sbin/sendmail
512 dosym exim /usr/sbin/rsmtp
513 dosym exim /usr/sbin/rmail
514 dosym ../sbin/exim /usr/bin/mailq
515 dosym ../sbin/exim /usr/bin/newaliases
516 dosym ../sbin/sendmail /usr/lib/sendmail
518 for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
519 exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
520 convert4r3 convert4r4 exipick
525 dodoc -r "${S}"/doc/.
526 doman "${S}"/doc/exim.8
527 use dsn && dodoc "${S}"/README.DSN
528 use doc && dodoc "${WORKDIR}"/${PN}-pdf-${PV//rc/RC}/doc/*.pdf
532 newins "${S}"/src/configure.default exim.conf.dist
533 if use exiscan-acl; then
534 newins "${S}"/src/configure.default exim.conf.exiscan-acl
536 doins "${WORKDIR}"/system_filter.exim
537 doins "${FILESDIR}"/auth_conf.sub
539 pamd_mimic system-auth exim auth account
543 # fixup includes so they actually can be found when including
545 -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
547 insinto /usr/include/exim
548 doins {config,local_scan}.h ../src/{mytypes,store}.h
551 insinto /etc/logrotate.d
552 newins "${FILESDIR}/exim.logrotate" exim
554 newinitd "${FILESDIR}"/exim.rc10 exim
555 newconfd "${FILESDIR}"/exim.confd exim
558 "${FILESDIR}"/{exim.service,exim.socket,exim-submission.socket}
560 "${FILESDIR}"/exim_at.service 'exim@.service'
562 "${FILESDIR}"/exim-submission_at.service 'exim-submission@.service'
564 diropts -m 0750 -o ${MAILUSER} -g ${MAILGROUP}
565 keepdir /var/log/${PN}
569 if [[ ! -f ${EROOT}/etc/exim/exim.conf ]] ; then
570 einfo "${EROOT}/etc/exim/system_filter.exim is a sample system_filter."
571 einfo "${EROOT}/etc/exim/auth_conf.sub contains the configuration sub"
572 einfo "for using smtp auth."
573 einfo "Please create ${EROOT}/etc/exim/exim.conf from"
574 einfo " ${EROOT}/etc/exim/exim.conf.dist."
577 einfo "DMARC support requires ${EROOT}/etc/exim/opendmarc.tlds"
578 einfo "you can populate this file with the contents downloaded from"
579 einfo " https://publicsuffix.org/list/public_suffix_list.dat"
582 einfo "DCC support is experimental, you can find some limited"
583 einfo "documentation at the bottom of this prerelease message:"
584 einfo " http://article.gmane.org/gmane.mail.exim.devel/3579"
586 use srs && einfo "SRS support is experimental"
587 use dsn && einfo "extra information in fail DSN message is experimental"
588 elog "The obsolete acl condition 'demime' is removed, the replacements"
589 elog "are the ACLs acl_smtp_mime and acl_not_smtp_mime"