Subject: [alpine-aports] [PATCH] main/clamav: upgrade to 0.99. Minor fixes in APKBUILD, init and logrotate scripts (second release)

From: Valery Kartel <[email-masked]>
Date: Mon, 7 Dec 2015 18:32:08 +0200

---
 main/clamav/APKBUILD            | 48 +++++++++++++++++++-------------------
 main/clamav/clamd.initd         | 51 ++++++++++++++++++-----------------------
 main/clamav/clamd.logrotate     | 11 ++++-----
 main/clamav/freshclam.initd     | 30 ++++++++++++------------
 main/clamav/freshclam.logrotate | 10 ++++----
 5 files changed, 70 insertions(+), 80 deletions(-)

diff --git a/main/clamav/APKBUILD b/main/clamav/APKBUILD
index 1a9511c..9f34500 100644
--- a/main/clamav/APKBUILD
+++ b/main/clamav/APKBUILD
@@ -1,9 +1,10 @@
+# Contributor: Valery Kartel <[email-masked]>
 # Contributor: Łukasz Jendrysik <[email-masked]>
 # Contributor: Carlo Landmeter <[email-masked]>
 # Maintainer: Carlo Landmeter <[email-masked]>
 pkgname=clamav
-pkgver=0.98.7
-pkgrel=2
+pkgver=0.99
+pkgrel=0
 pkgusers="clamav"
 pkggroups="clamav"
 pkgdesc="An anti-virus toolkit for UNIX"
@@ -14,7 +15,7 @@ depends="$pkgname-scanner $pkgname-daemon"
 depends_dev="openssl-dev"
 install="freshclam.pre-install
 	clamav-daemon.pre-install clamav-daemon.pre-upgrade"
-makedepends="ncurses-dev zlib-dev bzip2-dev linux-headers $depends_dev"
+makedepends="ncurses-dev zlib-dev bzip2-dev linux-headers $depends_dev fts-dev"
 subpackages="$pkgname-doc $pkgname-dev $pkgname-lib $pkgname-libunrar
 	$pkgname-daemon $pkgname-scanner $pkgname-db freshclam"
 source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
@@ -42,7 +43,7 @@ prepare() {
 
 build() {
 	cd "$_builddir"
-	./configure \
+	LIBS=-lfts ./configure \
 		--build=$CBUILD \
 		--host=$CHOST \
 		--prefix=/usr \
@@ -67,7 +68,7 @@ package() {
 
 	# set proper defaults
 	sed -i -e "s:^\(Example\):\# \1:" \
-                -e "s:.*\(PidFile\) .*:\1 /var/run/clamav/freshclam.pid:" \
+                -e "s:.*\(PidFile\) .*:\1 /run/clamav/freshclam.pid:" \
                 -e "s:.*\(DatabaseOwner\) .*:\1 clamav:" \
                 -e "s:^\#\(UpdateLogFile\) .*:\1 /var/log/clamav/freshclam.log:" \
                 -e "s:^\#\(NotifyClamd\).*:\1 /etc/clamav/clamd.conf:" \
@@ -77,8 +78,8 @@ package() {
 
 	# set proper defaults
         sed -i -e "s:^\(Example\):\# \1:" \
-                -e "s:.*\(PidFile\) .*:\1 /var/run/clamav/clamd.pid:" \
-                -e "s:.*\(LocalSocket\) .*:\1 /var/run/clamav/clamd.sock:" \
+                -e "s:.*\(PidFile\) .*:\1 /run/clamav/clamd.pid:" \
+                -e "s:.*\(LocalSocket\) .*:\1 /run/clamav/clamd.sock:" \
                 -e "s:.*\(User\) .*:\1 clamav:" \
                 -e "s:^\#\(LogFile\) .*:\1 /var/log/clamav/clamd.log:" \
                 -e "s:^\#\(LogTime\).*:\1 yes:" \
@@ -117,7 +118,6 @@ freshclam() {
         mv "$pkgdir"/etc/clamav/freshclam.conf.sample \
 		"$subpkgdir"/etc/clamav/ || return 1
 	install -d -m755 -o clamav -g clamav \
-                "$subpkgdir"/var/run/clamav \
 		"$subpkgdir"/var/log/clamav \
 		"$subpkgdir"/var/lib/clamav || return 1
 
@@ -138,7 +138,6 @@ db() {
 		"$subpkgdir"/etc/clamav \
 		|| return 1
 	install -d -m755 -o clamav -g clamav \
-                "$subpkgdir"/var/run/clamav \
 		"$subpkgdir"/var/log/clamav \
 		"$subpkgdir"/var/lib/clamav || return 1
 }
@@ -165,7 +164,6 @@ daemon() {
 		"$subpkgdir"/etc/clamav \
 		|| return 1
 	install -d -m 755 -o clamav -g clamav \
-                "$subpkgdir"/var/run/clamav \
 		"$subpkgdir"/var/log/clamav \
 		"$subpkgdir"/var/lib/clamav
 	mv "$pkgdir"/usr/bin/clamconf \
@@ -186,24 +184,24 @@ daemon() {
 		"$pkgdir"/etc/logrotate.d/clamd || return 1
 }
 
-md5sums="157c601161da1c2d5a0e48ea1b49e067  clamav-0.98.7.tar.gz
-64ca44466837bcd69f28e01f6c96e2a9  clamd.initd
+md5sums="ae79c3982761ba1815dbce17f846bab6  clamav-0.99.tar.gz
+191b7b6b29eaef0af9f745e331058618  clamd.initd
 e8a03fad6ce603631e8fe71a24d387c6  clamd.confd
-d29c888953097041f27b2dbc21b6e94c  freshclam.initd
+6c79b77c35ce35ba3846b5a4f363a1d4  freshclam.initd
 e48466ddfb56f66c623b83e58777b778  freshclam.confd
-ae1e48ab56a0fff1acdde023c1f6f350  clamd.logrotate
-226824214c021b2366f0be1289561d17  freshclam.logrotate"
-sha256sums="282417b707740de13cd8f18d4cbca9ddd181cf96b444db2cad98913a5153e272  clamav-0.98.7.tar.gz
-500fc4e6ec43f7a87cf159b0c56ca594f0a3f855ab6c80f7aa91315dcc4da941  clamd.initd
+2fb0399fbad82ab17c1c04f2d331214a  clamd.logrotate
+56e88ff24d3490af599e34e6f3346d5b  freshclam.logrotate"
+sha256sums="d2792c8cfadd685fffc40b2199679628815df031fd3149ccf961649fc8787ea9  clamav-0.99.tar.gz
+0ac8e153aea4422c82956e083358a83b9c77a6400e5bafbfcec2ddb97eb3e733  clamd.initd
 4d978313004f66d871564b873df27c5459d3cc504788b179e41edba0f04b74dc  clamd.confd
-cf945febd186528798df2e5567e108d1bcf3618c74615d8c5edee3cfad756c9c  freshclam.initd
+4ba12be50d010269bcd170c1d14a91e6ddcfe85df3f5cbf68803e6e75a420bb5  freshclam.initd
 75551ce7e04bbef4a889bc94a357b160d9da88f06eba32df594ba3cbb2c81ed1  freshclam.confd
-ec5e60f7efca02ed151f625e9a44404346991ed6608c6e2088db2436bbd03d49  clamd.logrotate
-84006ac3d2e8dc2e13a01f5e313c20e4978cdc93d831c181e0075badcbf4ada0  freshclam.logrotate"
-sha512sums="acf01961472c13ccb219420cc3fa3c3e6f8a733edef371dbc04ce5867900aa1535e956ec8ad50d31c8f872a0a1d79fcccac944cd86e29ecdfa4af18f7fd5afb9  clamav-0.98.7.tar.gz
-9abb547591170ab07da6238a47db00bfa8eb0f962e430e9e701ff12542b81d02b86092edc0fe49aa9cfbb263cdd62db8f55d255cf1625f8532da2deee79ccc42  clamd.initd
+2fee72877bc1fdc788b298319479de9495db85bdae4433143ce83a450a09dae3  clamd.logrotate
+5127ebd370d8c62f3558c9605b4f33f7fb54bac3acf7831dc5f8c4dda1509dfa  freshclam.logrotate"
+sha512sums="328e66fa412ba61f5e44c839b254c7a84d2ce7821fda6cf29e4ee9532c06e45bdec62f202ca561223e984fff170bfd8280e5cc8e306c09a3017b17e7db3bbf56  clamav-0.99.tar.gz
+c3e1c9efe8744ec96627ea7fe8d54e1c07a45da40907e774ee664d9880bb8e77a98902fb831171acb2b5df2bf797ce712b3b68a17c35657ad86826add7177e35  clamd.initd
 59c561b3dcb0b616b647cd8e4ebc46a2cc5e7144c8c7ea0054cc1c3021d1da8f67e4dad5c083c3fe712ed887aaabfca91b538f4759537e7c4c9ab71ba4fd5794  clamd.confd
-7371e12ce6efa33684ac90a03c244b2cf626322ac8fc1e9fa8ca67a9353badea3f3eb0b3d966e286519956f94d1b5752b3d03aabb901105270010eadb0aedf72  freshclam.initd
+00daed8afb67a6e4a29893340246c8840cce970dd9103d26557ecdd26ef60b12551d2291c214fc657faaaa339484052079347411b0cad65e3a33ece56d57cf16  freshclam.initd
 ba181fe1abaac7b898ccb40b0713455aa3c9d5e25ad21d687b6cac09b0105b9e376526e7c776a44636234d8db819709d8d6a6cc76119bc3e98b637b1a3f26c08  freshclam.confd
-57e5b0c0dc6dc078e0102829e5d36882cff9ae5dd0637c31c7a23ef274dd0a4d967bc036f74c42b4690af511bc0a43fdb6d19b0c307506432577d82de7beff78  clamd.logrotate
-f1cd8df6d47824009a6df130bd60bf5e9f9deaef87fbeaceec8fe71e6c8b2772b5dba017390a2190deee851723256f06e9aef2182b0a2881119f22ba68740554  freshclam.logrotate"
+3ae493dd1610a819402c015f6b8c0f080f926b72dc43d2bded60030bf6a55040e4b88e0f64d3aae299dc1133d7e1b89855e7346b4665a64e8b82592f7b75cf6a  clamd.logrotate
+30cff378bc28c76b795e00c92ae5ee623f3abe4a19bed61dd8403c96e72658bb02b7f040d26a6258104af754464d25ea7d9646918c4b47d2ba9a8cbf4687056c  freshclam.logrotate"
diff --git a/main/clamav/clamd.initd b/main/clamav/clamd.initd
index 37e29ec..35e6aaf 100755
--- a/main/clamav/clamd.initd
+++ b/main/clamav/clamd.initd
@@ -1,22 +1,37 @@
 #!/sbin/openrc-run
 
-extra_started_commands="reload"
-extra_commands="logfix"
-
 NAME=clamd
 CONF=/etc/clamav/clamd.conf
 
+pidfile=/run/clamav/clamd.pid
+command=/usr/sbin/clamd
+extra_started_commands="reload"
+extra_commands="logfix"
+required_files=$CONF
+
 depend() {
 	need net
 	after firewall
 	provide antivirus
 }
 
+start_pre() {
+	# fix clamd run permissions
+	local pid=`awk '$1 == "PidFile" { print $2 }' $CONF`
+	[ "x$pid" != "x" ] && pidfile=$pid
+	local socket=`awk '$1 == "LocalSocket" { print $2 }' $CONF`
+	local socketdir=${socket%/*}
+	local clamav_user=`awk '$1 == "User" { print $2 }' $CONF`
+	checkpath --directory --owner -m 750 ${clamav_user:-clamav} \
+		${pidfile%/*}
+	checkpath --directory --owner -m 750 ${clamav_user:-clamav} \
+		${socketdir:-/run/clamav}
+}
+
 start() {
 	local clamd_socket=$(awk '$1 == "LocalSocket" { print $2 }' $CONF)
 
 	logfix
-	socketfix
 
 	if [ -S "${clamd_socket:=/tmp/clamd}" ]; then
 		rm -f ${clamd_socket}
@@ -44,24 +59,13 @@ start() {
 	ebegin "Starting ${NAME}"
 	start-stop-daemon --start --quiet \
 		--nicelevel ${CLAMD_NICELEVEL:-0} \
-		--exec /usr/sbin/clamd
+		--exec $command
 	eend $? "Failed to start ${NAME}"
 }
 
-stop() {
-	ebegin "Stopping ${NAME}"
-	start-stop-daemon --stop --quiet --exec /usr/sbin/clamd
-	eend $?
-}
-
 reload() {
-	ebegin "Reloading ${NAME}"
-	if ! service_started "${NAME}" ; then
-		eend 1 "${NAME} is not started"
-		return 1
-	fi
-	start-stop-daemon --stop --signal HUP \
-		--exec /usr/sbin/clamd
+	ebegin "Reloading ${SVCNAME}"
+	start-stop-daemon --signal HUP --pidfile $pidfile --name $SVCNAME
 	eend $?
 }
 
@@ -78,14 +82,3 @@ logfix() {
 		chmod 640 ${logfile}
 	fi
 }
-
-socketfix() {                                                                
-        # fix clamd run permissions                     
-        local socket=`awk '$1 == "LocalSocket" { print $2 }' $CONF`
-	local socketdir=${socket%/*}
-        local clamav_user=`awk '$1 == "User" { print $2 }' $CONF`
-	checkpath --directory --owner ${clamav_user:-clamav} \
-		${socketdir:-/var/run/clamav}
-}                                                     
-
-
diff --git a/main/clamav/clamd.logrotate b/main/clamav/clamd.logrotate
index 3d7fc79..dc0f5ca 100644
--- a/main/clamav/clamd.logrotate
+++ b/main/clamav/clamd.logrotate
@@ -1,8 +1,7 @@
 /var/log/clamav/clamd.log {
-        missingok
-        postrotate
-                /etc/init.d/clamd logfix
-                /bin/kill -HUP `cat /var/run/clamav/clamd.pid 2> /dev/null` 2>/dev/null || true
-        endscript
+	missingok
+	postrotate
+		/etc/init.d/clamd --quiet logfix
+		/etc/init.d/clamd --quiet --ifstarted reload
+	endscript
 }
-
diff --git a/main/clamav/freshclam.initd b/main/clamav/freshclam.initd
index 4b71fbf..279b529 100644
--- a/main/clamav/freshclam.initd
+++ b/main/clamav/freshclam.initd
@@ -1,17 +1,26 @@
 #!/sbin/openrc-run
 
-extra_started_commands="reload"
-extra_commands="logfix"
+CONF=/etc/clamav/freshclam.conf
 
+pidfile=/run/clamav/freshclam.pid
 command=/usr/bin/freshclam
-pidfile=/var/run/clamav/freshclam.pid
-CONF=/etc/clamav/freshclam.conf
+extra_started_commands="reload"
+extra_commands="logfix"
+required_files=$CONF
 
 depend() {
 	need net
 	after firewall
 }
 
+start_pre() {
+	local pid=`awk '$1 == "PidFile" { print $2 }' $CONF`
+	local owner=`awk '$1 == "DatabaseOwner" { print $2 }' $CONF`
+	[ "x$pid" != "x" ] && pidfile=$pid
+	checkpath --directory --owner ${owner:-clamav} \
+		--mode 750 ${pidfile%/*}
+}
+
 start() {
 	ebegin "Starting freshclam"
 	start-stop-daemon --start --quiet \
@@ -23,20 +32,12 @@ start() {
 	eend $?
 }
 
-stop() {
-	ebegin "Stopping freshclam"
-	start-stop-daemon --stop --quiet --pidfile $pidfile
-	eend $?
-}
-
 reload() {
-	ebegin "Reloading freshclam"
-	start-stop-daemon --stop --signal HUP \
-		--exec $command --pidfile $pidfile
+	ebegin "Reloading ${SVCNAME}"
+	start-stop-daemon --signal HUP --pidfile $pidfile --name $SVCNAME
 	eend $?
 }
 
-
 logfix() {
 	# fix freshclam log permissions
 	# (might be clobbered by logrotate or something)
@@ -50,4 +51,3 @@ logfix() {
 		chmod 640 ${logfile}
 	fi
 }
-
diff --git a/main/clamav/freshclam.logrotate b/main/clamav/freshclam.logrotate
index df42d60..18117ee 100644
--- a/main/clamav/freshclam.logrotate
+++ b/main/clamav/freshclam.logrotate
@@ -1,7 +1,7 @@
 /var/log/clamav/freshclam.log {
-        missingok
-        postrotate
-                /etc/init.d/freshclam logfix
-                /bin/kill -HUP `cat /var/run/clamav/freshclam.pid 2> /dev/null` 2>/dev/null || true
-        endscript
+	missingok
+	postrotate
+		/etc/init.d/freshclam --quiet logfix
+		/etc/init.d/freshclam --quiet --ifstarted reload
+	endscript
 }
-- 
2.6.3

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