[Pkg-electronics-devel] Bug#1062803: libsigrok4t64: improper /usr-move mitigation

Helmut Grohne helmut at subdivi.de
Sat Feb 3 11:11:10 GMT 2024


Package: libsigrok4t64
Version: 0.5.2-5.1~exp1
Severity: serious
Tags: patch
User: helmutg at debian.org
Usertags: dep17p1
Control: affects -1 + libsigrok4
X-Debbugs-Cc: vorlon at debian.org

Hi Steve,

this NMU also introduces a DEP17 P1 problem. To make matters worse, the
affected file already is being mitigated for DEP17 P7. Mitigating both
problems at the same time is "interesting". I think I found a solution
and it passes piuparts. As I do not want to interfere with the time64
transition, I am not uploading this and merely attaching a patch.

For P7 mitigations, the diversion must not be owned by the causing
package. Hence these diversions are assigned to usr-is-merged and must
remain there. We're also dealing with the problem that these mitigations
now have to move from libsigrok4 to libsigrok4t64. I'd appreciate
another pair of eyeballs double checking this.

Helmut
-------------- next part --------------
diff --minimal -Nru libsigrok-0.5.2/debian/changelog libsigrok-0.5.2/debian/changelog
--- libsigrok-0.5.2/debian/changelog	2024-02-02 08:36:33.000000000 +0100
+++ libsigrok-0.5.2/debian/changelog	2024-02-03 11:50:34.000000000 +0100
@@ -1,3 +1,10 @@
+libsigrok (0.5.2-5.1~exp1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Extend /usr-move mitigation for package rename. (Closes: #-1)
+
+ -- Helmut Grohne <helmut at subdivi.de>  Sat, 03 Feb 2024 11:50:34 +0100
+
 libsigrok (0.5.2-5.1~exp1) experimental; urgency=medium
 
   * Non-maintainer upload.
diff --minimal -Nru libsigrok-0.5.2/debian/libsigrok4t64.postinst libsigrok-0.5.2/debian/libsigrok4t64.postinst
--- libsigrok-0.5.2/debian/libsigrok4t64.postinst	2024-02-02 08:36:33.000000000 +0100
+++ libsigrok-0.5.2/debian/libsigrok4t64.postinst	1970-01-01 01:00:00.000000000 +0100
@@ -1,23 +0,0 @@
-#!/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/rules.d/60-libsigrok.rules.usr-is-merged \
-        --remove /lib/udev/rules.d/60-libsigrok.rules
-    dpkg-divert --package usr-is-merged --no-rename \
-        --divert /lib/udev/rules.d/61-libsigrok-plugdev.rules.usr-is-merged \
-        --remove /lib/udev/rules.d/61-libsigrok-plugdev.rules
-    dpkg-divert --package usr-is-merged --no-rename \
-        --divert /lib/udev/rules.d/61-libsigrok-uaccess.rules.usr-is-merged \
-        --remove /lib/udev/rules.d/61-libsigrok-uaccess.rules
-fi
-# end-remove-after
-
-#DEBHELPER#
-
-exit 0
diff --minimal -Nru libsigrok-0.5.2/debian/libsigrok4t64.postrm libsigrok-0.5.2/debian/libsigrok4t64.postrm
--- libsigrok-0.5.2/debian/libsigrok4t64.postrm	2024-02-02 08:36:33.000000000 +0100
+++ libsigrok-0.5.2/debian/libsigrok4t64.postrm	2024-02-03 11:50:16.000000000 +0100
@@ -1,9 +1,7 @@
 #!/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 \
@@ -16,7 +14,6 @@
         --divert /lib/udev/rules.d/61-libsigrok-uaccess.rules.usr-is-merged \
         --remove /lib/udev/rules.d/61-libsigrok-uaccess.rules
 fi
-# end-remove-after
 
 #DEBHELPER#
 
diff --minimal -Nru libsigrok-0.5.2/debian/libsigrok4t64.preinst libsigrok-0.5.2/debian/libsigrok4t64.preinst
--- libsigrok-0.5.2/debian/libsigrok4t64.preinst	2024-02-02 08:36:33.000000000 +0100
+++ libsigrok-0.5.2/debian/libsigrok4t64.preinst	2024-02-03 11:50:34.000000000 +0100
@@ -1,10 +1,10 @@
 #!/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
+# These protect both from M-A:same shared file loss and from loss due to moving
+# from libsigrok4 to libsigrok4t64.
+if [ "$1" = upgrade ] || [ "$1" = install ]; then
     dpkg-divert --package usr-is-merged --no-rename \
         --divert /lib/udev/rules.d/60-libsigrok.rules.usr-is-merged \
         --add /lib/udev/rules.d/60-libsigrok.rules
@@ -14,8 +14,11 @@
     dpkg-divert --package usr-is-merged --no-rename \
         --divert /lib/udev/rules.d/61-libsigrok-uaccess.rules.usr-is-merged \
         --add /lib/udev/rules.d/61-libsigrok-uaccess.rules
+
+    # These diversions are supposed to be taken over from libsigrok4, which
+    # will attempt to remove them in postinst and postrm. Prevent that.
+    rm -f /var/lib/dpkg/libsigrok4:*.postinst /var/lib/dpkg/libsigrok4:*.postrm
 fi
-# end-remove-after
 
 #DEBHELPER#
 


More information about the Pkg-electronics-devel mailing list