#! /bin/bash

unset DEBUG
# DEBUG=1

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="`which freshclam`"
[ "$SIGTOOL" ] || SIGTOOL="`which sigtool`"
[ "$DEBHELPERVERSION" ] || DEBHELPERVERSION="4.1.16"

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 00:00:00.000000000 +0000
+++ clamav-data/debian/README.Debian.in	2005-03-01 16:11:26.000000000 +0000
@@ -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 00:00:00.000000000 +0000
+++ clamav-data/debian/changelog.in	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,5 @@
+clamav-data (DEBIANVERSION) unstable; urgency=low
+
+  * Initial Release, created by clamav-getfiles
+
+ -- 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 00:00:00.000000000 +0000
+++ clamav-data/debian/config	2005-03-01 16:11:26.000000000 +0000
@@ -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 00:00:00.000000000 +0000
+++ clamav-data/debian/control.in	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,29 @@
+Source: clamav-data
+Section: utils
+Priority: optional
+Maintainer: Marc Haber <mh+debian-packages@zugschlus.de>
+Build-Depends-Indep: debhelper (>= DEBHELPERVERSION)
+Standards-Version: 3.6.1
+
+Package: clamav-data
+Architecture: all
+Conflicts: clamav-freshclam, clamav (<< 0.65)
+Replaces: clamav-freshclam
+Depends: ${debconf-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
+  deb http://people.debian.org/~zugschlus/clamav-data/ /
+  deb-src http://people.debian.org/~zugschlus/clamav-data/ /
+ .
+ Please note that the packages from people.debian.org are built
+ automatically and are not checked by any human before they are put up
+ for download. Use them at your own risk.
diff -urN -x CVS clamav-data/debian.empty/copyright clamav-data/debian/copyright
--- clamav-data/debian.empty/copyright	1970-01-01 00:00:00.000000000 +0000
+++ clamav-data/debian/copyright	2005-03-01 16:11:26.000000000 +0000
@@ -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., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, 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 00:00:00.000000000 +0000
+++ clamav-data/debian/cron.daily	2005-03-01 16:11:26.000000000 +0000
@@ -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 00:00:00.000000000 +0000
+++ clamav-data/debian/dirs	2005-03-01 16:11:26.000000000 +0000
@@ -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 00:00:00.000000000 +0000
+++ clamav-data/debian/install	2005-03-01 16:11:26.000000000 +0000
@@ -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 00:00:00.000000000 +0000
+++ clamav-data/debian/po/POTFILES.in	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1 @@
+[type: gettext/rfc822deb] templates.master
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 00:00:00.000000000 +0000
+++ clamav-data/debian/po/cs.po	2005-03-01 16:21:58.000000000 +0000
@@ -0,0 +1,46 @@
+#
+#    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: 2003-08-12 09:04+0200\n"
+"PO-Revision-Date: 2005-02-04 12:49+0100\n"
+"Last-Translator: Miroslav Kure <kurem@debian.cz>\n"
+"Language-Team: Czech <debian-l10n-czech@debian.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-2\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr "Chcete zaslat varovn e-maily o zastaralch datovch souborech?"
+
+#. Description
+#: ../templates:5
+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 balk obsahuje _nemnnou_ databzi virovch vzork pro clamav. "
+"Protoe to me vst k falenmu pocitu bezpe, um balk pomoc "
+"cron.daily zaslat varovn vdy, kdy jsou databze star ne dva msce."
+
+#. Description
+#: ../templates:5
+msgid "Do you want this cron job to be executed?"
+msgstr "Chcete spustit tuto cronovou lohu?"
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 00:00:00.000000000 +0000
+++ clamav-data/debian/po/da.po	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,41 @@
+# translation of clamav-data_20031009.174551_templates.po to Danish
+# Claus Hindsgaul <claus_h@image.dk>, 2004.
+#
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data_20031009.174551_templates\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2003-08-12 09:04+0200\n"
+"PO-Revision-Date: 2004-02-20 13:21+0100\n"
+"Last-Translator: Claus Hindsgaul <claus_h@image.dk>\n"
+"Language-Team: Danish <dansk@klid.dk>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.3\n"
+"Plural-Forms:  nplurals=2; plural=(n != 1);\n"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr "Vil du generere advarselsbreve om forldede datafiler?"
+
+#. Description
+#: ../templates:5
+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."
+
+#. Description
+#: ../templates:5
+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 00:00:00.000000000 +0000
+++ clamav-data/debian/po/de.po	2005-03-01 16:11:26.000000000 +0000
@@ -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.
+# Erik Schanze <mail@erikschanze.de>, 2004.
+# Marc Haber <mh+debian-packages@zugschlus.de>, 2004.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data_20040430.104200.296_templates\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2003-08-12 09:04+0200\n"
+"PO-Revision-Date: 2004-05-25 23:21+0200\n"
+"Last-Translator: Erik Schanze <mail@erikschanze.de>, Marc Haber <mh+debian-packages@zugschlus.de>\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.3.1\n"
+"Plural-Forms:  nplurals=2; plural=(n != 1);\n"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr "Sollen bei zu alten Virusdefinitionen Warnungen per Email erzeugt werden?"
+
+#. Description
+#: ../templates:5
+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 _festen_ Bestand 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 Datenbasis "
+"ä¤lter als 2 Monate ist."
+
+#. Description
+#: ../templates:5
+msgid "Do you want this cron job to be executed?"
+msgstr "Soll dieser cronjob eingerichtet werden?"
+
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 00:00:00.000000000 +0000
+++ clamav-data/debian/po/fr.po	2005-03-01 16:11:26.000000000 +0000
@@ -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.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: clamav-data (20030706.141937)\n"
+"POT-Creation-Date: 2003-08-12 08:52+0200\n"
+"PO-Revision-Date: 2003-08-12 08:56+0100\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"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr ""
+"Souhaitez-vous des avertissements par courriel en cas de donnes primes?"
+
+#. Description
+#: ../templates:5
+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."
+
+#. Description
+#: ../templates:5
+msgid "Do you want this cron job to be executed?"
+msgstr "Souhaitez-vous programmer cette tche de cron?"
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 00:00:00.000000000 +0000
+++ clamav-data/debian/po/it.po	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,37 @@
+# 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: 2003-08-12 09:04+0200\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"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr "Si desidera ricevere un avviso via email se il database non  aggiornato?"
+
+#. Description
+#: ../templates:5
+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."
+
+#. Description
+#: ../templates:5
+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 00:00:00.000000000 +0000
+++ clamav-data/debian/po/ja.po	2005-03-01 16:11:26.000000000 +0000
@@ -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: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2003-08-12 09:04+0200\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"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr "Ťǡեηٹ e-mail ޤ?"
+
+#. Description
+#: ../templates:5
+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 ǷٹǤޤ"
+
+#. Description
+#: ../templates:5
+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 00:00:00.000000000 +0000
+++ clamav-data/debian/po/nl.po	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,39 @@
+#
+#    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"
+"POT-Creation-Date: 2003-08-12 09:04+0200\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"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr "Wilt u dat er e-mails verstuurd worden om te waarschuwen voor verlopen gegevensbestanden?"
+
+#. Description
+#: ../templates:5
+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."
+
+#. Description
+#: ../templates:5
+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_BR.po clamav-data/debian/po/pt_BR.po
--- clamav-data/debian.empty/po/pt_BR.po	1970-01-01 00:00:00.000000000 +0000
+++ clamav-data/debian/po/pt_BR.po	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,49 @@
+#
+#    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: 2003-08-12 09:04+0200\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"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr ""
+"Deseja gerar mensagens de aviso sobre arquivos de dados desatualizados ?"
+
+#. Description
+#: ../templates:5
+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."
+
+#. Description
+#: ../templates:5
+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/templates.pot clamav-data/debian/po/templates.pot
--- clamav-data/debian.empty/po/templates.pot	1970-01-01 00:00:00.000000000 +0000
+++ clamav-data/debian/po/templates.pot	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,44 @@
+#
+#    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: 2003-08-12 09:04+0200\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"
+
+#. Description
+#: ../templates:5
+msgid "Do you want to generate warning e-mails on outdated data files?"
+msgstr ""
+
+#. Description
+#: ../templates:5
+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 ""
+
+#. Description
+#: ../templates:5
+msgid "Do you want this cron job to be executed?"
+msgstr ""
diff -urN -x CVS clamav-data/debian.empty/postinst clamav-data/debian/postinst
--- clamav-data/debian.empty/postinst	1970-01-01 00:00:00.000000000 +0000
+++ clamav-data/debian/postinst	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+
+. /usr/share/debconf/confmodule
+
+if [ "$1" = "configure" ]; then
+  db_get clamav-data/warn-on-old-databases
+  rm -f /var/lib/clamav-data/warn-on-old-databases
+  if [ "$RET" = "true" ]; then
+    touch /var/lib/clamav-data/warn-on-old-databases
+  fi
+fi
+
+#DEBHELPER#
diff -urN -x CVS clamav-data/debian.empty/postrm clamav-data/debian/postrm
--- clamav-data/debian.empty/postrm	1970-01-01 00:00:00.000000000 +0000
+++ clamav-data/debian/postrm	2005-03-01 16:11:26.000000000 +0000
@@ -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 00:00:00.000000000 +0000
+++ clamav-data/debian/rules	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,95 @@
+#!/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
+
+ifeq (,$(wildcard /usr/bin/po2debconf))
+	PO2DEBCONF := no
+	MINDEBCONFVER := 0.5
+else
+	PO2DEBCONF := yes
+	MINDEBCONFVER := 1.2.0
+endif
+
+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
+
+	# Add here commands to clean up after the build process.
+	# -$(MAKE) clean
+
+	#	dh_clean
+
+ifeq ($(PO2DEBCONF),yes)
+	# Hack for woody compatibility. This makes sure that the
+	# debian/templates file shipped in the source package doesn't
+	# specify encodings, which woody's debconf can't handle. If
+	# building on a system with po-debconf installed (conveniently
+	# debhelper (>= 4.1.16) depends on it), the binary-arch target
+	# will generate a  better version for sarge.
+	echo 1 > debian/po/output
+	po2debconf debian/templates.master > debian/templates
+	rm -f debian/po/output
+endif
+
+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
+ifeq ($(PO2DEBCONF),yes)
+	po2debconf -e utf8 debian/templates.master > debian/templates
+endif
+	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 -- -V'debconf-depends=debconf (>= $(MINDEBCONFVER))'
+	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 00:00:00.000000000 +0000
+++ clamav-data/debian/templates	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,18 @@
+Template: clamav-data/warn-on-old-databases
+Type: boolean
+Default: true
+Description: Do you want to generate 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.
+ .
+ Do you want this cron job to be executed?
+Description-fr: Souhaitez-vous des avertissements par courriel en cas de donnes primes?
+ 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.
+ .
+ Souhaitez-vous programmer cette tche de cron?
diff -urN -x CVS clamav-data/debian.empty/templates.master clamav-data/debian/templates.master
--- clamav-data/debian.empty/templates.master	1970-01-01 00:00:00.000000000 +0000
+++ clamav-data/debian/templates.master	2005-03-01 16:11:26.000000000 +0000
@@ -0,0 +1,10 @@
+Template: clamav-data/warn-on-old-databases
+Type: boolean
+Default: true
+_Description: Do you want to generate 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.
+ .
+ Do you want this cron job to be executed?
EOF

    # Create fresh changelog
    m4 -DDEBIANVERSION="$VERSION" -DDATE="$CHANGELOGDATE" -DDEBHELPERVERSION="$DEBHELPERVERSION"\
    < debian/changelog.in \
    > debian/changelog
    # Create fresh README.Debian
    m4 -DDEBIANVERSION="$VERSION" -DDATE="$CHANGELOGDATE" -DDEBHELPERVERSION="$DEBHELPERVERSION"\
    < debian/README.Debian.in \
    > debian/README.Debian
    # Create fresh control
    m4 -DDEBIANVERSION="$VERSION" -DDATE="$CHANGELOGDATE" -DDEBHELPERVERSION="$DEBHELPERVERSION"\
    < 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
#ln -sf $MIRRORS $DATADIR
RET=0
$FRESHCLAM $FRESHCLAMCONFIGFILE --datadir $DATADIR --log $DATADIR/freshclam.log --log-verbose || RET=$?

if [ $RET -gt 1 ]; then
	echo >&2 "ERR: can't download data files"
	exit 1
fi

OUTPUTFILE="/tmp/clamscanoutput.$$"

if [ -x "$CLAMSCAN" ]; then
	[ "$CLAMAVTESTFILES" ] || CLAMAVTESTFILES="/usr/share/clamav-testfiles"
	[ "$REFNUMBADFILES" ] || REFNUMBADFILES="5"
       	echo "$CLAMSCAN -d $DATADIR --recursive $CLAMAVTESTFILES"
	RET=0
	$CLAMSCAN -d $DATADIR --recursive $CLAMAVTESTFILES > $OUTPUTFILE 2>&1 || RET=$?
	cat $OUTPUTFILE
	if [ $RET -ne 1 ] ; then
	    echo >&2 "An error ($RET) occured while scanning clamav test files."
	    rm $OUTPUTFILE
	    exit 2
	fi
	NUMBADFILES=`< $OUTPUTFILE grep 'ClamAV-Test-File FOUND' | wc -l`
	if [ $NUMBADFILES -ne $REFNUMBADFILES ]; then
	    echo >&2 "Wrong number ($NUMBADFILES/$REFNUMBADFILES) of 'infected' files detected while scanning clamav test files"
	    rm $OUTPUTFILE
	    exit 2
	fi

	[ "$EICAR" ] || EICAR="/var/lib/clamav-getfiles/eicar.com"
	if [ -f "$EICAR" ]; then
            echo "$CLAMSCAN clamscan -d $DATADIR $EICAR"
	    RET=0
	    $CLAMSCAN -d $DATADIR $EICAR > $OUTPUTFILE 2>&1 || RET=$?
	    cat $OUTPUTFILE
	    if [ $RET -ne 1 ] ; then
	        echo >&2 "An error ($RET) occured while scanning the EICAR Anti-Virus test file."
		rm $OUTPUTFILE
	        exit 2
	    fi
	    NUMBADFILES=`< $OUTPUTFILE grep 'Eicar-Test-Signature FOUND' | wc -l`
	    if [ $NUMBADFILES -ne 1 ]; then
	        echo >&2 "Wrong number ($NUMBADFILES/1) of 'infected' files detected while scanning EICAR Anti-Virus test file"
		rm $OUTPUTFILE
	        exit 2
	    fi
	else
	    echo "No test scan against eicar.com done, file not present on system."
	    echo "You might want to install eicar-testfile or manually put eicar.com"
	    echo "to $EICAR"
	fi
        rm $OUTPUTFILE
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 ! 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 ..
rm -rf clamav-data-$VERSION
echo 'Done.'
