File clamav-database-refresh.sh of Package clamav-database.23529

#!/bin/bash


# Tue Jan 14 15:33:40 CET 2014 - draht
#
# remark:
# 
# This update shell script doesn't really make sense as part of 
# the source of a package that doesn't have network access during
# its build. In fact, %build is empty.
#
# However, now that the script is right in front of you, you can
# use it to update the tar file with the virus database from your
# host system, and change the version string in the spec file to
# the current date.
# Convenience...

C_DB=clamav-database.tar.bz2
SPEC=$( echo *.spec)
if [ ! -x "`which freshclam`" ]; then
  echo "You need the package clamav or clamav-nodb installed on your system for the update
of the clamav malware database using the freshclam tool to be able to work.

Fatal, exit."
exit 11
fi

freshclam
(
cd /
tar cfvv - var/lib/clamav
) | bzip2 -c9 > $C_DB

# osc may bitch around if it uses an incorrect API URL with the vc command.
# is this a bug?
#
# never mind...
apiurl=$( cat .osc/_apiurl )
# osc result may belong to root. Better jump through hula hoops and
# not use any new inodes.
cp -a clamav-database.changes clamav-database.changes..
rm -f a.changes
osc -A $apiurl vc -m "database refresh on `date +'%F'` (bsc#1084929)" a.changes
cat a.changes clamav-database.changes.. > clamav-database.changes
diff -u clamav-database.changes.. clamav-database.changes
rm -f clamav-database.changes.. a.changes

DATESTRING=`date +"%Y%m%d%H%M"`
# retain owner of spec file if this runs as root
cp -a $SPEC $SPEC.n
awk -v DATESTRING=$DATESTRING '
/^Version:/ { printf("Version:\t%s\n", DATESTRING); next; }
/^Release:/ { printf("Release:\t0.0\n"); next; }
{ print };
' < $SPEC > $SPEC.n

diff -u $SPEC $SPEC.n
mv $SPEC.n $SPEC


openSUSE Build Service is sponsored by