Hi,

I encountered the same issue; the unnecessary question for overwriting a
conffile that does not exist anymore, because it's already diverted. But
in contrast to the original bug poster, removing the package in question
wasn't a problem, unless the dpkg-divert removal statement in put in the
right postrm target.

Another observation is that if the overwriting package has the new
configuration file not marked as conffile, no question is asked (as it
should be).

I created some test packages (all attached) to demonstrate the issue.

test-pkg-c
----------

Installs /etc/test-pkg-c/config-file as conffile.

test-pkg-d
----------

Diverts /etc/test-pkg-c/config-file to /etc/test-pkg-c/config-file.diverted
and installs a different /etc/test-pkg-c/config-file (also) as conffile.

test-pkg-e
----------

Diverts /etc/test-pkg-c/config-file to /etc/test-pkg-c/config-file.diverted
and installs a different /etc/test-pkg-c/config-file, but not marking it as
conffile.

Demonstration
-------------------------

First we install test-pkg-c:

# dpkg -i test-pkg-c_0.1_all.deb
Selecting previously deselected package test-pkg-c.
(Reading database ... 15719 files and directories currently installed.)
Unpacking test-pkg-c (from test-pkg-c_0.1_all.deb) ...
Setting up test-pkg-c (0.1) ...
# ls -l /etc/test-pkg-c
total 4
-rw-r--r-- 1 root root 9 2008-12-10 11:04 config-file

Okay, everything seems fine. Next, test-pkg-e:

# dpkg -i test-pkg-e_0.1_all.deb
Selecting previously deselected package test-pkg-e.
(Reading database ... 15724 files and directories currently installed.)
Unpacking test-pkg-e (from test-pkg-e_0.1_all.deb) ...
Adding `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-e'
Setting up test-pkg-e (0.1) ...
# ls -l /etc/test-pkg-c
total 8
-rw-r--r-- 1 root root 19 2008-12-10 11:35 config-file
-rw-r--r-- 1 root root  9 2008-12-10 11:04 config-file.diverted
# dpkg-divert --list /etc/test-pkg-c/config-file
diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-e

Okay, seems fine. As said before, if the overwriting file is not marked as
conffile, no question is asked. Let's remove/purge test-pkg-e:

# dpkg -P test-pkg-e
(Reading database ... 15727 files and directories currently installed.)
Removing test-pkg-e ...
Removing `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-e'
Purging configuration files for test-pkg-e ...
# ls -l /etc/test-pkg-c
total 4
-rw-r--r-- 1 root root 9 2008-12-10 11:04 config-file
# dpkg-divert --list /etc/test-pkg-c/config-file
#

Okay, package was nicely removed, nothing left and original file restored.
Now we're going to install test-pkg-d:

# dpkg -i test-pkg-d_0.1_all.deb
Selecting previously deselected package test-pkg-d.
(Reading database ... 15724 files and directories currently installed.)
Unpacking test-pkg-d (from test-pkg-d_0.1_all.deb) ...
Adding `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d'
Setting up test-pkg-d (0.1) ...

Configuration file `/etc/test-pkg-c/config-file'
 ==> Deleted (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : background this process to examine the situation
 The default action is to keep your current version.
*** config-file (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/test-pkg-c/config-file ...
# ls -l /etc/test-pkg-c
total 8
-rw-r--r-- 1 root root 13 2008-12-10 11:07 config-file
-rw-r--r-- 1 root root  9 2008-12-10 11:04 config-file.diverted
# dpkg-divert --list /etc/test-pkg-c/config-file
diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d

Everything went alright, but as said before the question is pointless here.
Even more strange: if chosen to do a diff (D), dpkg diffs the new file
against an empty file, which doesn't make sense. Chosing N instead of Y
will leave an inconsistent system, we will demonstrate this later, first we
need to remove/purge test-pkg-d:

# dpkg -P test-pkg-d
(Reading database ... 15727 files and directories currently installed.)
Removing test-pkg-d ...
Purging configuration files for test-pkg-d ...
Removing `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d'
# ls -l /etc/test-pkg-c
total 4
-rw-r--r-- 1 root root 9 2008-12-10 11:04 config-file
# dpkg-divert --list /etc/test-pkg-c/config-file
#

Okay, package was nicely removed, nothing left and original file restored.
Now we're going to install test-pkg-d and answer N:

# dpkg -i test-pkg-d_0.1_all.deb
Selecting previously deselected package test-pkg-d.
(Reading database ... 15724 files and directories currently installed.)
Unpacking test-pkg-d (from test-pkg-d_0.1_all.deb) ...
Adding `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d'
Setting up test-pkg-d (0.1) ...

Configuration file `/etc/test-pkg-c/config-file'
 ==> Deleted (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : background this process to examine the situation
 The default action is to keep your current version.
*** config-file (Y/I/N/O/D/Z) [default=N] ? N
# ls -l /etc/test-pkg-c
total 8
-rw-r--r-- 1 root root  9 2008-12-10 11:04 config-file.diverted
-rw-r--r-- 1 root root 13 2008-12-10 11:07 config-file.dpkg-dist
# dpkg-divert --list /etc/test-pkg-c/config-file
diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d

As you see, there's no /etc/test-pkg-c/config-file anymore. Not cool. This
pleads even more for preventing this question. Let's see what happens if we
remove/purge test-pkg-d:

# dpkg -P test-pkg-d
(Reading database ... 15727 files and directories currently installed.)
Removing test-pkg-d ...
Purging configuration files for test-pkg-d ...
Removing `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d'
# ls -l /etc/test-pkg-c
total 4
-rw-r--r-- 1 root root 9 2008-12-10 11:04 config-file
# dpkg-divert --list /etc/test-pkg-c/config-file
#

Surprisingly, the removal of test-pkg-d restores the original file and
removes the config-file.dpkg-dist. So at least we are able to fix the
state of the system if the wrong answer was chosen. To end the
demonstration will remove test-pkg-c as well:

# dpkg -P test-pkg-c
(Reading database ... 15723 files and directories currently installed.)
Removing test-pkg-c ...
Purging configuration files for test-pkg-c ...
# ls -l /etc/test-pkg-c
ls: cannot access /etc/test-pkg-c: No such file or directory
# dpkg-divert --list /etc/test-pkg-c/config-file
#

Works perfectly, of course.

As requested in this bug post, I provided the dpkg debug output of the
installation of test-pkg-d (answering Y) as well.

I hope this helps to resolve the issue.


Attachment: test-packages.tar.gz
Description: GNU Zip compressed data

Attachment: dpkg-debug_2008-12-10.txt.gz
Description: GNU Zip compressed data

Reply via email to