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 COMM_URI="https://downloads.exim.org/exim4$([[ ${PV} == *_rc* ]] && echo /test)"
29 DESCRIPTION="A highly configurable, drop-in replacement for sendmail"
30 SRC_URI="${COMM_URI}/${P//rc/RC}.tar.xz
31 mirror://gentoo/system_filter.exim.gz
32 doc? ( ${COMM_URI}/${PN}-pdf-${PV//rc/RC}.tar.xz )"
33 HOMEPAGE="https://www.exim.org/"
37 KEYWORDS="~alpha amd64 arm ~hppa ~ia64 ~ppc ~ppc64 sparc x86 ~x86-solaris"
39 COMMON_DEPEND=">=sys-apps/sed-4.0.5
40 ( >=sys-libs/db-3.2:= <sys-libs/db-6:= )
42 idn? ( net-dns/libidn:= net-dns/libidn2:= )
43 perl? ( dev-lang/perl:= )
45 tcpd? ( sys-apps/tcp-wrappers )
47 !libressl? ( dev-libs/openssl:0= )
48 libressl? ( dev-libs/libressl:= )
51 net-libs/gnutls:0=[pkcs11?]
54 ldap? ( >=net-nds/openldap-2.0.7 )
61 mysql? ( dev-db/mysql-connector-c:= )
62 postgres? ( dev-db/postgresql:= )
63 sasl? ( >=dev-libs/cyrus-sasl-2.1.26-r2 )
64 redis? ( dev-libs/hiredis )
65 spf? ( >=mail-filter/libspf2-1.2.5-r1 )
66 dmarc? ( mail-filter/opendmarc )
67 srs? ( mail-filter/libsrs_alt )
74 sqlite? ( dev-db/sqlite )
75 radius? ( net-dialup/freeradius-client )
77 elibc_glibc? ( net-libs/libnsl )
79 # added X check for #57206
80 BDEPEND="virtual/pkgconfig"
81 DEPEND="${COMMON_DEPEND}"
82 RDEPEND="${COMMON_DEPEND}
86 !<mail-mta/msmtp-1.4.19-r1
87 !>=mail-mta/msmtp-1.4.19-r1[mta]
94 !<mail-mta/ssmtp-2.64-r2
95 !>=mail-mta/ssmtp-2.64-r2[mta]
97 >=net-mail/mailbase-0.00-r5
99 dcc? ( mail-filter/dcc )
100 selinux? ( sec-policy/selinux-exim )
104 "${FILESDIR}"/exim-4.69-r1.27021.patch
105 "${FILESDIR}"/exim-4.92-localscan_dlopen.patch
108 S=${WORKDIR}/${P//rc/RC}
111 # Legacy patches which need a respin for -p1
112 eapply -p0 "${FILESDIR}"/exim-4.14-tail.patch
113 eapply -p0 "${FILESDIR}"/exim-4.74-radius-db-ENV-clash.patch # 287426
114 eapply -p0 "${FILESDIR}"/exim-4.82-makefile-freebsd.patch # 235785
115 eapply -p0 "${FILESDIR}"/exim-4.89-as-needed-ldflags.patch # 352265, 391279
116 eapply -p0 "${FILESDIR}"/exim-4.76-crosscompile.patch # 266591
117 eapply -p2 "${FILESDIR}"/exim-4.92-fix-eval-expansion-32bit.patch #687554
119 if use maildir ; then
120 eapply "${FILESDIR}"/exim-4.20-maildir.patch
122 eapply -p0 "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
127 # user Exim believes it should be
130 if use prefix && [[ ${EUID} != 0 ]] ; then
137 # general config and paths
139 local aliases="${EPREFIX}/etc/mail/aliases"
141 -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${aliases}'" \
142 src/configure.default || die
144 sed -i -e 's/^buildname=.*/buildname=exim-gentoo/' Makefile || die
146 if use elibc_musl; then
147 sed -i -e 's/^LIBS = -lnsl/LIBS =/g' OS/Makefile-Linux || die
150 local conffile="${EPREFIX}/etc/exim/exim.conf"
151 sed -e "48i\CFLAGS=${CFLAGS}" \
152 -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=${EPREFIX}/usr/sbin:" \
153 -e "s:EXIM_USER=:EXIM_USER=${MAILUSER}:" \
154 -e "s:CONFIGURE_FILE=.*$:CONFIGURE_FILE=${conffile}:" \
155 -e "s:ZCAT_COMMAND=.*$:ZCAT_COMMAND=${EPREFIX}/bin/zcat:" \
156 -e "s:COMPRESS_COMMAND=.*$:COMPRESS_COMMAND=${EPREFIX}/bin/gzip:" \
157 src/EDITME > Local/Makefile || die
159 # work on Local/Makefile from now on
162 cat >> Makefile <<- EOC
163 INFO_DIRECTORY=${EPREFIX}/usr/share/info
164 PID_FILE_PATH=${EPREFIX}/run/exim.pid
165 SPOOL_DIRECTORY=${EPREFIX}/var/spool/exim
169 # if we use libiconv, now is the time to tell so
170 use !elibc_glibc && use !elibc_musl && \
171 echo "EXTRALIBS_EXIM=-liconv" >> Makefile
175 cat >> Makefile <<- EOC
182 cat >> Makefile <<- EOC
184 SUPPORT_I18N_2008=yes
185 EXTRALIBS_EXIM += -lidn -lidn2
190 # mail storage formats
193 # mailstore is Exim's traditional storage format
194 cat >> Makefile <<- EOC
195 SUPPORT_MAILSTORE=yes
200 cat >> Makefile <<- EOC
207 cat >> Makefile <<- EOC
215 # use the "native" interfaces to the DBM and CDB libraries, support
216 # passwd and directory lookups by default
217 local DB_VERS="5.3 5.1 4.8 4.7 4.6 4.5 4.4 4.3 4.2 3.2"
218 cat >> Makefile <<- EOC
220 CFLAGS+=-I$(db_includedir ${DB_VERS})
221 DBMLIB=-l$(db_libname ${DB_VERS})
228 # DNSDB lookup is enabled by default
229 sed -i -e 's:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:' Makefile || die
233 cat >> Makefile <<- EOC
235 LDAP_LIB_TYPE=OPENLDAP2
236 LOOKUP_INCLUDE += -I"${EPREFIX}"/usr/include/ldap
237 LOOKUP_LIBS += -lldap -llber
242 cat >> Makefile <<- EOC
244 LOOKUP_INCLUDE += $(mysql_config --include)
245 LOOKUP_LIBS += $(mysql_config --libs)
250 cat >> Makefile <<- EOC
254 if use elibc_glibc ; then
255 cat >> Makefile <<- EOC
256 CFLAGS += -I"${EPREFIX}"/usr/include/tirpc
261 if use postgres; then
262 cat >> Makefile <<- EOC
264 LOOKUP_INCLUDE += -I$(pg_config --includedir)
265 LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
270 cat >> Makefile <<- EOC
272 LOOKUP_SQLITE_PC=sqlite3
277 cat >> Makefile <<- EOC
279 LOOKUP_LIBS += -lhiredis
283 # Exim monitor, enabled by default, controlled via X USE-flag,
284 # disable if not requested, bug #46778
286 cp ../exim_monitor/EDITME eximon.conf || die
288 sed -i -e '/^EXIM_MONITOR=/s/^/# /' Makefile || die
295 # content scanning support
296 if use exiscan-acl; then
297 cat >> Makefile <<- EOC
298 WITH_CONTENT_SCAN=yes
302 # DomainKeys Identified Mail, RFC4871
304 # DKIM is enabled by default
305 cat >> Makefile <<- EOC
310 # Per-Recipient-Data-Response
312 # PRDR is enabled by default
313 cat >> Makefile <<- EOC
318 # Transport post-delivery actions
319 if use !tpda && use !dane; then
320 # EVENT is enabled by default
321 cat >> Makefile <<- EOC
328 local eximlog="${EPREFIX}/var/log/exim/exim_%s.log"
330 -e "s:LOG_FILE_PATH=${eximlog}:LOG_FILE_PATH=syslog:" \
332 cat >> Makefile <<- EOC
336 cat >> Makefile <<- EOC
337 LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
341 # starttls support (ssl)
343 echo "SUPPORT_TLS=yes" >> Makefile
345 echo "USE_GNUTLS=yes" >> Makefile
346 echo "USE_GNUTLS_PC=gnutls" >> Makefile
347 use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
349 echo "USE_OPENSSL_PC=openssl" >> Makefile
355 cat >> Makefile <<- EOC
357 EXTRALIBS_EXIM += -lwrap
361 # Light Mail Transport Protocol
363 cat >> Makefile <<- EOC
370 cat >> Makefile <<- EOC
377 cat >> Makefile <<- EOC
380 DLOPEN_LOCAL_SCAN=yes
386 cat >> Makefile <<- EOC
393 cat >> Makefile <<- EOC
398 # Sender Policy Framework
400 cat >> Makefile <<- EOC
402 EXTRALIBS_EXIM += -lspf2
407 # experimental features
410 # Authenticated Receive Chain
412 echo "EXPERIMENTAL_ARC=yes">> Makefile
415 # Distributed Checksum Clearinghouse
417 echo "EXPERIMENTAL_DCC=yes">> Makefile
420 # Sender Rewriting Scheme
422 cat >> Makefile <<- EOC
424 EXTRALIBS_EXIM += -lsrs_alt
430 cat >> Makefile <<- EOC
431 EXPERIMENTAL_DMARC=yes
432 EXTRALIBS_EXIM += -lopendmarc
436 # Delivery Sender Notifications extra information in fail message
438 cat >> Makefile <<- EOC
439 EXPERIMENTAL_DSN_INFO=yes
444 # authentication (SMTP AUTH)
448 cat >> Makefile <<- EOC
456 cat >> Makefile <<- EOC
457 CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
464 if use dovecot-sasl; then
465 cat >> Makefile <<- EOC
470 # Pluggable Authentication Modules
472 cat >> Makefile <<- EOC
480 cat >> Makefile <<- EOC
481 RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
482 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
483 AUTH_LIBS += -lfreeradius-client
489 emake CC="$(tc-getCC)" HOSTCC="$(tc-getBUILD_CC)" \
490 AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO=''
494 cd "${S}"/build-exim-gentoo || die
500 fperms 4755 /usr/sbin/exim
502 dosym exim /usr/sbin/sendmail
503 dosym exim /usr/sbin/rsmtp
504 dosym exim /usr/sbin/rmail
505 dosym ../sbin/exim /usr/bin/mailq
506 dosym ../sbin/exim /usr/bin/newaliases
507 dosym ../sbin/sendmail /usr/lib/sendmail
509 for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
510 exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
511 convert4r3 convert4r4 exipick
516 dodoc -r "${S}"/doc/.
517 doman "${S}"/doc/exim.8
518 use dsn && dodoc "${S}"/README.DSN
519 use doc && dodoc "${WORKDIR}"/${PN}-pdf-${PV//rc/RC}/doc/*.pdf
523 newins "${S}"/src/configure.default exim.conf.dist
524 if use exiscan-acl; then
525 newins "${S}"/src/configure.default exim.conf.exiscan-acl
527 doins "${WORKDIR}"/system_filter.exim
528 doins "${FILESDIR}"/auth_conf.sub
530 pamd_mimic system-auth exim auth account
534 # fixup includes so they actually can be found when including
536 -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
538 insinto /usr/include/exim
539 doins {config,local_scan}.h ../src/{mytypes,store}.h
542 insinto /etc/logrotate.d
543 newins "${FILESDIR}/exim.logrotate" exim
545 newinitd "${FILESDIR}"/exim.rc10 exim
546 newconfd "${FILESDIR}"/exim.confd exim
549 "${FILESDIR}"/{exim.service,exim.socket,exim-submission.socket}
551 "${FILESDIR}"/exim_at.service 'exim@.service'
553 "${FILESDIR}"/exim-submission_at.service 'exim-submission@.service'
555 diropts -m 0750 -o ${MAILUSER} -g ${MAILGROUP}
556 keepdir /var/log/${PN}
560 if [[ ! -f ${EROOT}/etc/exim/exim.conf ]] ; then
561 einfo "${EROOT}/etc/exim/system_filter.exim is a sample system_filter."
562 einfo "${EROOT}/etc/exim/auth_conf.sub contains the configuration sub"
563 einfo "for using smtp auth."
564 einfo "Please create ${EROOT}/etc/exim/exim.conf from"
565 einfo " ${EROOT}/etc/exim/exim.conf.dist."
568 einfo "DCC support is experimental, you can find some limited"
569 einfo "documentation at the bottom of this prerelease message:"
570 einfo "http://article.gmane.org/gmane.mail.exim.devel/3579"
572 use srs && einfo "SRS support is experimental"
574 einfo "DMARC support is experimental. See global settings to"
575 einfo "configure DMARC, for usage see the documentation at "
576 einfo "experimental-spec.txt."
578 use dsn && einfo "extra information in fail DSN message is experimental"
579 elog "The obsolete acl condition 'demime' is removed, the replacements"
580 elog "are the ACLs acl_smtp_mime and acl_not_smtp_mime"