exim-4.89.ebuild 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="6"
  4. inherit eutils toolchain-funcs multilib pam systemd
  5. 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 elibc_glibc"
  6. REQUIRED_USE="
  7. dane? ( !gnutls )
  8. dmarc? ( spf dkim )
  9. pkcs11? ( gnutls )
  10. spf? ( exiscan-acl )
  11. srs? ( exiscan-acl )
  12. "
  13. 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}-pdf-${PV//rc/RC}.tar.bz2 )"
  18. HOMEPAGE="http://www.exim.org/"
  19. SLOT="0"
  20. LICENSE="GPL-2"
  21. KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~x86-solaris"
  22. COMMON_DEPEND=">=sys-apps/sed-4.0.5
  23. >=sys-libs/db-3.2:=
  24. dev-libs/libpcre
  25. perl? ( dev-lang/perl:= )
  26. pam? ( virtual/pam )
  27. tcpd? ( sys-apps/tcp-wrappers )
  28. ssl? (
  29. !libressl? ( dev-libs/openssl:0= )
  30. libressl? ( dev-libs/libressl:= )
  31. )
  32. gnutls? ( net-libs/gnutls[pkcs11?]
  33. dev-libs/libtasn1 )
  34. ldap? ( >=net-nds/openldap-2.0.7 )
  35. nis? ( elibc_glibc? ( || (
  36. <sys-libs/glibc-2.23
  37. >=sys-libs/glibc-2.23[rpc]
  38. ) ) )
  39. mysql? ( virtual/libmysqlclient )
  40. postgres? ( dev-db/postgresql:= )
  41. sasl? ( >=dev-libs/cyrus-sasl-2.1.26-r2 )
  42. redis? ( dev-libs/hiredis )
  43. spf? ( >=mail-filter/libspf2-1.2.5-r1 )
  44. dmarc? ( mail-filter/opendmarc )
  45. srs? ( mail-filter/libsrs_alt )
  46. X? ( x11-proto/xproto
  47. x11-libs/libX11
  48. x11-libs/libXmu
  49. x11-libs/libXt
  50. x11-libs/libXaw
  51. )
  52. sqlite? ( dev-db/sqlite )
  53. radius? ( net-dialup/freeradius-client )
  54. virtual/libiconv
  55. "
  56. # added X check for #57206
  57. DEPEND="${COMMON_DEPEND}
  58. virtual/pkgconfig"
  59. RDEPEND="${COMMON_DEPEND}
  60. !mail-mta/courier
  61. !mail-mta/esmtp
  62. !mail-mta/mini-qmail
  63. !<mail-mta/msmtp-1.4.19-r1
  64. !>=mail-mta/msmtp-1.4.19-r1[mta]
  65. !mail-mta/netqmail
  66. !mail-mta/nullmailer
  67. !mail-mta/postfix
  68. !mail-mta/qmail-ldap
  69. !mail-mta/sendmail
  70. !mail-mta/opensmtpd
  71. !<mail-mta/ssmtp-2.64-r2
  72. !>=mail-mta/ssmtp-2.64-r2[mta]
  73. !net-mail/mailwrapper
  74. >=net-mail/mailbase-0.00-r5
  75. virtual/logger
  76. dcc? ( mail-filter/dcc )
  77. selinux? ( sec-policy/selinux-exim )
  78. "
  79. S=${WORKDIR}/${P//rc/RC}
  80. src_prepare() {
  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.89-as-needed-ldflags.patch # 352265, 391279
  87. epatch "${FILESDIR}"/exim-4.76-crosscompile.patch # 266591
  88. if use maildir ; then
  89. epatch "${FILESDIR}"/exim-4.20-maildir.patch
  90. else
  91. epatch "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
  92. fi
  93. eapply_user
  94. # user Exim believes it should be
  95. MAILUSER=mail
  96. MAILGROUP=mail
  97. if use prefix && [[ ${EUID} != 0 ]] ; then
  98. MAILUSER=$(id -un)
  99. MAILGROUP=$(id -gn)
  100. fi
  101. }
  102. src_configure() {
  103. # general config and paths
  104. sed -i.orig \
  105. -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${EPREFIX}/etc/mail/aliases'" \
  106. "${S}"/src/configure.default || die
  107. sed -i -e 's/^buildname=.*/buildname=exim-gentoo/g' Makefile || die
  108. sed -e "48i\CFLAGS=${CFLAGS}" \
  109. -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=${EPREFIX}/usr/sbin:" \
  110. -e "s:EXIM_USER=:EXIM_USER=${MAILUSER}:" \
  111. -e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=${EPREFIX}/etc/exim/exim.conf:" \
  112. -e "s:ZCAT_COMMAND=.*$:ZCAT_COMMAND=${EPREFIX}/bin/zcat:" \
  113. -e "s:COMPRESS_COMMAND=.*$:COMPRESS_COMMAND=${EPREFIX}/bin/gzip:" \
  114. src/EDITME > Local/Makefile
  115. if use elibc_musl; then
  116. sed -e 's/^LIBS = -lnsl/LIBS =/g' \
  117. -i OS/Makefile-Linux
  118. fi
  119. cd Local
  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
  124. HAVE_ICONV=yes
  125. EOC
  126. # if we use libiconv, now is the time to tell so
  127. use !elibc_glibc && use !elibc_musl && echo "EXTRALIBS_EXIM=-liconv" >> Makefile
  128. # support for IPv6
  129. if use ipv6; then
  130. cat >> Makefile <<- EOC
  131. HAVE_IPV6=YES
  132. EOC
  133. fi
  134. #
  135. # mail storage formats
  136. # mailstore is Exim's traditional storage format
  137. cat >> Makefile <<- EOC
  138. SUPPORT_MAILSTORE=yes
  139. EOC
  140. # mbox
  141. if use mbx; then
  142. cat >> Makefile <<- EOC
  143. SUPPORT_MBX=yes
  144. EOC
  145. fi
  146. # maildir
  147. if use maildir; then
  148. cat >> Makefile <<- EOC
  149. SUPPORT_MAILDIR=yes
  150. EOC
  151. fi
  152. #
  153. # lookup methods
  154. # use the "native" interfaces to the DBM and CDB libraries, support
  155. # passwd and directory lookups by default
  156. cat >> Makefile <<- EOC
  157. USE_DB=yes
  158. DBMLIB=-ldb
  159. LOOKUP_CDB=yes
  160. LOOKUP_PASSWD=yes
  161. LOOKUP_DSEARCH=yes
  162. EOC
  163. if ! use dnsdb; then
  164. # DNSDB lookup is enabled by default
  165. sed -i "s:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:" Makefile
  166. fi
  167. if use ldap; then
  168. cat >> Makefile <<- EOC
  169. LOOKUP_LDAP=yes
  170. LDAP_LIB_TYPE=OPENLDAP2
  171. LOOKUP_INCLUDE += -I"${EROOT}"usr/include/ldap
  172. LOOKUP_LIBS += -lldap -llber
  173. EOC
  174. fi
  175. if use mysql; then
  176. cat >> Makefile <<- EOC
  177. LOOKUP_MYSQL=yes
  178. LOOKUP_INCLUDE += $(mysql_config --include)
  179. LOOKUP_LIBS += $(mysql_config --libs)
  180. EOC
  181. fi
  182. if use nis; then
  183. cat >> Makefile <<- EOC
  184. LOOKUP_NIS=yes
  185. LOOKUP_NISPLUS=yes
  186. EOC
  187. fi
  188. if use postgres; then
  189. cat >> Makefile <<- EOC
  190. LOOKUP_PGSQL=yes
  191. LOOKUP_INCLUDE += -I$(pg_config --includedir)
  192. LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
  193. EOC
  194. fi
  195. if use sqlite; then
  196. cat >> Makefile <<- EOC
  197. LOOKUP_SQLITE=yes
  198. LOOKUP_SQLITE_PC=sqlite3
  199. EOC
  200. fi
  201. if use redis; then
  202. cat >> Makefile <<- EOC
  203. LOOKUP_REDIS=yes
  204. LOOKUP_LIBS += -lhiredis
  205. EOC
  206. fi
  207. #
  208. # Exim monitor, enabled by default, controlled via X USE-flag,
  209. # disable if not requested, bug #46778
  210. if use X; then
  211. cp ../exim_monitor/EDITME eximon.conf || die
  212. else
  213. sed -i -e '/^EXIM_MONITOR=/s/^/# /' Makefile
  214. fi
  215. #
  216. # features
  217. # content scanning support
  218. if use exiscan-acl; then
  219. cat >> Makefile <<- EOC
  220. WITH_CONTENT_SCAN=yes
  221. WITH_OLD_DEMIME=yes
  222. EOC
  223. fi
  224. # DomainKeys Identified Mail, RFC4871
  225. if ! use dkim; then
  226. # DKIM is enabled by default
  227. cat >> Makefile <<- EOC
  228. DISABLE_DKIM=yes
  229. EOC
  230. fi
  231. # Per-Recipient-Data-Response
  232. if ! use prdr; then
  233. # PRDR is enabled by default
  234. cat >> Makefile <<- EOC
  235. DISABLE_PRDR=yes
  236. EOC
  237. fi
  238. # log to syslog
  239. if use syslog; then
  240. sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Makefile
  241. cat >> Makefile <<- EOC
  242. LOG_FILE_PATH=syslog
  243. EOC
  244. else
  245. cat >> Makefile <<- EOC
  246. LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
  247. EOC
  248. fi
  249. # starttls support (ssl)
  250. if use ssl; then
  251. echo "SUPPORT_TLS=yes" >> Makefile
  252. if use gnutls; then
  253. echo "USE_GNUTLS=yes" >> Makefile
  254. echo "USE_GNUTLS_PC=gnutls" >> Makefile
  255. use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
  256. else
  257. echo "USE_OPENSSL_PC=openssl" >> Makefile
  258. fi
  259. fi
  260. # TCP wrappers
  261. if use tcpd; then
  262. cat >> Makefile <<- EOC
  263. USE_TCP_WRAPPERS=yes
  264. EXTRALIBS_EXIM += -lwrap
  265. EOC
  266. fi
  267. # Light Mail Transport Protocol
  268. if use lmtp; then
  269. cat >> Makefile <<- EOC
  270. TRANSPORT_LMTP=yes
  271. EOC
  272. fi
  273. # embedded Perl
  274. if use perl; then
  275. cat >> Makefile <<- EOC
  276. EXIM_PERL=perl.o
  277. EOC
  278. fi
  279. # dlfunc
  280. if use dlfunc; then
  281. cat >> Makefile <<- EOC
  282. EXPAND_DLFUNC=yes
  283. EOC
  284. fi
  285. #
  286. # experimental features
  287. # DANE
  288. if use dane; then
  289. cat >> Makefile <<- EOC
  290. EXPERIMENTAL_DANE=yes
  291. EOC
  292. fi
  293. # Distributed Checksum Clearinghouse
  294. if use dcc; then
  295. echo "EXPERIMENTAL_DCC=yes">> Makefile
  296. fi
  297. # Sender Policy Framework
  298. if use spf; then
  299. cat >> Makefile <<- EOC
  300. EXPERIMENTAL_SPF=yes
  301. EXTRALIBS_EXIM += -lspf2
  302. EOC
  303. fi
  304. # Sender Rewriting Scheme
  305. if use srs; then
  306. cat >> Makefile <<- EOC
  307. EXPERIMENTAL_SRS=yes
  308. EXTRALIBS_EXIM += -lsrs_alt
  309. EOC
  310. fi
  311. # DMARC
  312. if use dmarc; then
  313. cat >> Makefile <<- EOC
  314. EXPERIMENTAL_DMARC=yes
  315. EXTRALIBS_EXIM += -lopendmarc
  316. EOC
  317. fi
  318. # Transport post-delivery actions
  319. if use tpda; then
  320. cat >> Makefile <<- EOC
  321. EXPERIMENTAL_EVENT=yes
  322. EOC
  323. fi
  324. # Proxy Protocol
  325. if use proxy; then
  326. cat >> Makefile <<- EOC
  327. EXPERIMENTAL_PROXY=yes
  328. EOC
  329. fi
  330. # Delivery Sender Notifications
  331. if use dsn; then
  332. cat >> Makefile <<- EOC
  333. EXPERIMENTAL_DSN=yes
  334. EOC
  335. fi
  336. #
  337. # authentication (SMTP AUTH)
  338. # standard bits
  339. cat >> Makefile <<- EOC
  340. AUTH_SPA=yes
  341. AUTH_CRAM_MD5=yes
  342. AUTH_PLAINTEXT=yes
  343. EOC
  344. # Cyrus SASL
  345. if use sasl; then
  346. cat >> Makefile <<- EOC
  347. CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
  348. AUTH_CYRUS_SASL=yes
  349. AUTH_LIBS += -lsasl2
  350. EOC
  351. fi
  352. # Dovecot
  353. if use dovecot-sasl; then
  354. cat >> Makefile <<- EOC
  355. AUTH_DOVECOT=yes
  356. EOC
  357. fi
  358. # Pluggable Authentication Modules
  359. if use pam; then
  360. cat >> Makefile <<- EOC
  361. SUPPORT_PAM=yes
  362. AUTH_LIBS += -lpam
  363. EOC
  364. fi
  365. # Radius
  366. if use radius; then
  367. cat >> Makefile <<- EOC
  368. RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
  369. RADIUS_LIB_TYPE=RADIUSCLIENTNEW
  370. AUTH_LIBS += -lfreeradius-client
  371. EOC
  372. fi
  373. }
  374. src_compile() {
  375. emake CC="$(tc-getCC)" HOSTCC="$(tc-getCC $CBUILD)" \
  376. AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO='' \
  377. || die "make failed"
  378. }
  379. src_install () {
  380. cd "${S}"/build-exim-gentoo || die
  381. dosbin exim
  382. if use X; then
  383. dosbin eximon.bin
  384. dosbin eximon
  385. fi
  386. fperms 4755 /usr/sbin/exim
  387. dosym exim /usr/sbin/sendmail
  388. dosym exim /usr/sbin/rsmtp
  389. dosym exim /usr/sbin/rmail
  390. dosym /usr/sbin/exim /usr/bin/mailq
  391. dosym /usr/sbin/exim /usr/bin/newaliases
  392. dosym /usr/sbin/sendmail /usr/lib/sendmail
  393. for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
  394. exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
  395. convert4r3 convert4r4 exipick
  396. do
  397. dosbin $i
  398. done
  399. dodoc "${S}"/doc/*
  400. doman "${S}"/doc/exim.8
  401. use dsn && dodoc "${S}"/README.DSN
  402. use doc && dodoc "${WORKDIR}"/${PN}-pdf-${PV//rc/RC}/doc/*.pdf
  403. # conf files
  404. insinto /etc/exim
  405. newins "${S}"/src/configure.default exim.conf.dist
  406. if use exiscan-acl; then
  407. newins "${S}"/src/configure.default exim.conf.exiscan-acl
  408. fi
  409. doins "${WORKDIR}"/system_filter.exim
  410. doins "${FILESDIR}"/auth_conf.sub
  411. pamd_mimic system-auth exim auth account
  412. # headers, #436406
  413. if use dlfunc ; then
  414. # fixup includes so they actually can be found when including
  415. sed -i \
  416. -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
  417. local_scan.h || die
  418. insinto /usr/include/exim
  419. doins {config,local_scan}.h ../src/{mytypes,store}.h
  420. fi
  421. insinto /etc/logrotate.d
  422. newins "${FILESDIR}/exim.logrotate" exim
  423. newinitd "${FILESDIR}"/exim.rc10 exim
  424. newconfd "${FILESDIR}"/exim.confd exim
  425. systemd_dounit "${FILESDIR}"/{exim.service,exim.socket,exim-submission.socket}
  426. systemd_newunit "${FILESDIR}"/exim_at.service 'exim@.service'
  427. systemd_newunit "${FILESDIR}"/exim-submission_at.service 'exim-submission@.service'
  428. diropts -m 0750 -o ${MAILUSER} -g ${MAILGROUP}
  429. dodir /var/log/${PN}
  430. }
  431. pkg_postinst() {
  432. if [[ ! -f ${EROOT}etc/exim/exim.conf ]] ; then
  433. einfo "${EROOT}etc/exim/system_filter.exim is a sample system_filter."
  434. einfo "${EROOT}etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
  435. einfo "Please create ${EROOT}etc/exim/exim.conf from ${EROOT}etc/exim/exim.conf.dist."
  436. fi
  437. use dane && einfo "DANE support is experimental"
  438. if use dcc ; then
  439. einfo "DCC support is experimental, you can find some limited"
  440. einfo "documentation at the bottom of this prerelease message:"
  441. einfo "http://article.gmane.org/gmane.mail.exim.devel/3579"
  442. fi
  443. use spf && einfo "SPF support is experimental"
  444. use srs && einfo "SRS support is experimental"
  445. if use dmarc ; then
  446. einfo "DMARC support is experimental. See global settings to"
  447. einfo "configure DMARC, for usage see the documentation at "
  448. einfo "experimental-spec.txt."
  449. fi
  450. use tpda && einfo "TPDA/EVENT support is experimental"
  451. use proxy && einfo "proxy support is experimental"
  452. use dsn && einfo "DSN support is experimental"
  453. elog "The obsolete acl condition 'demime' is removed, the replacements"
  454. elog "are the ACLs acl_smtp_mime and acl_not_smtp_mime"
  455. }