Package: bfh-container Version: 20211009-31 Severity: serious Tags: patch User: [email protected] Usertags: dep17
Hi, I'm sorry to tell you that I still got the duplicated diversions wrong. The full story is at https://lists.debian.org/debian-devel/2025/01/msg00125.html. In any case, I managed to reproduce bad scenarios for bfh-container. The main issue here is that --rename may be specified for the canonicalized diversion when the actual file is aliased and then it may be renamed in a bad way making dpkg unhappy. Additionally, the order of diversions was wrong as diversion targets must not overlap. Adding the canonicalized diversion was failing as the aliased diversion had not yet changed its target. I'm attaching a patch that fixes both and also attaching my test cases (that are all passing now). I added more comments such that the mess becomes easier to understand by my future self and others. Helmut
diff --minimal -Nru bfh-metapackages-20211009/debian/bfh-container.preinst
bfh-metapackages-20211009/debian/bfh-container.preinst
--- bfh-metapackages-20211009/debian/bfh-container.preinst 2024-12-12
18:01:16.000000000 +0100
+++ bfh-metapackages-20211009/debian/bfh-container.preinst 2025-01-13
12:35:28.000000000 +0100
@@ -8,26 +8,22 @@
for FILE in halt poweroff reboot shutdown coldreboot
do
- TRUENAME_USR="$(dpkg-divert --truename
"/usr/sbin/${FILE}")"
- TRUENAME_ALIAS="$(dpkg-divert --truename
"/sbin/${FILE}")"
- RENAME_FLAG="--no-rename"
- if [ "${TRUENAME_USR}" = "/usr/sbin/${FILE}" ]
+ # DEP17 M18 duplicated diversion, can be removed after
trixie.
+ RENAME_FLAG="--no-rename"
+ TRUENAME_ALIAS="$(dpkg-divert --truename
"/sbin/${FILE}")"
+ if [ "${TRUENAME_ALIAS}" = "/sbin/${FILE}" ]
then
- if [ "${TRUENAME_ALIAS}" = "/sbin/${FILE}" ]
+ # Rename if the file is presently installed as
aliased.
+ if dpkg -S "/sbin/${FILE}" 2>/dev/null | grep
-q "^[^ ]*: /sbin/${FILE}$"
then
RENAME_FLAG="--rename"
fi
- dpkg-divert --package bfh-container --quiet
--add "${RENAME_FLAG}" --divert "/usr/lib/container/divert/${FILE}.orig"
"/usr/sbin/${FILE}"
- fi
-
- # DEP17 M18 duplicated diversion, can be removed after
trixie.
- if [ "${TRUENAME_ALIAS}" = "/sbin/${FILE}" ]
- then
dpkg-divert --package bfh-container --quiet
--add "${RENAME_FLAG}" --divert
"/lib/container/divert/${FILE}.orig.usr-is-merged" "/sbin/${FILE}"
elif [ "${TRUENAME_ALIAS}" !=
"/lib/container/divert/${FILE}.orig.usr-is-merged" ]
then
+ # Change the diversion target. Must be done
before adding the canonicalized diversion below.
dpkg-divert --package bfh-container --quiet
--remove --no-rename "/sbin/${FILE}"
dpkg-divert --package bfh-container --quiet
--add --no-rename --divert "/lib/container/divert/${FILE}.orig.usr-is-merged"
"/sbin/${FILE}"
@@ -36,6 +32,10 @@
mv "${TRUENAME_ALIAS}"
"/lib/container/divert/${FILE}.orig.usr-is-merged"
fi
fi
+
+ # We may rename unconditionally here. If the file is
aliased, the earlier --rename will have moved it.
+ dpkg-divert --package bfh-container --quiet --add
--rename --divert "/usr/lib/container/divert/${FILE}.orig" "/usr/sbin/${FILE}"
+
done
for FILE in pm-hibernate pm-suspend pm-suspend-hybrid
@@ -44,6 +44,7 @@
if [ "${TRUENAME_USR}" =
"/lib/container/divert/${FILE}.orig" ]
then
+ # Update diversion target from aliased to
canonical.
dpkg-divert --package bfh-container --quiet
--remove --no-rename "/usr/sbin/${FILE}"
dpkg-divert --package bfh-container --quiet
--add --no-rename --divert "/usr/lib/container/divert/${FILE}.orig"
"/usr/sbin/${FILE}"
else
diff --minimal -Nru bfh-metapackages-20211009/debian/changelog
bfh-metapackages-20211009/debian/changelog
--- bfh-metapackages-20211009/debian/changelog 2024-12-12 18:07:25.000000000
+0100
+++ bfh-metapackages-20211009/debian/changelog 2025-01-13 12:35:28.000000000
+0100
@@ -1,3 +1,10 @@
+bfh-metapackages (20211009-31.1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Fix --rename flags on duplicated diversions (DEP17 M18, Closes: #-1)
+
+ -- Helmut Grohne <[email protected]> Mon, 13 Jan 2025 12:35:28 +0100
+
bfh-metapackages (20211009-31) sid; urgency=medium
* Uploading to sid.
test-bfh.sh
Description: Bourne shell script

