Subject: [alpine-aports] [PATCH] testing/exim: add rspamd local_scan support, cleanups in init and pre-install scripts

From: Valery Kartel <[email-masked]>
Date: Thu, 21 Jan 2016 20:17:16 +0200

---
 testing/exim/APKBUILD         | 39 +++++++++++++++++++++++----------------
 testing/exim/exim.Makefile    |  2 ++
 testing/exim/exim.confd       |  8 +++++++-
 testing/exim/exim.initd       | 20 ++++++++++++++------
 testing/exim/exim.pre-install |  4 ++--
 5 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/testing/exim/APKBUILD b/testing/exim/APKBUILD
index ff9dafc..d8aeb19 100644
--- a/testing/exim/APKBUILD
+++ b/testing/exim/APKBUILD
@@ -4,7 +4,7 @@
 # Maintainer: Jesse Young <[email-masked]>
 pkgname=exim
 pkgver=4.86
-pkgrel=2
+pkgrel=3
 pkgdesc="A Message Transfer Agent"
 url="http://www.exim.org/"
 arch="all"
@@ -14,7 +14,7 @@ depends=
 pkgusers="exim"
 pkggroups="exim"
 depends_dev=""
-makedepends="bash gawk perl $depends_dev db-dev pcre-dev openssl-dev libspf2-dev mariadb-dev postgresql-dev sqlite-dev libidn-dev"
+makedepends="bash gawk perl $depends_dev db-dev pcre-dev openssl-dev libspf2-dev mariadb-dev postgresql-dev sqlite-dev libidn-dev rspamd-contrib"
 install="exim.pre-install exim.post-upgrade"
 subpackages="$pkgname-cdb $pkgname-dbmdb $pkgname-dnsdb $pkgname-sqlite $pkgname-mysql $pkgname-postgresql $pkgname-utils $pkgname-scripts $pkgname-doc"
 source="ftp://ftp.exim.org/pub/exim/exim4/$pkgname-$pkgver.tar.bz2
@@ -31,6 +31,7 @@ prepare() {
 	sed	-e 's/^LIBS = -lnsl/LIBS =/g' \
 		-e 's/^HAVE_ICONV=yes/#HAVE_ICONV=yes/' \
 		-i OS/Makefile-Linux
+	cp /usr/share/rspamd/contrib/exim/local_scan.c Local
 }
 
 build() {
@@ -50,11 +51,17 @@ package() {
 	for i in mailq rmail rsmtp runq sendmail newaliases; do
 		ln -s exim $i
 	done
-	install -m644 -D "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
-	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
-	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
-	install -m750 -D -g exim -d "$pkgdir"/usr/lib/exim
-	install -m750 -D -o exim -d "$pkgdir"/var/log/exim
+	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
+	install -Dm750 -g $pkggroups -d "$pkgdir"/usr/lib/$pkgname
+	install -Dm750 -o $pkgusers -d "$pkgdir"/var/log/$pkgname
+	install -Dm750 -o $pkgusers -g mail -d "$pkgdir"/var/spool/$pkgname
+	# Add rspamd local_scan config to exim.conf
+	sed -i '/# begin local_scan/q' "$pkgdir"/etc/$pkgname/$pkgname.conf > /dev/null
+	sed 's/^.*\*     /#/' < /usr/share/rspamd/contrib/exim/local_scan.c.in \
+		| sed -n 25,30p >> "$pkgdir"/etc/$pkgname/$pkgname.conf
+	echo -e "\n# End of Exim configuration file" >> "$pkgdir"/etc/$pkgname/$pkgname.conf
 }
 
 scripts() {
@@ -118,17 +125,17 @@ _inst_lookup() {
 	install -D -m755 "$_builddir"/build-Linux-*/lookups/$1.so "$subpkgdir"/usr/lib/exim/$1.so
 }
 md5sums="797f248ef3e0c0e2f178e915f88fc4e9  exim-4.86.tar.bz2
-85348d0fed6b35f5c0b4241023269a19  exim.Makefile
-7fac36b4683fe9e2bd1969ebfded4206  exim.confd
-7145f5f92ee5cea37b90576e61195cb1  exim.initd
+26c4da6ee7dc8ee9badce4e395d1c469  exim.Makefile
+186f4491800be8c56ce39320f24d7264  exim.confd
+871a2839c3814412a820b79095cc2a4d  exim.initd
 2eff3af519bdf8acf0292fffe89871a5  exim.logrotate"
 sha256sums="f1ccf2ce2ea51b7fbbf160e7e0e41d24ca401cf44a185128ad99ea04635fc456  exim-4.86.tar.bz2
-9afac834b73fe6cdf3b45efdb89428a790e2a2b68bdbaafecd8d9fcfbe2ef35d  exim.Makefile
-02ccb013b3f29183969dceb2dc1285cfacc18b1e8a8a052ace7bc85171ea1a27  exim.confd
-4872b9bb29ee3cf06e71ef0e3c703279ab8ef46f72153b61fb9ce93fcb63a3fd  exim.initd
+cc58c4f79052f264c14abe0886605115570ece5e759242c7deca9cf84585e06d  exim.Makefile
+db711754c48dfb7e3810009a1c6ffa331625c9d74d00dc8fa8256d9fa2c353f0  exim.confd
+6dbdf67ab4dc82142c46901ed7ceed5fca09af037071630809929e1fb545b89e  exim.initd
 b5a6d449cb1998beb44d4144ef97e66a98b46d164445989a6d624c80549f24bc  exim.logrotate"
 sha512sums="0b90cd1b4d99bbb976336ccf9c2c3375f453a74bb306f1b0215f7ecca80fbda83cf5cc38c502516c2903c5d753f1f559c534fc4f4b1b32ee3300db86de6610ab  exim-4.86.tar.bz2
-0a3d5908f397c34c21e8a82c8d5d5e02644f30e7323f1da7acce2ebe74918da5eefe04945a5a0f3edf21881d04d1bf1e470e6bac5b6de930a6b82a4e012ce7a5  exim.Makefile
-dfc5e5e266c8a249728c7924f66223eadadf69e38b7ad3ae41197fcdb545a4c3a835939941dff41a948f7e26cbab9d5f1a8c412d27b87a0596c0f9d4f0e43eec  exim.confd
-0be62b48d5df089bd28445e6a679d40bf303baccb94b9f94a89df455996973a897dc2506b15272658a3e828fb274a64d5368988ba6d604388153fd1339fa3138  exim.initd
+852593762e87ab2aad825d69d9a40dfb1e0b16c6f94ae25f8f72f90e4a459cd75e2c6d53dc354645cc433591b86508cd91a2272e409950af5cdc1bdacf65d16d  exim.Makefile
+bb6f5ead067af19ace661cc92bcd428da97570aedd1f9dc5b61a34e7e3fb3e028be6c96d51df73353bdfcaf69a3ee053fb03d245f868d63ebf518aa96ec82d66  exim.confd
+cd7a27922d6cce59cf2dbedaab6f90159614cd6566b5d7ff7e232acf76a42b697709bb85981ffa88b60a7ee326bb88f1892f2405495ca228b4ec025885e65ed6  exim.initd
 28e748693a6a72d9943fa9c342ff041fe650fa6977f468dee127e845e6c2a91872ce33fb6f5698838906bde3ed92de7a91cdb0349cedc40b806261867e8c06cb  exim.logrotate"
diff --git a/testing/exim/exim.Makefile b/testing/exim/exim.Makefile
index 68d21d8..40a9ed4 100644
--- a/testing/exim/exim.Makefile
+++ b/testing/exim/exim.Makefile
@@ -70,3 +70,5 @@ HAVE_IPV6=YES
 CONFIGURE_FILE_USE_NODE=yes
 CONFIGURE_FILE_USE_EUID=yes
 SUPPORT_MOVE_FROZEN_MESSAGES=yes
+LOCAL_SCAN_SOURCE=Local/local_scan.c
+LOCAL_SCAN_HAS_OPTIONS=yes
diff --git a/testing/exim/exim.confd b/testing/exim/exim.confd
index 692d44a..316674f 100644
--- a/testing/exim/exim.confd
+++ b/testing/exim/exim.confd
@@ -1,2 +1,8 @@
 # Command-line options for running exim
-#EXIM_OPTS="-bd -q15m"
+#command_args="-bd -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
diff --git a/testing/exim/exim.initd b/testing/exim/exim.initd
index ef0ddc5..fd0d9bd 100644
--- a/testing/exim/exim.initd
+++ b/testing/exim/exim.initd
@@ -1,19 +1,27 @@
 #!/sbin/openrc-run
 
-pidfile="/run/exim.pid"
-command="/usr/sbin/exim"
-command_args="${EXIM_OPTS:--bd -q15m}"
-required_files="/etc/exim/exim.conf"
+description="EXIM internet mailer"
+cfgfile=/etc/exim/exim.conf
+pidfile=/run/exim.pid
+command=/usr/sbin/exim
+command_args=${command_args:--bd -q15m}
+required_files="$cfgfile"
 extra_started_commands="reload"
+description_reload="Reload configuration"
 
 depend() {
-	need logger
 	use antivirus net
 	provide mta
 }
 
+start_pre() {
+	ebegin
+	$command -bV >/dev/null 2>>${startuplog:-/dev/null}
+	eend $?
+}
+
 reload() {
 	ebegin "Reloading ${SVCNAME}"
-	start-stop-daemon --signal HUP --pidfile ${pidfile} --name ${SVCNAME}
+	start-stop-daemon --signal HUP --pidfile $pidfile
 	eend $?
 }
diff --git a/testing/exim/exim.pre-install b/testing/exim/exim.pre-install
index 9edcbc8..7a4cada 100644
--- a/testing/exim/exim.pre-install
+++ b/testing/exim/exim.pre-install
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 addgroup -S exim 2>/dev/null
-adduser  -H -S -u 43 -h /var/spool/exim -s /sbin/nologin -g Exim -G exim -D exim 2>/dev/null
-addgroup exim mail 2>/dev/null
+adduser -h /var/spool/exim -g "exim" -s /bin/false -SDHG exim exim 2>/dev/null
+adduser exim mail 2>/dev/null
 
 exit 0
-- 
2.7.0

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