Hi Bernd,

Here are my findings... to make story short -- the problem is in the
prerm script -- in the order of embedded autoscripts by debhelper tools.
I am not yet sure what is the best solution on how to get it under
control and I am too sleepy to trust my decision... now the best idea is
simply use sed or perl 1-2 liner to swap those sections places in
prerm... I should not change the order of commands in debian/rules and
should not duplicate them since it might lead to some undersired
outcomes and duplicate entries in postinst/prerm.  If you have a good
idea on how to handle it -- I am open for suggestions...

I am yet to look at your patch to extract useful ideas from it ;-)

I will fix fail2ban tomorrow or day after ;-) if you are bored you
are welcome to see my notes below:

pycentral is supposed to do all the job of byte-compiling and removing
trash in prerm for private scripts too (disregard strace calls
below -- it was there just so I didn't have to rerun to see what it
opened/closed):
,--
| > find /usr/share/fail2ban/ -iname *.pyc | xargs rm
| > find /usr/share/fail2ban/ -iname *.pyc | wc
|       0       0       0
| > strace -fF -o /tmp/fail2ban.pkginstall.strace.txt pycentral -v pkginstall 
fail2ban &> /tmp/fail2ban.pkginstall.log
| > find /usr/share/fail2ban/ -iname *.pyc | wc
|      39      39    1599
| > strace -fF -o /tmp/fail2ban.pkgremove.strace.txt pycentral -v pkgremove 
fail2ban &> /tmp/fail2ban.pkgremove.log
| > find /usr/share/fail2ban/ -iname *.pyc | wc
|       0       0       0
| > cat /tmp/fail2ban.pkgremove.log
| umovestr: Input/output error
| pycentral: pycentral -v pkgremove fail2ban
| INFO: using old version '/usr/bin/python2.3'
| INFO: using unsupported version '/usr/bin/python2.5'
| pycentral:      remove package fail2ban
| pycentral:      remove byte-code files (39)
|
`---

pkginstall must be called in postinst and pkgremove in prerm, and
presumably they are, just grep
grep  pycentral /var/lib/dpkg/info/fail2ban.*

so the question is really WTF?

not thinking too long after I didn't find a proper way via DH_PYCENTRAL to make
it verbose, I just modified it to be verbose by default.

ok -- reinstalling works fine...
,---
| > sudo dpkg -i fail2ban_0.8.0-1_all.deb
| (Reading database ... 437961 files and directories currently installed.)
| Preparing to replace fail2ban 0.7.9-1 (using fail2ban_0.8.0-1_all.deb) ...
| pycentral: pycentral pkgremove fail2ban
| INFO: using old version '/usr/bin/python2.3'
| INFO: using unsupported version '/usr/bin/python2.5'
| pycentral:      remove package fail2ban
| pycentral:      remove byte-code files (39)
| Stopping authentication failure monitor: fail2ban.
| Unpacking replacement fail2ban ...
| Setting up fail2ban (0.8.0-1) ...
| pycentral: pycentral pkginstall fail2ban
| INFO: using old version '/usr/bin/python2.3'
| INFO: using unsupported version '/usr/bin/python2.5'
| pycentral:      avail=['2.3', '2.4', '2.5'], pkg=current, install=['2.4']
| pycentral:      install package fail2ban
| pycentral:      byte-compile files (39/39) python2.4
| pycentral:          ['/usr/share/fail2ban/common/protocol.py', 
'/usr/share/fail2ban/common/__init__.py', '...']
| Starting authentication failure monitor: fail2ban.
|
| > find /usr/share/fail2ban/ -iname *.pyc | wc
|      39      39    1599
`---

But removing
,--
| > dpkg --purge fail2ban
| (Reading database ... 437961 files and directories currently installed.)
| Removing fail2ban ...
| pycentral: pycentral pkgremove fail2ban
| INFO: using old version '/usr/bin/python2.3'
| INFO: using unsupported version '/usr/bin/python2.5'
| pycentral:      remove package fail2ban
| pycentral:      remove byte-code files (39)
| Stopping authentication failure monitor: fail2ban.
| Purging configuration files for fail2ban ...
| dpkg - warning: while removing fail2ban, directory `/etc/fail2ban/action.d' 
not empty so not removed.
| dpkg - warning: while removing fail2ban, directory `/etc/fail2ban' not empty 
so not removed.
| dpkg - warning: while removing fail2ban, directory 
`/usr/share/fail2ban/server' not empty so not removed.
| dpkg - warning: while removing fail2ban, directory 
`/usr/share/fail2ban/client' not empty so not removed.
| dpkg - warning: while removing fail2ban, directory 
`/usr/share/fail2ban/common' not empty so not removed.
| dpkg - warning: while removing fail2ban, directory `/usr/share/fail2ban' not 
empty so not removed.
| > find /usr/share/fail2ban/ -iname *.pyc | wc
|      23      23     938
`---

So, pycentral had in mind to remove all pyc files but unfortunately
didn't succeed for some reason... ufff... since you saw above that calling it
from cmdline cleaned up everything nicely -- no files were left behind. So that
is what is weird...

ok -- lets look closer and what got deinstalled (omitted cmdlines for the 
size...)
,------------------------------------------------------------------
| > diff /tmp/fail2ban.installed.pyc /tmp/fail2ban.deinstalled.pyc
| 17d16
| < /usr/share/fail2ban/server/ssocket.pyc
| 25,39d23
| < /usr/share/fail2ban/server/filter.pyc
| < /usr/share/fail2ban/server/server.pyc
| < /usr/share/fail2ban/server/datestrptime.pyc
| < /usr/share/fail2ban/server/failticket.pyc
| < /usr/share/fail2ban/server/filterpoll.pyc
| < /usr/share/fail2ban/server/datetai64n.pyc
| < /usr/share/fail2ban/server/faildata.pyc
| < /usr/share/fail2ban/server/filtergamin.pyc
| < /usr/share/fail2ban/server/failregex.pyc
| < /usr/share/fail2ban/server/failmanager.pyc
| < /usr/share/fail2ban/server/datedetector.pyc
| < /usr/share/fail2ban/server/transmitter.pyc
| < /usr/share/fail2ban/server/dateepoch.pyc
| < /usr/share/fail2ban/server/datetemplate.pyc
| < /usr/share/fail2ban/server/regex.pyc
`---
so  just some files under server got removed while the rest not... 

then I had a look at postrm script and YEAY -- here is the reason:

,--
| [EMAIL PROTECTED]:/home/yoh.m/deb/debs/fail2ban/build-area/pbuilder/sid# grep 
-3 '^#' /var/lib/dpkg/info/fail2ban.prerm
| #!/bin/sh
| set -e
| # Automatically added by dh_pycentral
| if which python >/dev/null 2>&1 && which pycentral >/dev/null 2>&1; then
|         pycentral pkgremove fail2ban
| else
| --
|             | awk '/\/usr\/share\/pycentral/ {next} /\.py$/ {print $0"c\n" 
$0"o"}' \
|             | xargs rm -f >&2
| fi
| # End automatically added section
| # Automatically added by dh_installinit
| if [ -x "/etc/init.d/fail2ban" ]; then
|         if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|                 invoke-rc.d fail2ban stop || exit $?
| --
|                 /etc/init.d/fail2ban stop || exit $?
|         fi
| fi
| # End automatically added section
|
`---

;) so, after pycentral cleans up, I call fail2ban-client stop in init.d
script, which causes compilation of .pyc files... doh -- why I didn't think
about that from the beginning ;-)

The question now is how to fix it properly -- swapping of lines pycentral
and installinit would not be perfect, since then installinit would cause
bytecompilation of .py files before dh_pycentral call... heh heh...

-- 
                                  .-.
=------------------------------   /v\  ----------------------------=
Keep in touch                    // \\     (yoh@|www.)onerussian.com
Yaroslav Halchenko              /(   )\               ICQ#: 60653192
                   Linux User    ^^-^^    [175555]



Reply via email to