Bug#1056931: libgphoto2-6: Move files into /usr (incl. DEP17 P7 mitigation)

Chris Hofstaedtler zeha at debian.org
Sun Nov 26 20:58:34 GMT 2023


Package: libgphoto2-6
Version: 2.5.31-1
Severity: important
Tags: patch
User: helmutg at debian.org
Usertags: dep17p7
X-Debbugs-Cc: helmutg at debian.org

Dear Maintainer,

libgphoto2-6 contains udev files which are installed to /lib; these
files need to be moved to /usr/lib as part of Debian's usr-merge effort.
Because your package is Multi-Arch: same, an unfortunate corner-case
can occur whereby shared files (such as the udev files) may be
erroneously removed on upgrades (please see DEP17[1] P7: Shared
multiarch file loss).

You will find a patch attached to move the udev files, including the
mitigation for the file loss scenario. Alternatively, you can also use the
salsa merge request I've opened[2].

Please consider applying this patch at your earliest convenience. This
bug will be upgraded to release critical soon, as it blocks the overall
usr-merge effort which is being undertaken for the trixie release.

Note on the patch, esp. the debian/rules part: this tries to be
compatible with dh_installudev changing its default install path, and
then not break on binNMUs. It's ugly, I know.


Many thanks,
Chris

1. https://subdivi.de/~helmut/dep17.html
2. https://salsa.debian.org/debian-phototools-team/libgphoto2/-/merge_requests/6
-------------- next part --------------
>From 314bf4fae75d2823fc4445a84b53aefdd4290dc1 Mon Sep 17 00:00:00 2001
From: Chris Hofstaedtler <zeha at debian.org>
Date: Sun, 26 Nov 2023 21:32:25 +0100
Subject: [PATCH] Move udev files from /lib to /usr/lib

Including protective diversion against Multi-Arch: same file loss scenario
(DEP17 P7 M10).
---
 debian/changelog                      |  8 ++++++++
 debian/libgphoto2-6.lintian-overrides |  6 ++++++
 debian/libgphoto2-6.postinst          | 19 +++++++++++++++++++
 debian/libgphoto2-6.postrm            | 19 +++++++++++++++++++
 debian/libgphoto2-6.preinst           | 18 ++++++++++++++++++
 debian/rules                          |  8 ++++++--
 6 files changed, 76 insertions(+), 2 deletions(-)
 create mode 100644 debian/libgphoto2-6.postinst
 create mode 100644 debian/libgphoto2-6.postrm
 create mode 100644 debian/libgphoto2-6.preinst

diff --git a/debian/changelog b/debian/changelog
index b835d5f57..d666f2a66 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+libgphoto2 (2.5.31-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Move udev files from /lib to /usr/lib, including protective diversion
+    against Multi-Arch: same file loss scenario (DEP17 P7 M10). (Closes: #-1)
+
+ -- Chris Hofstaedtler <zeha at debian.org>  Sun, 26 Nov 2023 21:27:28 +0100
+
 libgphoto2 (2.5.31-1) unstable; urgency=medium
 
   * [33c8d67] The kFreeBSD port has been removed
diff --git a/debian/libgphoto2-6.lintian-overrides b/debian/libgphoto2-6.lintian-overrides
index dd6d57455..e1ae1f513 100644
--- a/debian/libgphoto2-6.lintian-overrides
+++ b/debian/libgphoto2-6.lintian-overrides
@@ -5,3 +5,9 @@ libgphoto2-6: spelling-error-in-binary Optio Option [usr/lib/*/libgphoto2/*/sier
 # strcpy(id->text, "Lumix Wifi") using immediate values.  The letter
 # "H" is part of the next machine instruction, "ifi\0" follows shortly.
 libgphoto2-6: spelling-error-in-binary WiH With [usr/lib/*/libgphoto2/*/lumix.so]
+
+# begin-remove-after: released:forky
+# protective diversion for upgrades of files moved from / to /usr
+libgphoto2-6: diversion-for-unknown-file lib/udev/hwdb.d/20-libgphoto2-6.hwdb [preinst:*]
+libgphoto2-6: diversion-for-unknown-file lib/udev/rules.d/60-libgphoto2-6.rules [preinst:*]
+# end-remove-after
diff --git a/debian/libgphoto2-6.postinst b/debian/libgphoto2-6.postinst
new file mode 100644
index 000000000..d8269e6cb
--- /dev/null
+++ b/debian/libgphoto2-6.postinst
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+set -e
+
+# begin-remove-after: released:forky
+# protective diversion of files moved from / to /usr, to avoid file loss.
+# Only for upgrades.
+if [ "$1" = "configure" ]; then
+    # At this point, the package will have installed the same file in */usr*.
+    dpkg-divert --package usr-is-merged --no-rename \
+        --divert /lib/udev/hwdb.d/20-libgphoto2-6.hwdb.usr-is-merged \
+        --remove /lib/udev/hwdb.d/20-libgphoto2-6.hwdb
+    dpkg-divert --package usr-is-merged --no-rename \
+        --divert /lib/udev/rules.d/60-libgphoto2-6.rules.usr-is-merged \
+        --remove /lib/udev/rules.d/60-libgphoto2-6.rules
+fi
+# end-remove-after
+
+#DEBHELPER#
diff --git a/debian/libgphoto2-6.postrm b/debian/libgphoto2-6.postrm
new file mode 100644
index 000000000..7584525c3
--- /dev/null
+++ b/debian/libgphoto2-6.postrm
@@ -0,0 +1,19 @@
+#!/bin/sh
+set -e
+
+# begin-remove-after: released:forky
+# protective diversion of files moved from / to /usr, to avoid file loss.
+# Only for upgrades.
+if [ "$1" = "remove" ] && [ "$DPKG_MAINTSCRIPT_PACKAGE_REFCOUNT" = "1" ]; then
+    # Cleanup in case package is removed before upgrade is finished (postinst ran).
+    dpkg-divert --package usr-is-merged --no-rename \
+        --divert /lib/udev/hwdb.d/20-libgphoto2-6.hwdb.usr-is-merged \
+        --remove /lib/udev/hwdb.d/20-libgphoto2-6.hwdb
+    dpkg-divert --package usr-is-merged --no-rename \
+        --divert /lib/udev/rules.d/60-libgphoto2-6.rules.usr-is-merged \
+        --remove /lib/udev/rules.d/60-libgphoto2-6.rules
+fi
+# end-remove-after
+
+#DEBHELPER#
+
diff --git a/debian/libgphoto2-6.preinst b/debian/libgphoto2-6.preinst
new file mode 100644
index 000000000..544812f6d
--- /dev/null
+++ b/debian/libgphoto2-6.preinst
@@ -0,0 +1,18 @@
+#!/bin/sh
+set -e
+
+# begin-remove-after: released:forky
+# protective diversion of files moved from / to /usr, to avoid file loss.
+# Only for upgrades.
+if [ "$1" = "upgrade" ]; then
+    dpkg-divert --package usr-is-merged --no-rename \
+        --divert /lib/udev/hwdb.d/20-libgphoto2-6.hwdb.usr-is-merged \
+        --add /lib/udev/hwdb.d/20-libgphoto2-6.hwdb
+    dpkg-divert --package usr-is-merged --no-rename \
+        --divert /lib/udev/rules.d/60-libgphoto2-6.rules.usr-is-merged \
+        --add /lib/udev/rules.d/60-libgphoto2-6.rules
+fi
+# end-remove-after
+
+#DEBHELPER#
+
diff --git a/debian/rules b/debian/rules
index 6c87bd531..28028ff55 100755
--- a/debian/rules
+++ b/debian/rules
@@ -37,10 +37,14 @@ override_dh_installudev:
 	# rm debian/libgphoto2-2/lib/udev/check-ptp-camera
 	# Generate the udev file, get it installed, and clean:
 	CAMLIBS=`ls -d debian/libgphoto2-$(major)/usr/lib/$(DEB_HOST_MULTIARCH)/libgphoto2/2*` ./packaging/generic/print-camera-list udev-rules version 201 mode 0664 group plugdev > debian/libgphoto2-$(major).udev
-	mkdir -p debian/libgphoto2-$(major)/lib/udev/hwdb.d/
-	CAMLIBS=`ls -d debian/libgphoto2-$(major)/usr/lib/$(DEB_HOST_MULTIARCH)/libgphoto2/2*` ./packaging/generic/print-camera-list hwdb > debian/libgphoto2-$(major)/lib/udev/hwdb.d/20-libgphoto2-$(major).hwdb
+	mkdir -p debian/libgphoto2-$(major)/usr/lib/udev/hwdb.d/
+	CAMLIBS=`ls -d debian/libgphoto2-$(major)/usr/lib/$(DEB_HOST_MULTIARCH)/libgphoto2/2*` ./packaging/generic/print-camera-list hwdb > debian/libgphoto2-$(major)/usr/lib/udev/hwdb.d/20-libgphoto2-$(major).hwdb
 	dh_installudev
 	rm debian/libgphoto2-$(major).udev
+	# This will become harmless after dh_installudev changes the default install path.
+	set -e; if test -d debian/libgphoto2-6/lib/udev/rules.d; then mv debian/libgphoto2-6/lib/udev/rules.d debian/libgphoto2-6/usr/lib/udev; fi
+	set -e; if test -d debian/libgphoto2-6/lib/udev; then rmdir debian/libgphoto2-6/lib/udev; fi
+	set -e; if test -d debian/libgphoto2-6/lib; then rmdir debian/libgphoto2-6/lib; fi
 endif
 
 override_dh_fixperms:
-- 
2.39.2



More information about the Pkg-phototools-devel mailing list