+# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
+# Contributor: Ash Berlin-Taylor <ash.berlin@gmail.com>
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Contributor: Ćukasz Jendrysik <scadu@yandex.com>
+# Contributor: Jesse Young <jlyo@jlyo.org>
+# Maintainer: Jesse Young <jlyo@jlyo.org>
+pkgname=exim-openldap
+_pkgname=exim
+provides=$_pkgname
+pkgver=4.95
+pkgrel=1
+pkgdesc="Replacement package for exim with built-in OpenLDAP support"
+url="https://www.exim.org/"
+arch="all"
+license="GPL-2.0-or-later"
+options="!check suid"
+pkgusers="$_pkgname"
+pkggroups="$_pkgname mail"
+depends="ca-certificates exim-openrc"
+makedepends="bash tdb-dev gawk libidn-dev libspf2-dev linux-headers
+ mariadb-connector-c-dev openssl1.1-compat-dev pcre-dev perl libpq-dev sqlite-dev
+ openldap-dev
+ "
+install="$pkgname.pre-install"
+source="https://ftp.exim.org/pub/exim/exim4/exim-$pkgver.tar.xz
+ bounce-charset.patch
+ exim.Makefile
+ exim.logrotate
+ "
+builddir="$srcdir/$_pkgname-$pkgver"
+
+# secfixes:
+# 4.94.2-r0:
+# - CVE-2021-27216
+# - CVE-2020-28007
+# - CVE-2020-28008
+# - CVE-2020-28009
+# - CVE-2020-28010
+# - CVE-2020-28011
+# - CVE-2020-28012
+# - CVE-2020-28013
+# - CVE-2020-28014
+# - CVE-2020-28015
+# - CVE-2020-28016
+# - CVE-2020-28017
+# - CVE-2020-28018
+# - CVE-2020-28019
+# - CVE-2020-28020
+# - CVE-2020-28021
+# - CVE-2020-28022
+# - CVE-2020-28023
+# - CVE-2020-28024
+# - CVE-2020-28025
+# - CVE-2020-28026
+# 4.93-r1:
+# - CVE-2020-12783
+# 4.92.2-r1:
+# - CVE-2019-16928
+# 4.92.2-r0:
+# - CVE-2019-15846
+# 4.92.1-r0:
+# - CVE-2019-13917
+# 4.92-r0:
+# - CVE-2019-10149
+# 4.89-r5:
+# - CVE-2017-1000369
+# 4.89-r7:
+# - CVE-2017-16943
+# 4.89.1-r0:
+# - CVE-2017-16944
+# 4.90.1-r0:
+# - CVE-2018-6789
+
+prepare() {
+ default_prepare
+
+ cp "$srcdir"/$_pkgname.Makefile Local/Makefile
+ sed -i \
+ -e 's/-lnsl//g' \
+ -e 's/^HAVE_ICONV.*$//' \
+ OS/Makefile-Linux
+}
+
+build() {
+ make makefile
+ make
+}
+
+package() {
+ install -m750 -D -g mail -d "$pkgdir"/etc/mail
+ make DESTDIR="$pkgdir" INSTALL_ARG="-no_symlink -no_chown exim" install
+ cd "$pkgdir"/usr/sbin
+ mv exim-${pkgver%.*}* exim
+ chmod u+s exim
+ local i; for i in mailq rmail rsmtp runq sendmail newaliases; do
+ ln -s exim $i
+ done
+ install -Dm644 "$srcdir"/$_pkgname.logrotate "$pkgdir"/etc/logrotate.d/$_pkgname
+ # Fix clamav local socket path, Add variant to spamd address
+ sed -i \
+ -e 's~# av_scanner = clamd:/tmp/clamd~# av_scanner = clamd:/run/clamav/clamd.sock~' \
+ -e '/# spamd_address = 127.0.0.1 783/a# spamd_address = 127.0.0.1 11333 variant=rspamd' \
+ "$pkgdir"/etc/$_pkgname/$_pkgname.conf
+ # Create subdirs for logs and extensions
+ install -dm750 -o $_pkgname -g mail "$pkgdir"/var/log/$_pkgname
+ mkdir -p "$pkgdir"/usr/lib/$_pkgname
+}
+
+sha512sums="
+93d09c20d99f27da5edbe3e6dc7d25aa4548faa2b67ca26f2cc0b4aeaf58398dd468e0263714fcf0df97531f05d16fcd3f1f0e9d0656ead7858a66b248a44a65 exim-4.95.tar.xz
+691df92954f015711398350963ea321d143127bc731a985bcacc5364c71b6df84b6c21a2e8dc3cc2048fcd3dd02def3dc8015f4d84dd672f23d5a41348e72dc7 bounce-charset.patch
+4d2a33d2d9399c2d9485155585a180f1314fdc6f0ea164f3ebd74dbafa0b968f0edfbdd6d6ed7cdb4bc63696073b66f25e03317cc304192457e40fa30a12e207 exim.Makefile
+28e748693a6a72d9943fa9c342ff041fe650fa6977f468dee127e845e6c2a91872ce33fb6f5698838906bde3ed92de7a91cdb0349cedc40b806261867e8c06cb exim.logrotate
+"