Control: tag -1 patch

Hi Sebastien,

thanks for the analysis!

On Fri, 8 May 2020 11:16:09 +0200 Sebastien Bacher <seb...@debian.org>
wrote:
> There are a few possible options there now that I can see
> - restore the .postinst 'test -e /etc/lirc/$f || cp /etc/lirc/${f}.dist
> /etc/lirc/$f || :' calls
But we want to get rid of that mess!

> - reverse the logic, and ship the conffile with the normal name but move
Yep, we want that

> old existing pre 0.10 ones to .old or something in the preinst

let's just delete them if
* dpkg does not know about them, and
* they match a known shipped version

> - restore the 'prompt for conffile change even when no change' bug, it's
> not ideal but better than just segfaulting and failing installation

and fall back to prompting only if the file has likely been modified

That is best explained in more detail as patches ;-)

Since I'm the one most likely to file more prompting bugs, I've
implemented that and quickly tested it in a chroot for the most
interesting upgrade paths.

I'm offering to NMU that.

If someone else is going to upload the fix, please don't bunde it with
stuff not appropriate for buster.
Note that we need this fix in buster, too, and to avoid doing fany
things with the version numbers for the upgrade paths, we should rebuild
0.10.1-6.2 as 0.10.1-6.2~deb10u1 (with the python3.8 patch disabled, the
linux 4.18 patch should be OK for buster).

Andreas
>From 3a77ccb1a928329f2a3540a300fcf55cb1d7e32e Mon Sep 17 00:00:00 2001
From: Andreas Beckmann <a...@debian.org>
Date: Sat, 9 May 2020 23:06:55 +0200
Subject: [PATCH 1/3] Revert "Revert "Do not install conffiles in a dummy
 location""

---
 debian/changelog        | 8 ++++++++
 debian/lirc.maintscript | 4 ++++
 debian/rules            | 4 ----
 3 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 debian/lirc.maintscript

diff --git a/debian/changelog b/debian/changelog
index f30a620..9d47679 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+lirc (0.10.1-6.2) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Revert "Revert "Do not install conffiles in a dummy location""
+    (0.10.1-5.2).
+
+ -- Andreas Beckmann <a...@debian.org>  Sat, 09 May 2020 23:05:43 +0200
+
 lirc (0.10.1-6.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff --git a/debian/lirc.maintscript b/debian/lirc.maintscript
new file mode 100644
index 0000000..f26aaa2
--- /dev/null
+++ b/debian/lirc.maintscript
@@ -0,0 +1,4 @@
+mv_conffile /etc/lirc/lircd.conf.dist /etc/lirc/lircd.conf 0.10.1-5.1~
+mv_conffile /etc/lirc/lircmd.conf.dist /etc/lirc/lircmd.conf 0.10.1-5.1~
+mv_conffile /etc/lirc/irexec.lircrc.dist /etc/lirc/irexec.lircrc 0.10.1-5.1~
+mv_conffile /etc/lirc/lirc_options.conf.dist /etc/lirc/lirc_options.conf 0.10.1-5.1~
diff --git a/debian/rules b/debian/rules
index fc2b39d..84787ef 100755
--- a/debian/rules
+++ b/debian/rules
@@ -42,10 +42,6 @@ ifeq ($(DEB_BUILD_ARCH_OS), linux)
 endif
 	# Temporary postinstall 0.9.4 script.
 	cp debian/lirc-old2new debian/tmp/usr/share/lirc
-	# Don't overwrite existing config files.
-	for f in lircd.conf lircmd.conf irexec.lircrc lirc_options.conf; do \
-	    mv debian/tmp/etc/lirc/$$f debian/tmp/etc/lirc/$$f.dist; \
-	done
 
 override_dh_auto_test:
 ifneq "nocheck"  "$(findstring nocheck,$(DEB_BUILD_OPTIONS))"
-- 
2.20.1

>From 0da18e85905411d0c6b2b6fda93a6689809aa493 Mon Sep 17 00:00:00 2001
From: Andreas Beckmann <a...@debian.org>
Date: Sat, 9 May 2020 23:16:03 +0200
Subject: [PATCH 2/3] rm_conffile /etc/lirc/*.dist, don't mv_conffile

---
 debian/changelog        | 3 +++
 debian/lirc.maintscript | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9d47679..b4af7b6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,9 @@ lirc (0.10.1-6.2) UNRELEASED; urgency=medium
   * Non-maintainer upload.
   * Revert "Revert "Do not install conffiles in a dummy location""
     (0.10.1-5.2).
+  * d/lirc.maintscript: rm_conffile /etc/lirc/*.dist because they are most
+    likely unmodified, don't mv_conffile them to =~ s/\.dist// to avoid
+    clashes with possibly modified files.
 
  -- Andreas Beckmann <a...@debian.org>  Sat, 09 May 2020 23:05:43 +0200
 
diff --git a/debian/lirc.maintscript b/debian/lirc.maintscript
index f26aaa2..d00d265 100644
--- a/debian/lirc.maintscript
+++ b/debian/lirc.maintscript
@@ -1,4 +1,4 @@
-mv_conffile /etc/lirc/lircd.conf.dist /etc/lirc/lircd.conf 0.10.1-5.1~
-mv_conffile /etc/lirc/lircmd.conf.dist /etc/lirc/lircmd.conf 0.10.1-5.1~
-mv_conffile /etc/lirc/irexec.lircrc.dist /etc/lirc/irexec.lircrc 0.10.1-5.1~
-mv_conffile /etc/lirc/lirc_options.conf.dist /etc/lirc/lirc_options.conf 0.10.1-5.1~
+rm_conffile /etc/lirc/lircd.conf.dist 0.10.1-6.2~
+rm_conffile /etc/lirc/lircmd.conf.dist 0.10.1-6.2~
+rm_conffile /etc/lirc/irexec.lircrc.dist 0.10.1-6.2~
+rm_conffile /etc/lirc/lirc_options.conf.dist 0.10.1-6.2~
-- 
2.20.1

>From f4ba5e27e9c9a79832b6413afa0822263126c51e Mon Sep 17 00:00:00 2001
From: Andreas Beckmann <a...@debian.org>
Date: Sat, 9 May 2020 23:44:23 +0200
Subject: [PATCH 3/3] lirc.preinst: clean up unmodified configuration files
 before replacing them with conffiles

---
 debian/changelog    |  4 +++-
 debian/lirc.preinst | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 debian/lirc.preinst

diff --git a/debian/changelog b/debian/changelog
index b4af7b6..cb26241 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,10 +2,12 @@ lirc (0.10.1-6.2) UNRELEASED; urgency=medium
 
   * Non-maintainer upload.
   * Revert "Revert "Do not install conffiles in a dummy location""
-    (0.10.1-5.2).
+    (0.10.1-5.2).  (Closes: #932779)
   * d/lirc.maintscript: rm_conffile /etc/lirc/*.dist because they are most
     likely unmodified, don't mv_conffile them to =~ s/\.dist// to avoid
     clashes with possibly modified files.
+  * d/lirc.preinst: Remove unmodified configuration files that are unknown to
+    dpkg to avoid prompting when replacing them with conffiles.
 
  -- Andreas Beckmann <a...@debian.org>  Sat, 09 May 2020 23:05:43 +0200
 
diff --git a/debian/lirc.preinst b/debian/lirc.preinst
new file mode 100644
index 0000000..53a5c31
--- /dev/null
+++ b/debian/lirc.preinst
@@ -0,0 +1,40 @@
+#!/bin/sh
+set -e
+
+md5sums_shipped="
+92df549c82f58ea28b605e5045984e04  /etc/lirc/irexec.lircrc
+d2664e84bab19f7f36628d1de3f273dd  /etc/lirc/lirc_options.conf #stretch
+6599e8ea08b5f4bf19409666cae22441  /etc/lirc/lirc_options.conf #buster
+810233d6f1bb15b64468beb95e4c670e  /etc/lirc/lircd.conf
+eca53bdc53bd5edc63cf06a4cff16b0d  /etc/lirc/lircmd.conf
+"
+
+if dpkg --compare-versions "$2" lt-nl "0.10.1-6.2~"
+then
+	# * configuration files unknown to dpkg and identical to a known
+	#   shipped version can be deleted to avoid prompting when replacing
+	#   them with proper conffiles
+	# * we must not remove conffiles still known to dpkg as "(obsolete)",
+	#   otherwise dpkg will remember their deletion
+	conffiles="$(dpkg-query -f '${Conffiles}' -W lirc)"
+	for conffile in /etc/lirc/lircd.conf /etc/lirc/lircmd.conf /etc/lirc/irexec.lircrc /etc/lirc/lirc_options.conf
+	do
+		test -f "$conffile" || continue
+		if [ -n "$(echo "$conffiles" | grep " $conffile ")" ]
+		then
+			echo "Keeping conffile $conffile which is known to dpkg."
+			continue
+		fi
+		case "$md5sums_shipped" in
+			*"$(md5sum "$conffile")"*)
+				echo "Removing unmodified configuration file $conffile which is unknown to dpkg."
+				rm "$conffile"
+				;;
+			*)
+				echo "Keeping modified configuration file $conffile which is unknown to dpkg."
+				;;
+		esac
+	done
+fi
+
+#DEBHELPER#
-- 
2.20.1

Reply via email to