#! /bin/bash

set -e

export LANG=C
export LC_CTYPE=C

# Script to automatically build debian packages containing clamav
# data files

# Written by Marc Haber <mh+debian-packages@zugschlus.de>

# Most of this has been taken from kav-getfiles by
# Hilko Bengen <bengen@toplink-plannet.de>

# What does this do?
# ------------------
# * use freshclam to get data files.
# * Prepare debian/docs.
# * Check whether the files are OK by calling clamscan on eicar.com.
# * Build .deb.
#
# We need:
# --------
# * freshclam
# * clamscan

[ "$CLAMSCAN" ] || CLAMSCAN="$(which clamscan)"
[ "$FRESHCLAM" ] || FRESHCLAM="/usr/share/clamav-getfiles/freshclam-wrapper"
[ "$SIGTOOL" ] || SIGTOOL="$(which sigtool)"
[ "$DEBHELPERVERSION" ] || DEBHELPERVERSION="4.1.16"
[ "$DISTRIBUTION" ] || DISTRIBUTION="local"
[ "$SECTION" ] || SECTION="utils"
[ "$PURGEAFTERBUILD" ] || PURGEAFTERBUILD="yes"
[ "$AUTOGENWARNING" ] || AUTOGENWARNING=".
 Please note that this package was built automatically without human
 supervision and was only automatically checked before upload. Use
 at your own risk."
if [ "$AUTOGENWARNING" == "none" ]; then
  AUTOGENWARNING=""
fi

umask 002
DATADIR="$(pwd)/clamav-data"

CURL_OPTIONS='--silent --fail --remote-time --remote-name'

make_dirs() {
    echo "Creating directory clamav-data-$VERSION": 
    rm -rf clamav-data-$VERSION
    mkdir clamav-data-$VERSION
    cd clamav-data-$VERSION
    mkdir debian

    # output from diff -urN -x CVS debian.empty debian
    patch -up1 <<"EOF"
diff -urN -x CVS clamav-data/debian.empty/README.Debian.in clamav-data/debian/README.Debian.in
--- clamav-data/debian.empty/README.Debian.in	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/README.Debian.in	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,6 @@
+clamav-data for Debian
+-------------------
+
+This package was automatically created by clamav-getfiles.
+
+ -- Marc Haber <mh+debian-packages@zugschlus.de>, DATE
diff -urN -x CVS clamav-data/debian.empty/changelog.in clamav-data/debian/changelog.in
--- clamav-data/debian.empty/changelog.in	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/changelog.in	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,7 @@
+clamav-data (DEBIANVERSION) DISTRIBUTION; urgency=low
+
+  * Automatically generated by clamav-getfiles.
+  * See clamav-getfiles changelog for the real change log.
+    URL: http://packages.debian.org/changelogs/pool/main/c/clamav-getfiles/current/changelog.html
+
+ -- Marc Haber <mh+debian-packages@zugschlus.de>  DATE
diff -urN -x CVS clamav-data/debian.empty/config clamav-data/debian/config
--- clamav-data/debian.empty/config	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/config	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+. /usr/share/debconf/confmodule
+
+case "$1" in
+  configure|reconfigure)
+    db_input medium clamav-data/warn-on-old-databases
+    db_go
+    ;;
+  *)
+    echo "illegal parameter $1" >&2
+    ;;
+esac
diff -urN -x CVS clamav-data/debian.empty/control.in clamav-data/debian/control.in
--- clamav-data/debian.empty/control.in	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/control.in	2007-01-20 10:23:26.000000000 +0100
@@ -0,0 +1,25 @@
+Source: clamav-data
+Section: SECTION
+Priority: optional
+Maintainer: Marc Haber <mh+debian-packages@zugschlus.de>
+Build-Depends: debhelper (>= DEBHELPERVERSION), po-debconf
+Standards-Version: 3.7.2
+
+Package: clamav-data
+Architecture: all
+Conflicts: clamav-freshclam, clamav (<< 0.65)
+Replaces: clamav-freshclam
+Depends: ${misc:Depends}
+Description: clamav data files
+ This package contains data files for clamav and was automatically
+ generated by clamav-getfiles from the identically named package.
+ .
+ If you have downloaded this package from an "official" Debian
+ release, the databases contained here are most certainly outdated.
+ Please check if you can use clamav-freshclam to do automatic updates,
+ or use clamav-getfiles to generate your own clamav-data packages.
+ .
+ If you can't obtain your own current database files, you can apt more
+ recent database files from the Debian-volatile archive. See
+ http://volatile.debian.net for details.
+ AUTOGENWARNING
diff -urN -x CVS clamav-data/debian.empty/copyright clamav-data/debian/copyright
--- clamav-data/debian.empty/copyright	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/copyright	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,36 @@
+This package was built automatically
+
+The data files were downloaded by freshclam and automatically packaged
+by clamav-getfiles.
+
+freshclam is a program from the Debian package clamav-freshclam, see
+/usr/share/doc/clamav-freshclam.
+
+clamav-getfiles is a package by Marc Haber, see
+/usr/share/doc/clamav-getfiles.
+
+Copyright for this package by Marc Haber
+<mh+debian-packages@zugschlus.de>: GPL V2
+
+Copyright for the data files included in this package by Tomasz
+Kojm <tk@mat.uni.torun.pl>: GPL V2, as confirmed in private e-mail
+on Tue, 28 Jan 2003 16:00:54 +0100. There is no information
+in the databases themself due to their format.
+
+   This package is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 dated June, 1991.
+
+   This package is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this package; if not, write to the
+   Free Software Foundation, Inc.,
+   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+On Debian GNU/Linux systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
+
diff -urN -x CVS clamav-data/debian.empty/cron.daily clamav-data/debian/cron.daily
--- clamav-data/debian.empty/cron.daily	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/cron.daily	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+DAYSDIFF="60"
+DATADIR="/var/lib/clamav"
+[ "$DATABASEFILE" ] || DATABASEFILE="$DATADIR/daily.cvd"
+[ "$SIGTOOL" ] || SIGTOOL="`which sigtool`"
+
+if ! [ -e /var/lib/clamav-data/warn-on-old-databases ]; then
+  # user doesn't want to see warning
+  exit 0
+fi
+
+if [ -z "$SIGTOOL" ] || ! [ -x "$SIGTOOL" ]; then
+  # no sigtool present, clamav uninstalled
+  exit 0
+fi
+
+if ! [ -e "$DATABASEFILE" ]; then
+  # no database file present, package removed but not purged
+  exit 0
+fi
+
+if ! [ -e "$DATABASEFILE" ]; then
+  echo >&2 "ERR: $DATABASEFILE does not exist."
+  echo >&2 "     This should not happen since that file is part of the"
+  echo >&2 "     clamav-data package."
+  exit 1
+fi
+
+FILEDATE="$($SIGTOOL --stdout --info=$DATADIR/daily.cvd |\
+            sed -n '/^Build time:/{s/Build time: //;/^[[:alnum:]]\{3\}-[[:digit:]]\{2\} [[:digit:]]\{2\}-[[:digit:]]\{2\}/s/-/ /;s/-/:/;p;}')"
+DBDATE="`date --utc --date="$FILEDATE" +%s`"
+REFDATE="`date --utc --date="$DAYSDIFF days ago" +%s`"
+
+if [ $DBDATE -lt $REFDATE ]; then
+  cat >&2 <<EOF
+The clamav-data package that is installed does contain databases older
+than $DAYSDIFF days. This can give you a false sense of security since
+your clamav scanner will not detect any malicious code that has been found
+since then.
+
+Please update your clamav-data package at your earliest convenience. On a
+host with good Internet connectivity, you can install the package
+clamav-freshclam, which will pull current clamav databases from the Internet
+on a regular basis. Or you can run clamav-getfiles from the clamav-getfiles
+package to create an up-to-date clamav-data package.
+
+If you do not want to receive these e-mails any more, please run
+dpkg-reconfigure clamav-data and turn off the reminder e-mails.
+EOF
+fi
+
+# end of file
diff -urN -x CVS clamav-data/debian.empty/dirs clamav-data/debian/dirs
--- clamav-data/debian.empty/dirs	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/dirs	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,3 @@
+var/lib/clamav
+var/lib/clamav-data
+usr/share/clamav-data
diff -urN -x CVS clamav-data/debian.empty/install clamav-data/debian/install
--- clamav-data/debian.empty/install	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/install	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1 @@
+*.cvd var/lib/clamav
diff -urN -x CVS clamav-data/debian.empty/po/POTFILES.in clamav-data/debian/po/POTFILES.in
--- clamav-data/debian.empty/po/POTFILES.in	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/POTFILES.in	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1 @@
+[type: gettext/rfc822deb] templates
diff -urN -x CVS clamav-data/debian.empty/po/cs.po clamav-data/debian/po/cs.po
--- clamav-data/debian.empty/po/cs.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/cs.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,43 @@
+#
+#    Translators, if you are not familiar with the PO format, gettext
+#    documentation is worth reading, especially sections dedicated to
+#    this format, e.g. by running:
+#         info -n '(gettext)PO Files'
+#         info -n '(gettext)Header Entry'
+#
+#    Some information specific to po-debconf are available at
+#            /usr/share/doc/po-debconf/README-trans
+#         or http://www.debian.org/intl/l10n/po-debconf/README-trans
+#
+#    Developers do not need to manually edit POT or PO files.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2006-09-24 16:16+0200\n"
+"Last-Translator: Miroslav Kure <kurem@debian.cz>\n"
+"Language-Team: Czech <debian-l10n-czech@lists.debian.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr "Zasílat varovné e-maily o zastaralých datových souborech?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Tento balík obsahuje _neměnnou_ databázi virových vzorků pro clamav. Protože "
+"to může vést k falešnému pocitu bezpečí, umí balík pomocí cron.daily zasílat "
+"varování vždy, když jsou databáze starší než dva měsíce."
diff -urN -x CVS clamav-data/debian.empty/po/da.po clamav-data/debian/po/da.po
--- clamav-data/debian.empty/po/da.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/da.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,40 @@
+# translation of clamav-data_20031009.174551_templates.po to Danish
+#
+#
+# Claus Hindsgaul <claus_h@image.dk>, 2004.
+# Claus Hindsgaul <claus.hindsgaul@gmail.com>, 2006.
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data_20031009.174551_templates\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2006-07-23 14:16+0200\n"
+"Last-Translator: Claus Hindsgaul <claus.hindsgaul@gmail.com>\n"
+"Language-Team: Danish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.11.2\n"
+"Plural-Forms:  nplurals=2; plural=(n != 1);\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr "Vil du generere daglige advarselsbreve om forldede datafiler?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Denne pakke indeholder en uforanderlig database med virusmnstre til clamav. "
+"Da dette kan give en falsk tryghed, kan pakken generere advarsler med et "
+"cron-job i cron.daily, hvis databasen er mere end to mneder gammel."
+
+#~ msgid "Do you want this cron job to be executed?"
+#~ msgstr "nsker du at dette cron-job skal kres?"
diff -urN -x CVS clamav-data/debian.empty/po/de.po clamav-data/debian/po/de.po
--- clamav-data/debian.empty/po/de.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/de.po	2007-01-21 11:10:23.000000000 +0100
@@ -0,0 +1,47 @@
+# translation of po-debconf template to German
+#
+#    Translators, if you are not familiar with the PO format, gettext
+#    documentation is worth reading, especially sections dedicated to
+#    this format, e.g. by running:
+#         info -n '(gettext)PO Files'
+#         info -n '(gettext)Header Entry'
+#    Some information specific to po-debconf are available at
+#            /usr/share/doc/po-debconf/README-trans
+#         or http://www.debian.org/intl/l10n/po-debconf/README-trans#
+#    Developers do not need to manually edit POT or PO files.
+#
+# Erik Schanze <mail@erikschanze.de>, 2004.
+# Marc Haber <mh+debian-packages@zugschlus.de>, 2004.
+# Matthias Julius <mdeb@julius-net.net>, 2007.
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data 20070105.014100.2414\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2007-01-20 12:24-0500\n"
+"Last-Translator: Matthias Julius <mdeb@julius-net.net>\n"
+"Language-Team: German <debian-l10n-german@lists.debian.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.11.4\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr "Sollen bei veralteten Datendateien Warnungen per Email erzeugt werden?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Dieses Paket enthält eine _statische_ Datenbank an Virusdefinitionen für "
+"Clamav. Weil dies zu einem falschen Gefühl von Sicherheit führen kann, kann "
+"das Paket aus cron.daily Warnungen erzeugen, wenn die statische Datenbank "
+"älter als 2 Monate ist."
diff -urN -x CVS clamav-data/debian.empty/po/fr.po clamav-data/debian/po/fr.po
--- clamav-data/debian.empty/po/fr.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/fr.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,49 @@
+# translation of fr.po to French
+#
+#    Translators, if you are not familiar with the PO format, gettext
+#    documentation is worth reading, especially sections dedicated to
+#    this format, e.g. by running:
+#         info -n '(gettext)PO Files'
+#         info -n '(gettext)Header Entry'
+#
+#    Some information specific to po-debconf are available at
+#            /usr/share/doc/po-debconf/README-trans
+#         or http://www.debian.org/intl/l10n/po-debconf/README-trans
+#
+#    Developers do not need to manually edit POT or PO files.
+#
+# Christian Perrier <bubulle@debian.org>, 2006.
+msgid ""
+msgstr ""
+"Project-Id-Version: fr\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2006-05-29 15:20+0200\n"
+"Last-Translator: Christian Perrier <bubulle@debian.org>\n"
+"Language-Team: French <debian-l10n-french@lists.debian.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-15\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.11.2\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+"Envoi d'avertissements quotidiens par courriel en cas de donnes primes?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Ce paquet contient une base de donnes statique pour les signatures de virus "
+"destines  clamav. Cela peut conduire  une fausse impression de scurit. "
+"En consquence, le paquet peut avertir par courriel (via les tches "
+"quotidiennes de cron) si les bases de donnes statiques sont vieilles de "
+"plus de deux mois."
diff -urN -x CVS clamav-data/debian.empty/po/it.po clamav-data/debian/po/it.po
--- clamav-data/debian.empty/po/it.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/it.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,39 @@
+# Traduzione italiana di clamav-data
+# Copyright (C) 2004 Free Software Foundation, Inc.
+# Cristian Rigamonti <cri@linux.it>, 2004.
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data (20040430.104200.296)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2004-06-08 11:32+0200\n"
+"Last-Translator: Cristian Rigamonti <cri@linux.it>\n"
+"Language-Team: Italian <tp@lists.linux.it>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+#, fuzzy
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+"Si desidera ricevere un avviso via email se il database non  aggiornato?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Questo pacchetto contiene un database _statico_ di firme di virus per "
+"clamav. Poich ci potrebbe generare un falso senso di sicurezza, questo "
+"pacchetto pu generare avvisi usando cron.daily se il database statico non  "
+"aggiornato da pi di due mesi."
+
+#~ msgid "Do you want this cron job to be executed?"
+#~ msgstr "Si desidera eseguire questo cron job?"
diff -urN -x CVS clamav-data/debian.empty/po/ja.po clamav-data/debian/po/ja.po
--- clamav-data/debian.empty/po/ja.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/ja.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,47 @@
+#
+#    Translators, if you are not familiar with the PO format, gettext
+#    documentation is worth reading, especially sections dedicated to
+#    this format, e.g. by running:
+#         info -n '(gettext)PO Files'
+#         info -n '(gettext)Header Entry'
+#
+#    Some information specific to po-debconf are available at
+#            /usr/share/doc/po-debconf/README-trans
+#         or http://www.debian.org/intl/l10n/po-debconf/README-trans
+#
+#    Developers do not need to manually edit POT or PO files.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2003-09-21 14:03+0900\n"
+"Last-Translator: Kenshi Muto <kmuto@debian.org>\n"
+"Language-Team: Japanese <debian-japanese@lists.debian.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=EUC-JP\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+#, fuzzy
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr "Ťǡեηٹ e-mail ޤ?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Υѥå clamav 륹ѥΡŪʡץǡ١ޤ"
+"ޤϥƥθäǧ򾷤ǽΤǡŪǡ١"
+" 2 ʾŤˡѥå cron.daily ǷٹǤޤ"
+
+#~ msgid "Do you want this cron job to be executed?"
+#~ msgstr " cron ֤¹Ԥޤ?"
diff -urN -x CVS clamav-data/debian.empty/po/nl.po clamav-data/debian/po/nl.po
--- clamav-data/debian.empty/po/nl.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/nl.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,50 @@
+#
+#    Translators, if you are not familiar with the PO format, gettext
+#    documentation is worth reading, especially sections dedicated to
+#    this format, e.g. by running:
+#         info -n '(gettext)PO Files'
+#         info -n '(gettext)Header Entry'
+#
+#    Some information specific to po-debconf are available at
+#            /usr/share/doc/po-debconf/README-trans
+#         or http://www.debian.org/intl/l10n/po-debconf/README-trans
+#
+#    Developers do not need to manually edit POT or PO files.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data 20031009\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2003-11-03 10:56+0100\n"
+"Last-Translator: Tim Dijkstra <tim@famdijkstra.org>\n"
+"Language-Team: Debian Dutch <debian-i10n-dutch@lists.debian.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=iso-8859-15\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+#, fuzzy
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+"Wilt u dat er e-mails verstuurd worden om te waarschuwen voor verlopen "
+"gegevensbestanden?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Dit pakket bevat een _statische_ gegevensbank van viruspatronen voor clamav. "
+"Daar dit tot een vals gevoel van veiligheid kan leiden, kan dit pakket, als "
+"de gegevensbanken ouder zijn dan twee maanden, waarschuwingen genereren "
+"vanuit cron.daily."
+
+#~ msgid "Do you want this cron job to be executed?"
+#~ msgstr "Wilt u dat deze cron-opdracht wordt uitgevoerd?"
diff -urN -x CVS clamav-data/debian.empty/po/pt.po clamav-data/debian/po/pt.po
--- clamav-data/debian.empty/po/pt.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/pt.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,36 @@
+# Portuguese translation for clamav-data debconf messages
+# This file is distributed under the same license as the clamav-data package.
+# Ricardo Silva <ardoric@gmail.com>, 2006
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data 20060725.011200.1618\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2006-08-02 12:22+0100\n"
+"Last-Translator: Ricardo Silva <ardoric@gmail.com>\n"
+"Language-Team: Native Portuguese <traduz@debianpt.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+"Gerar diariamente emails de aviso sobre ficheiros de dados desactualizados?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Este pacote contém a base de dados _estática_ dos padrões de vírus para o "
+"Clamav. Como isto pode levar a uma falsa sensação de segurança, o pacote "
+"pode gerar falsos avisos na tarefa agendada diária cron.daily se as bases de "
+"dados forem mais antigas que dois meses."
diff -urN -x CVS clamav-data/debian.empty/po/pt_BR.po clamav-data/debian/po/pt_BR.po
--- clamav-data/debian.empty/po/pt_BR.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/pt_BR.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,50 @@
+#
+#    Translators, if you are not familiar with the PO format, gettext
+#    documentation is worth reading, especially sections dedicated to
+#    this format, e.g. by running:
+#         info -n '(gettext)PO Files'
+#         info -n '(gettext)Header Entry'
+#
+#    Some information specific to po-debconf are available at
+#            /usr/share/doc/po-debconf/README-trans
+#         or http://www.debian.org/intl/l10n/po-debconf/README-trans
+#
+#    Developers do not need to manually edit POT or PO files.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2004-02-28 22:31-0300\n"
+"Last-Translator: Andr Lus Lopes <andrelop@debian.org>\n"
+"Language-Team: Debian-BR Porject <debian-l10n-portuguese@lists.debian.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+#, fuzzy
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+"Deseja gerar mensagens de aviso sobre arquivos de dados desatualizados ?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Este pacote contm uma base de dados _esttica_ de padres de vrus para o "
+"clamav. Uma vez que isso pode levar a um falso senso de segurana, o pacote "
+"pode gerar avisos a partir do cron.daily caso as bases de dados estticas "
+"sejam mais antigas do que dois meses."
+
+#~ msgid "Do you want this cron job to be executed?"
+#~ msgstr "Voc deseja que esse job do cron seja executado ?"
diff -urN -x CVS clamav-data/debian.empty/po/ru.po clamav-data/debian/po/ru.po
--- clamav-data/debian.empty/po/ru.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/ru.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,50 @@
+# translation of clamav-data_20050523.175200.892_ru.po to Russian
+#
+#    Translators, if you are not familiar with the PO format, gettext
+#    documentation is worth reading, especially sections dedicated to
+#    this format, e.g. by running:
+#         info -n '(gettext)PO Files'
+#         info -n '(gettext)Header Entry'
+#    Some information specific to po-debconf are available at
+#            /usr/share/doc/po-debconf/README-trans
+#         or http://www.debian.org/intl/l10n/po-debconf/README-trans#
+#    Developers do not need to manually edit POT or PO files.
+# Yuriy Talakan' <yt@amur.elektra.ru>, 2005.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data_20050523.175200.892_ru\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2005-06-04 21:02+1000\n"
+"Last-Translator: Yuriy Talakan' <yt@amur.elektra.ru>\n"
+"Language-Team: Russian <debian-l10n-russian@lists.debian.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.9.1\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+#, fuzzy
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+"Хотите генерировать письма с предупреждениями об устаревших файлах данных?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Данный пакет содержит _статическую_ базу вирусных шаблонов для clamav. "
+"Поскольку это может привести к ложному ощущению безопасности, пакет может "
+"генерировать предупреждения из cron.daily, если статическая база устарела "
+"более чем на два месяца."
+
+#~ msgid "Do you want this cron job to be executed?"
+#~ msgstr "Хотите, чтобы выполнялось это задание cron?"
diff -urN -x CVS clamav-data/debian.empty/po/sv.po clamav-data/debian/po/sv.po
--- clamav-data/debian.empty/po/sv.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/sv.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,48 @@
+# Translators, if you are not familiar with the PO format, gettext
+# documentation is worth reading, especially sections dedicated to
+# this format, e.g. by running:
+# info -n '(gettext)PO Files'
+# info -n '(gettext)Header Entry'
+# Some information specific to po-debconf are available at
+# /usr/share/doc/po-debconf/README-trans
+# or http://www.debian.org/intl/l10n/po-debconf/README-trans
+# Developers do not need to manually edit POT or PO files.
+# , fuzzy
+# 
+# 
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data 20050930.171700.1106\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2005-10-12 22:44+0200\n"
+"Last-Translator: Daniel Nylander <po@danielnylander.se>\n"
+"Language-Team: Swedish <sv@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+#, fuzzy
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+"Vill du generera e-postvarningar med information om frldrade datafiler?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Detta paket innehller en _statisk_ databas med virussignaturer fr clamav. "
+"Eftersom detta kan leda till en falskt knsla av skerhet kan paketet "
+"generera varningar frn ett dagligt cronjob om de statiska databaserna r "
+"ldra n tv mnader."
+
+#~ msgid "Do you want this cron job to be executed?"
+#~ msgstr "Vill du att detta cronjob ska startas?"
diff -urN -x CVS clamav-data/debian.empty/po/templates.pot clamav-data/debian/po/templates.pot
--- clamav-data/debian.empty/po/templates.pot	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/templates.pot	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,41 @@
+#
+#    Translators, if you are not familiar with the PO format, gettext
+#    documentation is worth reading, especially sections dedicated to
+#    this format, e.g. by running:
+#         info -n '(gettext)PO Files'
+#         info -n '(gettext)Header Entry'
+#
+#    Some information specific to po-debconf are available at
+#            /usr/share/doc/po-debconf/README-trans
+#         or http://www.debian.org/intl/l10n/po-debconf/README-trans
+#
+#    Developers do not need to manually edit POT or PO files.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
diff -urN -x CVS clamav-data/debian.empty/po/vi.po clamav-data/debian/po/vi.po
--- clamav-data/debian.empty/po/vi.po	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/po/vi.po	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,42 @@
+# Vietnamese Translation for clamav-data.
+# Copyright © 2005 Free Software Foundation, Inc.
+# Clytie Siddall <clytie@riverland.net.au>, 2005.
+# 
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data 20050301.153900.739\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-01-20 07:08+0100\n"
+"PO-Revision-Date: 2005-05-21 16:25+0930\n"
+"Last-Translator: Clytie Siddall <clytie@riverland.net.au>\n"
+"Language-Team: Vietnamese <gnomevi-list@lists.sourceforge.net>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0\n"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+#, fuzzy
+msgid "Generate daily warning e-mails on outdated data files?"
+msgstr ""
+"Bạn có muốn tạo ra thư điện tử cảnh báo khi gặp tập tin dữ liệu cũ (quá hạn) "
+"không?"
+
+#. Type: boolean
+#. Description
+#: ../templates:1001
+msgid ""
+"This package contains a _static_ database of virus patterns for clamav. "
+"Since this can be leading to a false sense of security, the package can "
+"generate warnings out of cron.daily if the static databases are older than "
+"two months."
+msgstr ""
+"Gói tin này chứa một cơ sở dữ liệu _tĩnh_ của mẫu vi-rút cho trình clamav. "
+"Để giúp đỡ bạn nhớ để cập nhật dữ liệu này (để bảo vệ hệ thống) thì trình "
+"clamav có thể tạo ra cảnh báo dùng tập lệnh cron.daily nếu cơ sở dữ liệu "
+"tĩnh cũ hơn hai tháng."
+
+#~ msgid "Do you want this cron job to be executed?"
+#~ msgstr "Vậy bạn muốn trình cron làm việc này không?"
diff -urN -x CVS clamav-data/debian.empty/postinst clamav-data/debian/postinst
--- clamav-data/debian.empty/postinst	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/postinst	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,50 @@
+#!/bin/bash
+set -e
+
+[ $CAD_DEBUG ] && set -x
+
+DAEMONPKG="clamav-daemon"
+INITSCRIPT="/etc/init.d/$DAEMONPKG"
+
+. /usr/share/debconf/confmodule
+
+if [ "$1" = "configure" ]; then
+  db_get clamav-data/warn-on-old-databases
+  db_stop
+  rm -f /var/lib/clamav-data/warn-on-old-databases
+  if [ "$RET" = "true" ]; then
+    touch /var/lib/clamav-data/warn-on-old-databases
+  fi
+  
+  if [ -x "$INITSCRIPT" ]; then
+    RET=0
+ 
+    if command -v invoke-rc.d >/dev/null; then
+      OUTPUT="$(invoke-rc.d $DAEMONPKG reload-database 2>&1)" || RET=$?
+    else
+      OUTPUT="$($INITSCRIPT reload-database 2>&1)" || RET=$?
+    fi
+    if echo $OUTPUT | grep -q "^Usage: /etc/init.d/clamav-daemon {start|stop|restart|force-reload"; then
+      # we have an old (< 0.86.2-2) clamav that doesn't support reload-database
+      RET=0
+      if command -v invoke-rc.d >/dev/null; then
+        invoke-rc.d $DAEMONPKG restart || RET=$?
+      else
+        $INITSCRIPT restart || RET=$?
+      fi
+    else
+      echo >&2 $OUTPUT
+    fi
+
+    # clamav-daemon init script will return 0 on "no error" and
+    # 3 on "daemon is not running".
+    if [ "$RET" -ne 0 ] && [ "$RET" -ne 3 ]; then
+      echo >&2 "WARN: signaling clamav-daemon to reload database failed"
+    fi
+    if [ "$RET" -eq 3 ]; then
+      echo >&2 "WARN: clamav-daemon not running, according to init script"
+    fi
+  fi
+fi
+
+#DEBHELPER#
diff -urN -x CVS clamav-data/debian.empty/postrm clamav-data/debian/postrm
--- clamav-data/debian.empty/postrm	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/postrm	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if [ "$1" = "purge" ]; then
+  rm -f /var/lib/clamav-data/warn-on-old-databases
+fi
+
+#DEBHELPER#
diff -urN -x CVS clamav-data/debian.empty/rules clamav-data/debian/rules
--- clamav-data/debian.empty/rules	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/rules	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,73 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+# export DH_VERBOSE=1
+
+# This is the debhelper compatability version to use.
+export DH_COMPAT=4
+
+build: build-stamp
+build-stamp:
+	dh_testdir
+
+	# Add here commands to compile the package.
+	#$(MAKE)
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+
+	debconf-updatepo
+	# Add here commands to clean up after the build process.
+	# -$(MAKE) clean
+
+	dh_clean
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+	dh_install
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+#	dh_testversion
+	dh_testdir
+	dh_testroot
+	dh_installdebconf	
+	dh_installdocs
+#	dh_installexamples
+#	dh_installmenu
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installinit
+	dh_installcron
+#	dh_installmanpages
+#	dh_installinfo
+#	dh_undocumented
+	dh_installchangelogs 
+#	dh_link
+#	dh_strip
+	dh_compress
+	dh_fixperms
+	# You may want to make some executables suid here.
+#	dh_suidregister
+#	dh_makeshlibs
+	dh_installdeb
+#	dh_perl
+#	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff -urN -x CVS clamav-data/debian.empty/templates clamav-data/debian/templates
--- clamav-data/debian.empty/templates	1970-01-01 01:00:00.000000000 +0100
+++ clamav-data/debian/templates	2007-01-20 10:21:12.000000000 +0100
@@ -0,0 +1,8 @@
+Template: clamav-data/warn-on-old-databases
+Type: boolean
+Default: true
+_Description: Generate daily warning e-mails on outdated data files?
+ This package contains a _static_ database of virus patterns for clamav.
+ Since this can be leading to a false sense of security, the package can
+ generate warnings out of cron.daily if the static databases are older than
+ two months.
EOF

    # Create fresh changelog
    m4 -DDEBIANVERSION="$VERSION" -DDISTRIBUTION="$DISTRIBUTION" \
       -DDATE="$CHANGELOGDATE" -DDEBHELPERVERSION="$DEBHELPERVERSION" \
       -DSECTION="$SECTION" -DAUTOGENWARNING="$AUTOGENWARNING" \
    < debian/changelog.in \
    > debian/changelog
    # Create fresh README.Debian
    m4 -DDEBIANVERSION="$VERSION" -DDISTRIBUTION="$DISTRIBUTION" \
       -DDATE="$CHANGELOGDATE" -DDEBHELPERVERSION="$DEBHELPERVERSION" \
       -DSECTION="$SECTION" -DAUTOGENWARNING="$AUTOGENWARNING" \
    < debian/README.Debian.in \
    > debian/README.Debian
    # Create fresh control
    m4 -DDEBIANVERSION="$VERSION" -DDISTRIBUTION="$DISTRIBUTION" \
       -DDATE="$CHANGELOGDATE" -DDEBHELPERVERSION="$DEBHELPERVERSION" \
       -DSECTION="$SECTION" -DAUTOGENWARNING="$AUTOGENWARNING" \
    < debian/control.in \
    > debian/control

    chmod 755 debian/rules
    cd ..
}

# Today's data goes into changelog
CHANGELOGDATE="$(date --utc +'%a, %d %b %Y %T %z')"

FRESHCLAMCONFIGFILE=""
if [ -n "$FRESHCLAMCONF" ]; then
  FRESHCLAMCONFIGFILE="--config-file=$FRESHCLAMCONF"
fi

mkdir -p $DATADIR
chmod 770 $DATADIR
cd $DATADIR
if TMPDIR=$(mktemp -d clgf.XXXXXX); then
  chmod g+rwx $TMPDIR
  find . -maxdepth 1 -type f -print0 | xargs --null --no-run-if-empty cp --target-directory=$TMPDIR
  pwd
  RET=0
  $FRESHCLAM $FRESHCLAMCONFIGFILE --quiet --user $(id -un) --datadir $TMPDIR --log $TMPDIR/freshclam.log --log-verbose --on-update-execute="touch freshclam-new" || RET=$?
  rm -f $TMPDIR/mirrors.dat
  cat $TMPDIR/freshclam.log
  if [ "$RET" -gt "1" ]; then
    echo >&2 "ERR: can't download data files"
    exit 1
  fi
  if ! [ -f "$TMPDIR/freshclam-new" ]; then
    echo "No new databases available"
    rm -rf $TMPDIR
    exit 10
  fi
  rm -f $TMPDIR/freshclam.log $TMPDIR/freshclam-new
  cp $TMPDIR/* .
  rm -rf $TMPDIR
else
  echo >&2 "ERR: can't create temporary directory"
fi
cd ..

OUTPUTFILE=$(mktemp -t clamscanoutput.XXXXXX) || { echo "$0: Cannot create temporary file" >&2; exit 1;  }
trap " [ -f \"$OUTPUTFILE\" ] && /bin/rm -f -- \"$OUTPUTFILE\"" 0 1 2 3 13 15

if [ -x "$CLAMSCAN" ]; then
	[ "$CLAMAVTESTFILES" ] || CLAMAVTESTFILES="/usr/share/clamav-testfiles"
	if ! CLAMSCAN_OPTS="-d $DATADIR" clamav-check; then
	  echo 'Test of newly created database failed'
	  exit 1
	fi
else
	echo 'No test scan with new databases done, no clamscan in path.'
fi

if ! [ -e "$DATADIR/daily.cvd" ]; then
  echo >&2 "ERR: download failed, no $DATADIR/daily.cvd found"
  exit 1
fi

# if you change this, verify if the associated code in
# clamav-data/debian/cron.daily needs to be changed as well

FILEDATE="$($SIGTOOL --stdout --info=$DATADIR/daily.cvd |\
            sed -n '/^Build time:/{s/Build time: //;/^[[:alnum:]]\{3\}-[[:digit:]]\{2\} [[:digit:]]\{2\}-[[:digit:]]\{2\}/s/-/ /;s/-/:/;p;}')"
[ "$DEBUG" ] && $SIGTOOL --stdout --info=$DATADIR/daily.cvd	
[ "$DEBUG" ] && echo "converted date string: $FILEDATE"
if ! date --utc --date="$FILEDATE" > /dev/null; then
  echo >&2 "ERR: cannot parse date output, sigtool has changed!"
  exit 1
fi

DATE="$(date --utc --date="$FILEDATE" +%Y%m%d.%H%M00)"
[ "$DEBUG" ] && echo "DATE $DATE"
VERSNUM="$($SIGTOOL --stdout --info=$DATADIR/daily.cvd |\
	   sed -n '/^Version:/{s/Version: //;p;}')"
[ "$DEBUG" ] && echo "VERSNUM $VERSNUM"

VERSION="${DATE}.${VERSNUM}"
if [ -n "$VERSSUFFIX" ]; then
  VERSION="${VERSION}.${VERSSUFFIX}"
fi

if ! echo $VERSION | grep '[[:digit:]]\+\.[[:digit:]]\+'; then
  echo >&2 "ERR: version doesn't look like expected, sigtool has probably changed!"
  exit 1
fi

make_dirs

# Create (empty) updates directory and move downloaded files there.
cp $DATADIR/* clamav-data-$VERSION

cd clamav-data-$VERSION

# Remove -uc, -us if you do want to sign the packages.
dpkg-buildpackage -rfakeroot -uc -us 2>&1

if [ $? -ne 0 ] ; then
    echo 'An error occured while building the .deb file' >&2
    exit 3
fi

cd ..
if [ "$PURGEAFTERBUILD" = "yes" ]; then
  rm -rf clamav-data-$VERSION
fi
echo 'Done.'
