aboutsummaryrefslogtreecommitdiffstats
path: root/main/clamav
diff options
context:
space:
mode:
authorFabian Affolter <fabian@bernewireless.net>2011-07-05 19:40:43 +0200
committerFabian Affolter <fabian@bernewireless.net>2011-07-05 19:40:43 +0200
commit7f9851115264bca9bce3926ddb29e533a23929dd (patch)
treeb0426fc489e4dad582f34b25d6f93354a65f5c0f /main/clamav
parent5dac3f219058736f6e19b7bec2b1cc2b1b300981 (diff)
parent269fc1049583d36e07153215fe535f88947ea98b (diff)
downloadaports-7f9851115264bca9bce3926ddb29e533a23929dd.tar.bz2
aports-7f9851115264bca9bce3926ddb29e533a23929dd.tar.xz
Merge branch 'master' of git://git.alpinelinux.org/aports
Diffstat (limited to 'main/clamav')
-rw-r--r--main/clamav/APKBUILD158
-rw-r--r--main/clamav/clamav-0.95.1-nls.patch11
-rw-r--r--main/clamav/clamav-daemon.post-install3
-rw-r--r--main/clamav/clamav-daemon.pre-install4
-rw-r--r--main/clamav/clamav-daemon.pre-upgrade11
-rw-r--r--main/clamav/clamav-db.post-install3
-rw-r--r--main/clamav/clamav-db.pre-install4
-rw-r--r--main/clamav/clamav-db.pre-upgrade11
-rw-r--r--main/clamav/clamd.confd6
-rw-r--r--main/clamav/clamd.initd57
-rw-r--r--main/clamav/clamd.logrotate8
-rw-r--r--main/clamav/freshclam.confd3
-rw-r--r--main/clamav/freshclam.initd59
-rw-r--r--main/clamav/freshclam.logrotate7
14 files changed, 345 insertions, 0 deletions
diff --git a/main/clamav/APKBUILD b/main/clamav/APKBUILD
new file mode 100644
index 0000000000..22fcda7f9c
--- /dev/null
+++ b/main/clamav/APKBUILD
@@ -0,0 +1,158 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=clamav
+pkgver=0.97
+pkgrel=4
+pkgusers=clamav
+pkggroups=clamav
+pkgdesc="An anti-virus toolkit for UNIX"
+url="http://www.clamav.net/"
+arch="all"
+license="GPL"
+depends="$pkgname-scanner $pkgname-daemon"
+install=""
+makedepends="ncurses-dev zlib-dev"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-lib $pkgname-libunrar
+ $pkgname-daemon $pkgname-scanner $pkgname-db"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+ clamd.initd
+ clamd.confd
+ freshclam.initd
+ freshclam.confd
+ clamav-0.95.1-nls.patch
+ clamd.logrotate
+ freshclam.logrotate
+ "
+
+_builddir="$srcdir/$pkgname-$pkgver"
+
+prepare() {
+ cd "$_builddir"
+ patch -p0 -i "$srcdir/clamav-0.95.1-nls.patch" || return 1
+}
+
+build() {
+ cd "$_builddir"
+ ./configure --prefix=/usr \
+ --libdir=/usr/lib \
+ --sysconfdir=/etc/clamav \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --without-iconv \
+ --disable-llvm \
+ --with-dbdir=/var/lib/clamav \
+ --enable-clamdtop
+ make || return 1
+}
+
+package() {
+ cd "$_builddir"
+ make DESTDIR="$pkgdir" install || return 1
+ rm "$pkgdir"/usr/lib/*.la || return 1
+}
+
+lib() {
+ pkgdesc="ClamAV library"
+ depends=""
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libclamav.so.* \
+ "$subpkgdir"/usr/lib/
+}
+
+libunrar() {
+ pkgdesc="ClamAV unrar libraries"
+ depends=""
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libclamunrar* \
+ "$subpkgdir"/usr/lib/
+}
+
+db() {
+ pkgdesc="ClamAV virus database and update program"
+ depends="logrotate"
+ install="$subpkgname.pre-install $subpkgname.post-install $subpkgname.pre-upgrade"
+ mkdir -p "$subpkgdir"/var/lib/ \
+ "$subpkgdir"/usr/bin \
+ "$subpkgdir"/etc/clamav \
+ "$subpkgdir"/var/run/clamav \
+ "$subpkgdir"/var/log/clamav
+ mv "$pkgdir"/var/lib/clamav \
+ "$subpkgdir"/var/lib/ || return 1
+ mv "$pkgdir"/usr/bin/freshclam \
+ "$subpkgdir"/usr/bin || return 1
+ install -m755 -D "$srcdir"/freshclam.initd \
+ "$subpkgdir"/etc/init.d/freshclam || return 1
+ install -m644 -D "$srcdir"/freshclam.confd \
+ "$subpkgdir"/etc/conf.d/freshclam || return 1
+ mv "$pkgdir"/etc/clamav/freshclam.conf \
+ "$subpkgdir"/etc/clamav/ || return 1
+ # set proper defaults
+ sed -i -e "s:^\(Example\):\# \1:" \
+ -e "s:.*\(PidFile\) .*:\1 /var/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:" \
+ -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
+ -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
+ "$subpkgdir"/etc/clamav/freshclam.conf
+ install -m644 -D "$srcdir"/freshclam.logrotate \
+ "$subpkgdir"/etc/logrotate.d/freshclam || return 1
+}
+
+scanner() {
+ pkgdesc="ClamAV command-line scanner and utils"
+ depends="$pkgname-db"
+ mkdir -p "$subpkgdir"/usr/bin
+ mv "$pkgdir"/usr/bin/clamscan \
+ "$subpkgdir"/usr/bin/ || return 1
+ mv "$pkgdir"/usr/bin/sigtool \
+ "$subpkgdir"/usr/bin/ || return 1
+ mv "$pkgdir"/usr/bin/clambc \
+ "$subpkgdir"/usr/bin/ || return 1
+
+}
+
+daemon() {
+ pkgdesc="ClamAV daemon scanner"
+ depends="$pkgname-db logrotate"
+ install="$subpkgname.pre-install $subpkgname.post-install $subpkgname.pre-upgrade"
+ mkdir -p "$subpkgdir"/usr/bin \
+ "$subpkgdir"/usr/sbin \
+ "$subpkgdir"/etc/clamav \
+ "$subpkgdir"/var/run/clamav \
+ "$subpkgdir"/var/log/clamav
+ mv "$pkgdir"/usr/bin/clamconf \
+ "$subpkgdir"/usr/bin/ || return 1
+ mv "$pkgdir"/usr/sbin/clamd \
+ "$subpkgdir"/usr/sbin/ || return 1
+ mv "$pkgdir"/usr/bin/clamdtop \
+ "$subpkgdir"/usr/bin/ || return 1
+ mv "$pkgdir"/usr/bin/clamdscan \
+ "$subpkgdir"/usr/bin/ || return 1
+ install -m755 -D "$srcdir"/clamd.initd \
+ "$subpkgdir"/etc/init.d/clamd || return 1
+ install -m644 -D "$srcdir"/clamd.confd \
+ "$subpkgdir"/etc/conf.d/clamd || return 1
+ mv "$pkgdir"/etc/clamav/clamd.conf \
+ "$subpkgdir"/etc/clamav/ || return 1
+ # 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:.*\(User\) .*:\1 clamav:" \
+ -e "s:^\#\(LogFile\) .*:\1 /var/log/clamav/clamd.log:" \
+ -e "s:^\#\(LogTime\).*:\1 yes:" \
+ -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
+ "$subpkgdir"/etc/clamav/clamd.conf
+ install -m644 -D "$srcdir"/clamd.logrotate \
+ "$subpkgdir"/etc/logrotate.d/clamd || return 1
+}
+
+md5sums="605ed132b2f8e89df11064adea2b183b clamav-0.97.tar.gz
+d64432c463850663c5041c3097f3e903 clamd.initd
+567bc32b657dd7031b9b7beaa946203a clamd.confd
+f4d1f415322905128dc27135566ad136 freshclam.initd
+e48466ddfb56f66c623b83e58777b778 freshclam.confd
+0d08fd29656bd4b018ecf8ce9706ac55 clamav-0.95.1-nls.patch
+ae1e48ab56a0fff1acdde023c1f6f350 clamd.logrotate
+226824214c021b2366f0be1289561d17 freshclam.logrotate"
diff --git a/main/clamav/clamav-0.95.1-nls.patch b/main/clamav/clamav-0.95.1-nls.patch
new file mode 100644
index 0000000000..82ae88f576
--- /dev/null
+++ b/main/clamav/clamav-0.95.1-nls.patch
@@ -0,0 +1,11 @@
+--- shared/output.c-orig 2009-04-04 10:17:42 +0000
++++ shared/output.c 2009-04-04 10:18:30 +0000
+@@ -67,7 +67,7 @@
+ pthread_mutex_t logg_mutex = PTHREAD_MUTEX_INITIALIZER;
+ #endif
+
+-#ifdef C_LINUX
++#if defined(C_LINUX) && defined(HAVE_LIBINTL_H)
+ #include <libintl.h>
+ #include <locale.h>
+
diff --git a/main/clamav/clamav-daemon.post-install b/main/clamav/clamav-daemon.post-install
new file mode 100644
index 0000000000..e40badb09b
--- /dev/null
+++ b/main/clamav/clamav-daemon.post-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+chown -R clamav:clamav /var/run/clamav /var/log/clamav
diff --git a/main/clamav/clamav-daemon.pre-install b/main/clamav/clamav-daemon.pre-install
new file mode 100644
index 0000000000..59ac60a44d
--- /dev/null
+++ b/main/clamav/clamav-daemon.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -H -s /bin/false -D clamav 2>/dev/null
+exit 0
diff --git a/main/clamav/clamav-daemon.pre-upgrade b/main/clamav/clamav-daemon.pre-upgrade
new file mode 100644
index 0000000000..c8f82dacd4
--- /dev/null
+++ b/main/clamav/clamav-daemon.pre-upgrade
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# make sure we don't lose our config
+mkdir -p /etc/clamav
+if [ -f /etc/clamav.conf ]; then
+ mv /etc/clamav.conf /etc/clamav/
+ ln -s clamav/clamav.conf /etc/clamav.conf
+fi
+
+exit 0
+
diff --git a/main/clamav/clamav-db.post-install b/main/clamav/clamav-db.post-install
new file mode 100644
index 0000000000..b43342f31a
--- /dev/null
+++ b/main/clamav/clamav-db.post-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+chown -R clamav:clamav /var/lib/clamav /var/run/clamav /var/log/clamav
diff --git a/main/clamav/clamav-db.pre-install b/main/clamav/clamav-db.pre-install
new file mode 100644
index 0000000000..59ac60a44d
--- /dev/null
+++ b/main/clamav/clamav-db.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -H -s /bin/false -D clamav 2>/dev/null
+exit 0
diff --git a/main/clamav/clamav-db.pre-upgrade b/main/clamav/clamav-db.pre-upgrade
new file mode 100644
index 0000000000..47230e16b2
--- /dev/null
+++ b/main/clamav/clamav-db.pre-upgrade
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# make sure we don't lose our config
+mkdir -p /etc/clamav
+if [ -f /etc/freshclam.conf ]; then
+ mv /etc/freshclam.conf /etc/clamav/
+ ln -s clamav/freshclam.conf /etc/freshclam.conf
+fi
+
+exit 0
+
diff --git a/main/clamav/clamd.confd b/main/clamav/clamd.confd
new file mode 100644
index 0000000000..bc8072aead
--- /dev/null
+++ b/main/clamav/clamd.confd
@@ -0,0 +1,6 @@
+
+CLAMD_NICELEVEL=0
+
+# make sure we also start freshclam
+# comment out if you dont want start freshclam
+rc_need="freshclam"
diff --git a/main/clamav/clamd.initd b/main/clamav/clamd.initd
new file mode 100644
index 0000000000..2864267e1e
--- /dev/null
+++ b/main/clamav/clamd.initd
@@ -0,0 +1,57 @@
+#!/sbin/runscript
+
+opts="logfix reload"
+NAME=clamd
+CONF=/etc/clamav/clamd.conf
+
+depend() {
+ need net
+ after firewall
+ provide antivirus
+}
+
+start() {
+ local clamd_socket=$(awk '$1 == "LocalSocket" { print $2 }' $CONF)
+
+ logfix
+
+ if [ -S "${clamd_socket:=/tmp/clamd}" ]; then
+ rm -f ${clamd_socket}
+ fi
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet \
+ --nicelevel ${CLAMD_NICELEVEL:-0} \
+ --exec /usr/sbin/clamd
+ 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 --oknodo --signal HUP \
+ --exec /usr/sbin/clamd
+ eend $?
+}
+
+logfix() {
+ # fix clamd log permissions
+ # (might be clobbered by logrotate or something)
+ local logfile=`awk '$1 == "LogFile" { print $2 }' $CONF`
+ local clamav_user=`awk '$1 == "User" { print $2 }' $CONF`
+ if [ -n "${logfile}" ] && [ -n "${clamav_user}" ]; then
+ if [ ! -f "${logfile}" ]; then
+ touch ${logfile}
+ fi
+ chown ${clamav_user} ${logfile}
+ chmod 640 ${logfile}
+ fi
+}
diff --git a/main/clamav/clamd.logrotate b/main/clamav/clamd.logrotate
new file mode 100644
index 0000000000..3d7fc79cad
--- /dev/null
+++ b/main/clamav/clamd.logrotate
@@ -0,0 +1,8 @@
+/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
+}
+
diff --git a/main/clamav/freshclam.confd b/main/clamav/freshclam.confd
new file mode 100644
index 0000000000..17559037da
--- /dev/null
+++ b/main/clamav/freshclam.confd
@@ -0,0 +1,3 @@
+
+FRESHCLAM_NICELEVEL=0
+
diff --git a/main/clamav/freshclam.initd b/main/clamav/freshclam.initd
new file mode 100644
index 0000000000..f25fec434d
--- /dev/null
+++ b/main/clamav/freshclam.initd
@@ -0,0 +1,59 @@
+#!/sbin/runscript
+
+opts="logfix reload"
+
+NAME=freshclam
+DAEMON=/usr/bin/$NAME
+CONF=/etc/clamav/freshclam.conf
+
+depend() {
+ need net
+ after firewall
+}
+
+start() {
+ ebegin "Starting freshclam"
+ start-stop-daemon --start --quiet \
+ --nicelevel ${FRESHCLAM_NICELEVEL:-0} \
+ --exec /usr/bin/freshclam -- -d
+ retcode=$?
+ if [ ${retcode} = 1 ]; then
+ eend 0
+ einfo "Virus databases are already up to date."
+ else
+ eend ${retcode} "Failed to start freshclam"
+ fi
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet --name ${NAME}
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${NAME}"
+ if ! service_started "${NAME}" ; then
+ eend 1 "${NAME} is not started"
+ return 1
+ fi
+ start-stop-daemon --stop --oknodo --signal HUP \
+ --exec ${DAEMON} --name $NAME
+ eend $?
+}
+
+
+logfix() {
+ # fix freshclam log permissions
+ # (might be clobbered by logrotate or something)
+ logfile=$(awk '$1 == "UpdateLogFile" { print $2 }' $CONF)
+ local freshclam_user=$(awk '$1 == "DatabaseOwner" { print $2 }' $CONF)
+ if [ -n "${logfile}" -a -n "${clamav_user}" ]; then
+ if [ ! -f "${logfile}" ]; then
+ touch ${logfile}
+ fi
+ chown ${freshclam_user} ${logfile}
+ chmod 640 ${logfile}
+ fi
+}
+
diff --git a/main/clamav/freshclam.logrotate b/main/clamav/freshclam.logrotate
new file mode 100644
index 0000000000..df42d6084f
--- /dev/null
+++ b/main/clamav/freshclam.logrotate
@@ -0,0 +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
+}