Subject: [alpine-aports] [PATCH v3] testing/exim: upgrade to 4.89

From: Valery Kartel <[email-masked]>
Date: Fri, 10 Mar 2017 11:17:12 +0200

- APKBUILD cleanups and improve redability
- add redis lookup backend support
- rewrite lookup backends building in APKBUILD
- rename lookup backends subpackages to exim-lookup_$backend
  and make it provides its old exim-$backend subpackages name.

---
v1 -> v2: remade exim-lookup_pgsql to provide compatibility
          name exim-postgresql and remove exim-postgresql subpackage.

v2 -> v3: - move lsearch, dsearch, passwd to modules
	  - make pure 'server' pack (just exim-binary, config, init scripts)
	  - exim package now depends on exim-server, minimal set of lookups
	    and ca-certificates
	  - rename conf.d variables to EXIM_ unique ones
	  - define checkconfig in init script
---
 testing/exim/APKBUILD      | 103 ++++++++++++++++++++++++++++-----------------
 testing/exim/exim.Makefile |   8 ++--
 testing/exim/exim.confd    |   4 +-
 testing/exim/exim.initd    |  16 ++++---
 4 files changed, 82 insertions(+), 49 deletions(-)

diff --git a/testing/exim/APKBUILD b/testing/exim/APKBUILD
index a25f5e58e1..2be4f4faef 100644
--- a/testing/exim/APKBUILD
+++ b/testing/exim/APKBUILD
@@ -4,27 +4,41 @@
 # Contributor: Jesse Young <[email-masked]>
 # Maintainer: Jesse Young <[email-masked]>
 pkgname=exim
-pkgver=4.88
-pkgrel=2
-pkgdesc="A Message Transfer Agent"
+pkgver=4.89
+pkgrel=0
+pkgdesc="EXIM - A Message Transfer Agent"
 url="http://www.exim.org/"
 arch="all"
 license="GPL2"
-options="suid"
-depends="ca-certificates"
+options="suid !check"
+depends="$pkgname-server $pkgname-lookup_lsearch $pkgname-lookup_dsearch
+	$pkgname-lookup_passwd ca-certificates
+	"
 pkgusers="exim"
 pkggroups="exim"
 makedepends="bash gawk perl $depends_dev db-dev pcre-dev libressl-dev libspf2-dev mariadb-dev
-	postgresql-dev sqlite-dev libidn-dev linux-headers"
+	postgresql-dev sqlite-dev libidn-dev linux-headers hiredis-dev
+	"
 install="exim.pre-install"
-subpackages="$pkgname-cdb $pkgname-dbmdb $pkgname-dnsdb $pkgname-sqlite $pkgname-mysql $pkgname-postgresql
-	$pkgname-utils $pkgname-scripts::noarch $pkgname-doc"
+subpackages="$pkgname-doc $pkgname-utils $pkgname-scripts::noarch
+	$pkgname-server
+	$pkgname-lookup_dbmdb:_lookup
+	$pkgname-lookup_dnsdb:_lookup
+	$pkgname-lookup_dsearch:_lookup
+	$pkgname-lookup_lsearch:_lookup
+	$pkgname-lookup_mysql:_lookup
+	$pkgname-lookup_passwd:_lookup
+	$pkgname-lookup_pgsql:_pgsql
+	$pkgname-lookup_redis:_lookup
+	$pkgname-lookup_sqlite:_lookup
+	"
 source="ftp://ftp.exim.org/pub/exim/exim4/$pkgname-$pkgver.tar.bz2
-	exim.Makefile
-	exim.confd
-	exim.initd
-	exim.logrotate
-	exim.gencert"
+	$pkgname.Makefile
+	$pkgname.confd
+	$pkgname.initd
+	$pkgname.logrotate
+	$pkgname.gencert
+	"
 builddir="$srcdir/$pkgname-$pkgver"
 
 prepare() {
@@ -49,15 +63,9 @@ package() {
 	install -m750 -D -g mail -d "$pkgdir"/etc/mail
 	make DESTDIR="$pkgdir" INSTALL_ARG="-no_symlink -no_chown exim" install || return 1
 	install -D -m644 doc/exim.8 "$pkgdir"/usr/share/man/man8/exim.8
-	cd "$pkgdir"/usr/sbin
-	mv exim-${pkgver%.*}* exim
-	chmod u+s exim
 	for i in mailq rmail rsmtp runq sendmail newaliases; do
-		ln -s exim $i
+		ln -s /usr/sbin/exim "$pkgdir"/usr/sbin/$i
 	done
-	install -Dm644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
-	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
-	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.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~' \
@@ -65,9 +73,25 @@ package() {
 		"$pkgdir"/etc/$pkgname/$pkgname.conf
 }
 
+server() {
+	pkgdesc="$pkgdesc (server)"
+	depends=
+	mkdir -p "$subpkgdir"/usr/sbin || return 1
+	mv "$pkgdir"/usr/sbin/$pkgname-${pkgver%.*}* \
+		"$subpkgdir"/usr/sbin/$pkgname || return 1
+	chmod u+s "$subpkgdir"/usr/sbin/$pkgname || return 1
+	install -Dm755 "$srcdir"/$pkgname.initd \
+		"$subpkgdir"/etc/init.d/$pkgname || return 1
+	install -Dm644 "$srcdir"/$pkgname.confd \
+		"$subpkgdir"/etc/conf.d/$pkgname || return 1
+	install -Dm644 "$srcdir"/$pkgname.logrotate \
+		"$subpkgdir"/etc/logrotate.d/$pkgname || return 1
+	mv "$pkgdir"/etc/$pkgname "$subpkgdir"/etc/ || return 1
+}
+
 scripts() {
-	pkgdesc="exim scripts"
-	depends="exim perl"
+	pkgdesc="$pkgdesc (scripts)"
+	depends="$pkgname perl"
 	cd "$builddir"
 	make	DESTDIR="$subpkgdir" \
 		INSTALL_ARG="exicyclog exim_checkaccess eximstats exiqgrep exigrep exinext exiqsumm exipick exiwhat convert4r3 convert4r4" \
@@ -76,32 +100,33 @@ scripts() {
 }
 
 utils() {
-	pkgdesc="exim utils"
-	depends="exim"
+	pkgdesc="$pkgdesc (utils)"
+	depends="$pkgname"
 	cd "$builddir"
 	make	DESTDIR="$subpkgdir" \
 		INSTALL_ARG="exim_dbmbuild exim_dumpdb exim_tidydb exim_fixdb exim_lock" \
 		install || return 1
-	install -m755 "$srcdir"/exim.gencert "$subpkgdir"/usr/sbin/exim_gencert || return 1
+	install -m755 "$srcdir"/$pkgname.gencert "$subpkgdir"/usr/sbin/exim_gencert || return 1
 	rm -fr "$subpkgdir"/etc
 }
 
-_mv_ext() {
-	pkgdesc="EXIM extension: $1"
-	depends="$pkgname"
-	install -D -m755 "$builddir"/build-Linux-*/lookups/$1.so "$subpkgdir"/usr/lib/$pkgname/$1.so
+_lookup() {
+	local name=${subpkgname#$pkgname-lookup_}
+	pkgdesc="EXIM lookup backend: $name"
+	depends="$pkgname-server"
+	provides="$pkgname-$name"
+	install -D -m755 "$builddir"/build-Linux-*/lookups/$name.so \
+		"$subpkgdir"/usr/lib/$pkgname/$name.so
 }
 
-sqlite() { _mv_ext sqlite; }
-mysql() { _mv_ext mysql; }
-postgresql() { _mv_ext pgsql; }
-cdb() { _mv_ext cdb; }
-dbmdb() { _mv_ext dbmdb; }
-dnsdb() { _mv_ext dnsdb; }
+_pgsql() {
+	_lookup || return 1
+	provides="$pkgname-postgresql"
+}
 
-sha512sums="ea094bf703628c201de119fc5f09539475e52158e935f8f2a9e4138c4a1bfe885017145c3cc5e22aa9087b195091955c69385ebf1ea0baec64ed5c1b8e3b1caf  exim-4.88.tar.bz2
-c0733014f52d78e3380c018109cf5628b498cea29e901344598ff128d9f3a190766ce9a5858f4fff6fc4b1c6f921dd1a3589f566eebc1f0ec709d2a8da2bbd82  exim.Makefile
-bb6f5ead067af19ace661cc92bcd428da97570aedd1f9dc5b61a34e7e3fb3e028be6c96d51df73353bdfcaf69a3ee053fb03d245f868d63ebf518aa96ec82d66  exim.confd
-3769e74a54566362bcdf57c45fbf7d130d7a7529fbc40befce431eef0387df117c71a5b57779c507e30d5b125913b5f26c9d16b17995521a1d94997be6dc3e02  exim.initd
+sha512sums="1e059966a93b47f055ab4ec2a4556f2c918aff56ea0367585f3a853f00411e9c275e13be4f9ae615a468fa06263135cd6a138fa1753f1b7fb3259a3321fcca65  exim-4.89.tar.bz2
+ac501743a0316e990a2179ae3b559123451f166b61dc058bc1b822710e4bbf267a08eb6ba732c2ebc378d9776c9b33a51329646b91168e38ea0327ba0c368825  exim.Makefile
+c701905785074e9d3ec30c56c68f21789559735d15c6ac7dcf0366cc26d14fc8e68a4e4639d006a463a39da4ecf1ad40a1b159ab551083c649e6fb2ef6ed0f8e  exim.confd
+3c2122bd856595ec128db62538a4ca8fcea95a42078c79eadb5859b4191b23a0f24926c00ba4b6a8f507878701d8c6c03a4c9f85a1c226e490c487dbd351c168  exim.initd
 28e748693a6a72d9943fa9c342ff041fe650fa6977f468dee127e845e6c2a91872ce33fb6f5698838906bde3ed92de7a91cdb0349cedc40b806261867e8c06cb  exim.logrotate
 abdaf749ed3947a75b997caa300bf9f27ef82760f1854aa4521a9ac0f322f1655b65a375bc7a709259daea88bf93cfab5289997fa8e376fac9a3477f09bab642  exim.gencert"
diff --git a/testing/exim/exim.Makefile b/testing/exim/exim.Makefile
index c372d73016..2e2a8dadce 100644
--- a/testing/exim/exim.Makefile
+++ b/testing/exim/exim.Makefile
@@ -18,17 +18,19 @@ SUPPORT_MAILDIR=yes
 LOOKUP_MODULE_DIR=/usr/lib/exim/
 CFLAGS_DYNAMIC=-shared -rdynamic -fPIC
 LOOKUP_DBM=2
-LOOKUP_LSEARCH=yes
-LOOKUP_DSEARCH=yes
+LOOKUP_LSEARCH=2
+LOOKUP_DSEARCH=2
 LOOKUP_CDB=2
 LOOKUP_DNSDB=2
-LOOKUP_PASSWD=yes
+LOOKUP_PASSWD=2
 LOOKUP_MYSQL=2
 LOOKUP_MYSQL_INCLUDE=-I/usr/include/mysql
 LOOKUP_MYSQL_LIBS=-Wl,--no-as-needed -lmysqlclient
 LOOKUP_PGSQL=2
 LOOKUP_PGSQL_INCLUDE=-I/usr/include/postgresql
 LOOKUP_PGSQL_LIBS=-Wl,--no-as-needed -lpq
+LOOKUP_REDIS=2
+LOOKUP_REDIS_LIBS=-Wl,--no-as-needed -lhiredis
 LOOKUP_SQLITE=2
 LOOKUP_SQLITE_LIBS=-Wl,--no-as-needed -lsqlite3
 PCRE_CONFIG=yes
diff --git a/testing/exim/exim.confd b/testing/exim/exim.confd
index 316674f26b..5e0571c317 100644
--- a/testing/exim/exim.confd
+++ b/testing/exim/exim.confd
@@ -1,8 +1,8 @@
 # Command-line options for running exim
-#command_args="-bd -q15m"
+#EXIM_ARGS="-q15m"
 
 # Where to log startup configuration checking
 # - /dev/null - silent (default)
 # - /dev/tty - show output on curent terminal
 # - /path/filename - append to specified logfile
-#startuplog=/var/log/exim/startup.log
+#EXIM_STARTUPLOG=/var/log/exim/startup.log
diff --git a/testing/exim/exim.initd b/testing/exim/exim.initd
index 102dcb4963..741b40f995 100644
--- a/testing/exim/exim.initd
+++ b/testing/exim/exim.initd
@@ -4,24 +4,30 @@ description="EXIM internet mailer"
 cfgfile=/etc/exim/exim.conf
 pidfile=/run/exim.pid
 command=/usr/sbin/exim
-command_args=${command_args:--bd -q15m}
+command_args="-bd ${EXIM_ARGS:--q15m}"
 required_files="$cfgfile"
+extra_commands="checkconfig"
 extra_started_commands="reload"
 description_reload="Reload configuration"
+description_checkconfig="Verify configuration"
 
 depend() {
 	use antivirus net
 	provide mta
 }
 
-start_pre() {
-	ebegin
-	$command -bV >/dev/null 2>>${startuplog:-/dev/null}
+checkconfig() {
+	ebegin "Checking $RC_SVCNAME config"
+	$command -bV
 	eend $?
 }
 
+start_pre() {
+	checkconfig >/dev/null 2>>${EXIM_STARTUPLOG:-/dev/null}
+}
+
 reload() {
 	ebegin "Reloading $RC_SVCNAME"
-	start-stop-daemon --signal HUP --pidfile $pidfile
+	checkconfig >/dev/null 2>&1 && start-stop-daemon --signal HUP --pidfile $pidfile
 	eend $?
 }
-- 
2.11.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Leonardo Arena <[email-masked]>
Date: Tue, 14 Mar 2017 12:11:34 +0100

Hi!

>   and make it provides its old exim-$backend subpackages name.

I don't get why it was needed to rename. How other distros naming it?
Other MTAs packages like postfix use $pkgname-$backend. Am I missing
something?

> 	  - exim package now depends on exim-server, minimal set of

If the server needs lsearch, dsearch, passwd modules to run, what is
the benefit of making subpackages? Is there a usage case where you need
only the lookup tools, perhaps with the utils? I see that exim-utils
pulls in the server package anyway.

Thanks!

|_eo

---

From: Valery Kartel <[email-masked]>
Date: Tue, 14 Mar 2017 13:32:20 +0200

Hi,

I suggest this renaming because these subpackages are just lookup-backends
(not scripts, utils etc...)

lsearch, dsearch, passwd - are file-based lookups. If I use sql database as
storage I don't need those lookups at all.
So I propose this ability as an option (install exim-server instead of exim)

Other distros usually have a monolitic exim package.
A quick search in ubuntu I see exim4-base, exim4-config, and 2 varians of
install: exim4-light & exim4-heavy

---

From: Leonardo Arena <[email-masked]>
Date: Thu, 23 Mar 2017 16:36:56 +0100

Hi,

On 14/03/2017 12:32, Valery Kartel wrote:
> Hi,
> 
> I suggest this renaming because these subpackages are just
> lookup-backends (not scripts, utils etc...)
> 

Yes, but also postfix has the same subpackages for the same purpose and
they aren't prefixed by "lookup". I'd just keep naming $pkgname-$backend.

> lsearch, dsearch, passwd - are file-based lookups. If I use sql database
> as storage I don't need those lookups at all.

This sounds good.

Thanks!

|_eo

---

From: Valery Kartel <[email-masked]>
Date: Fri, 24 Mar 2017 11:33:25 +0200

Hi,

> they aren't prefixed by "lookup". I'd just keep naming $pkgname-$backend.

It's a postfix's internal problem :)

All those lookup_backends provides their legacy names.

$ apk search exim-lsearch exim-redis

exim-lookup_redis-4.89-r0
exim-lookup_lsearch-4.89-r0

And with this naming we have an easy way to view what lookups exim support

$apk search exim-lookup

exim-lookup_pgsql-4.89-r0
exim-lookup_cdb-4.89-r0
exim-lookup_dnsdb-4.89-r0
exim-lookup_passwd-4.89-r0
exim-lookup_lsearch-4.89-r0
exim-lookup_redis-4.89-r0
exim-lookup_dsearch-4.89-r0
exim-lookup_dbmdb-4.89-r0
exim-lookup_sqlite-4.89-r0
exim-lookup_mysql-4.89-r0