Bug#592322: [Pkg-clamav-devel] Bug#592322: freshclam.conf: update moves DatabaseMirror line

2010-08-11 Thread Török Edwin
On Mon, 9 Aug 2010 23:10:33 +0100
Stephen Gran sg...@debian.org wrote:

 This one time, at band camp, Török Edwin said:
  On Mon, 9 Aug 2010 12:55:32 +0100
  Stephen Gran sg...@debian.org wrote:
  
   This one time, at band camp, Török Edwin said:
After updating clamav-freshclam I got this diff:
--- /etc/clamav/freshclam.conf 2010-06-10 15:40:04.624888178
+0300 +++ /var/lib/clamav/freshclam.conf 2010-08-09
12:03:46.265177327 +0300
   
   I agree this is most likely a bug - we're probably not popping
   off the list in the same order we push onto it or something.
   
   However:
   
-- Package-specific info:
--- configuration ---
Checking configuration files in /usr/local/etc
   
   Can you try without local versions installed, just to make sure
   nothing funny is happening as a result?
  
  Well I can't reproduce this with an apt-get --reinstall
  clamav-freshclam.
  
  What should I do to try and reproduce this bug? Revert to older
  clamav-freshclam then upgrade again?
 
 Just eliminating the local version, and running
 dpkg-reconfigure -phigh clamav-freshclam
 once or twice should do it.

OK, so testcase:
Make /etc/clamav/freshclam.conf have these entries:
DatabaseMirror db.local.clamav.net
DatabaseMirror database.clamav.net

dpkg-reconfigure -phigh clamav-freshclam
dpkg-reconfigure -phigh clamav-freshclam

Now add db.ro.clamav.net as first like this:
DatabaseMirror db.ro.clamav.net
DatabaseMirror db.local.clamav.net
DatabaseMirror database.clamav.net

dpkg-reconfigure -phigh clamav-freshclam

Popup with diff showing it in wrong place.

 
 Although, looking at the way the list is set up, I can see that we are
 in fact setting it up wrong:
 
 We set up the variable:
 
   if [ -e $CLAMAVCONF ]; then
 for variable in `egrep -v '^[[:space:]]*(#|$)' $CLAMAVCONF |
 awk '{print $1}'`; do case $variable in
 DatabaseMirror)
 if [ -z $DatabaseMirror ]; then
   for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`;
 do value=$i $value
   done
 else
   continue
 fi
 ;;
 
 Then store that in debconf:
 
 if [ -n $DatabaseMirror ]; then
   if [ -e /usr/share/doc/clamav-freshclam/mirror-list.gz ]; then
 if zgrep -q
 $DatabaseMirror /usr/share/doc/clamav-freshclam/mirror-list.gz;then
 db_set clamav-freshclam/local_mirror `zgrep
 $DatabaseMirror /usr/share/doc/clamav-freshclam/mirror-list.gz` ||
 true else db_set clamav-freshclam/local_mirror $DatabaseMirror ||
 true fi fi
 fi
 
 Then pull it out to construct the config file:
 
   db_metaget clamav-freshclam/local_mirror value || true
   [ $RET =  ] || rawmirrors=$RET
   if echo $rawmirrors | egrep -q '(\(|\))'; then
 mirrors=`echo $rawmirrors | awk '{print $1}'`
   else
 mirrors=$rawmirrors
   fi
 
 And then finally write out the temporary copy of the config file:
   if [ -n $mirrors ]; then
 for i in $mirrors; do
   echo DatabaseMirror $i  $DEBCONFILE
 done
   fi
   if ! echo $mirrors | grep -q database.clamav.net; then
 echo DatabaseMirror database.clamav.net  $DEBCONFILE
   fi
   if [ -n $DatabaseMirror ]; then
 for m in $DatabaseMirror; do
   grep -q $m $DEBCONFILE || echo DatabaseMirror $m 
 $DEBCONFILE done
   fi
 
 So it looks like the simple fix will be to change:
 value=$i $value
 to
 value=$value $i
 
 in /var/lib/dpkg/info/clamav-freshclam.config and 
 /var/lib/dpkg/info/clamav-freshclam.postinst

Changing order here does something wrong with newlines, I get:
DatabaseMirror db.ro.clamav.net
 │ DatabaseMirror db.local.clamav.net DatabaseMirror
db.local.clamav.net │ DatabaseMirror database.clamav.net DatabaseMirror
database.clamav.net │   DatabaseMirror db.ro.clamav.net 



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#592322: [Pkg-clamav-devel] Bug#592322: freshclam.conf: update moves DatabaseMirror line

2010-08-09 Thread Stephen Gran
This one time, at band camp, Török Edwin said:
 After updating clamav-freshclam I got this diff:
 --- /etc/clamav/freshclam.conf 2010-06-10 15:40:04.624888178 +0300
 +++ /var/lib/clamav/freshclam.conf 2010-08-09 12:03:46.265177327 +0300

I agree this is most likely a bug - we're probably not popping off the
list in the same order we push onto it or something.

However:

 -- Package-specific info:
 --- configuration ---
 Checking configuration files in /usr/local/etc

Can you try without local versions installed, just to make sure nothing
funny is happening as a result?

Cheers,
-- 
 -
|   ,''`.Stephen Gran |
|  : :' :sg...@debian.org |
|  `. `'Debian user, admin, and developer |
|`- http://www.debian.org |
 -


signature.asc
Description: Digital signature


Bug#592322: [Pkg-clamav-devel] Bug#592322: freshclam.conf: update moves DatabaseMirror line

2010-08-09 Thread Török Edwin
On Mon, 9 Aug 2010 12:55:32 +0100
Stephen Gran sg...@debian.org wrote:

 This one time, at band camp, Török Edwin said:
  After updating clamav-freshclam I got this diff:
  --- /etc/clamav/freshclam.conf 2010-06-10 15:40:04.624888178 +0300
  +++ /var/lib/clamav/freshclam.conf 2010-08-09 12:03:46.265177327
  +0300
 
 I agree this is most likely a bug - we're probably not popping off the
 list in the same order we push onto it or something.
 
 However:
 
  -- Package-specific info:
  --- configuration ---
  Checking configuration files in /usr/local/etc
 
 Can you try without local versions installed, just to make sure
 nothing funny is happening as a result?

Well I can't reproduce this with an apt-get --reinstall
clamav-freshclam.

What should I do to try and reproduce this bug? Revert to older
clamav-freshclam then upgrade again?

Best regards,
--Edwin



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#592322: [Pkg-clamav-devel] Bug#592322: freshclam.conf: update moves DatabaseMirror line

2010-08-09 Thread Stephen Gran
This one time, at band camp, Török Edwin said:
 On Mon, 9 Aug 2010 12:55:32 +0100
 Stephen Gran sg...@debian.org wrote:
 
  This one time, at band camp, Török Edwin said:
   After updating clamav-freshclam I got this diff:
   --- /etc/clamav/freshclam.conf 2010-06-10 15:40:04.624888178 +0300
   +++ /var/lib/clamav/freshclam.conf 2010-08-09 12:03:46.265177327
   +0300
  
  I agree this is most likely a bug - we're probably not popping off the
  list in the same order we push onto it or something.
  
  However:
  
   -- Package-specific info:
   --- configuration ---
   Checking configuration files in /usr/local/etc
  
  Can you try without local versions installed, just to make sure
  nothing funny is happening as a result?
 
 Well I can't reproduce this with an apt-get --reinstall
 clamav-freshclam.
 
 What should I do to try and reproduce this bug? Revert to older
 clamav-freshclam then upgrade again?

Just eliminating the local version, and running
dpkg-reconfigure -phigh clamav-freshclam
once or twice should do it.

Although, looking at the way the list is set up, I can see that we are
in fact setting it up wrong:

We set up the variable:

  if [ -e $CLAMAVCONF ]; then
for variable in `egrep -v '^[[:space:]]*(#|$)' $CLAMAVCONF | awk '{print 
$1}'`; do
  case $variable in
DatabaseMirror)
if [ -z $DatabaseMirror ]; then
  for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`; do
value=$i $value
  done
else
  continue
fi
;;

Then store that in debconf:

if [ -n $DatabaseMirror ]; then
  if [ -e /usr/share/doc/clamav-freshclam/mirror-list.gz ]; then
if zgrep -q $DatabaseMirror 
/usr/share/doc/clamav-freshclam/mirror-list.gz;then
  db_set clamav-freshclam/local_mirror `zgrep $DatabaseMirror 
/usr/share/doc/clamav-freshclam/mirror-list.gz` || true
else
  db_set clamav-freshclam/local_mirror $DatabaseMirror || true
fi
  fi
fi

Then pull it out to construct the config file:

  db_metaget clamav-freshclam/local_mirror value || true
  [ $RET =  ] || rawmirrors=$RET
  if echo $rawmirrors | egrep -q '(\(|\))'; then
mirrors=`echo $rawmirrors | awk '{print $1}'`
  else
mirrors=$rawmirrors
  fi

And then finally write out the temporary copy of the config file:
  if [ -n $mirrors ]; then
for i in $mirrors; do
  echo DatabaseMirror $i  $DEBCONFILE
done
  fi
  if ! echo $mirrors | grep -q database.clamav.net; then
echo DatabaseMirror database.clamav.net  $DEBCONFILE
  fi
  if [ -n $DatabaseMirror ]; then
for m in $DatabaseMirror; do
  grep -q $m $DEBCONFILE || echo DatabaseMirror $m  $DEBCONFILE
done
  fi

So it looks like the simple fix will be to change:
value=$i $value
to
value=$value $i

in /var/lib/dpkg/info/clamav-freshclam.config and 
/var/lib/dpkg/info/clamav-freshclam.postinst

If the naive first try of dpkg-reconfigure still does the wrong thing
for you after removing the local copy, can you try this fix and let me
know if it does the right thing?  I suspect that's all that's needed,
but as you have a handy test case, it would be useful to confirm it.

My fear is that it will be a more subtle bug with the way we are using
debconf to store the data (that the template expects a single value, and
we are potentially storing a space seperated multi-value list, some of
which aren't in the debconf list of things to pick from).  If the above
simple case doesn't fix it for you, I may ask you to do some more set -x
debugging to confirm that.

Cheers,
-- 
 -
|   ,''`.Stephen Gran |
|  : :' :sg...@debian.org |
|  `. `'Debian user, admin, and developer |
|`- http://www.debian.org |
 -


signature.asc
Description: Digital signature