Followup-For: Bug #905177 Hi,
the situation is a bit tricky for upgrades that had bind9 from squeeze
or older installed: there /etc/bind/named.conf.options was a conffile.
Which is something dpkg remembers (with an outdated md5sum). The content
of the file have been updated over time s.t. we don't need to handle
md5sums in the preinst depending on whether the first installation
happened in lenny or wheezy :-)
We cannot move the file aside in case dpkg knows it as a conffile:
Setting up bind9 (1:9.11.5.P4+dfsg-1) ...
Installing new version of config file /etc/apparmor.d/usr.sbin.named ...
Installing new version of config file /etc/bind/bind.keys ...
Installing new version of config file /etc/bind/named.conf.default-zones ...
Configuration file '/etc/bind/named.conf.options'
==> 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 : start a shell to examine the situation
The default action is to keep your current version.
*** named.conf.options (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing
package bind9 (--configure):
end of file on stdin at conffile prompt
Processing triggers for systemd (241-1) ...
Processing triggers for libc-bin (2.28-8) ...
Errors were encountered while processing:
bind9
That's from squeeze -> wheezy -> jessie -> stretch -> buster. Notice the
"Deleted (by you or by a script) since installation."
My proposed solution you can find in the attached patch. It passes my
tests starting from lenny as well as starting from wheezy.
I create a backup as .dpkg-old and then edit the file in-place to match
the content of the yet-to-be-installed-conffile. In that case dpkg does
not see a content conflicht, does not prompt about it and updates the
md5sum of the conffile to the new version in its database.
Andreas
>From a714533a17508d0f5f2084c15a42801458f7eeeb Mon Sep 17 00:00:00 2001 From: Andreas Beckmann <[email protected]> Date: Sun, 24 Mar 2019 22:51:53 +0100 Subject: [PATCH] bind9.preinst: cope with ancient conffile named.conf.options In squeeze and earlier /etc/bind/named.conf.options was a conffile. On upgrades from such a version dpkg will remember it as an obsolete conffile with an outdated md5sum. Therefore we must not move it aside in this case (which dpkg would take as a deletion by the local admin), instead we edit it in place to match the to-be-installed version in order to avoid prompting and make dpkg update the md5sum. Closes: #905177 --- debian/bind9.preinst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/debian/bind9.preinst b/debian/bind9.preinst index 464ffc627..66b06abaa 100644 --- a/debian/bind9.preinst +++ b/debian/bind9.preinst @@ -20,7 +20,15 @@ case "$1" in theirs=$(md5sum /etc/bind/named.conf.options | sed 's/ .*$//') mine=56919cbc0d819c9a303a8bdeb306b5f1 if [ "$mine" = "$theirs" ]; then - mv /etc/bind/named.conf.options /etc/bind/named.conf.options.dpkg-old + if [ -n "$(dpkg-query -f '${Conffiles}' -W bind9 | grep /etc/bind/named.conf.options)" ]; then + # dpkg knows /etc/bind/named.conf.options as a conffile (from squeeze or older) + # cannot move the outdated file aside to avoid dpkg noticing deleted-by-local-admin + # therefore edit it in place to make it match the to-be-installed version + cp -p /etc/bind/named.conf.options /etc/bind/named.conf.options.dpkg-old + sed -i '26{/^$/d}; 23{/auth-nxdomain no;/d}' /etc/bind/named.conf.options + else + mv /etc/bind/named.conf.options /etc/bind/named.conf.options.dpkg-old + fi fi fi ;; -- 2.11.0
bind9_1:9.11.5.P4+dfsg-1.log.gz
Description: application/gzip

