Looks like the systemctl links are gone but not the pm-utils ones

Helmut Grohne helmut at subdivi.de
Fri Nov 24 23:50:26 GMT 2023


Hi,

On Mon, Nov 20, 2023 at 04:05:31PM +0100, Helmut Grohne wrote:
> I've attached the prospective change to this mail. It passes piuparts
> and it passes my own test cases. I definitely think it should be
> reviewed before uploaded. One thing I already see for possible
> improvement is that since we declare Breaks against all providers of
> /sbin/halt, this diversion does not actually have to persist beyond
> postinst. Once molly-guard is configured, we know that any broken
> package is no longer installed nor unpacked. A molly-guard.postinst
> could remove the diversion of /sbin/halt to
> /sbin/halt.no-molly-guard.usr-is-merged. Then we are only left with one
> diversion per command which also makes this a lot less confusing.

I have implemented the removal of unnecessary diversions in postinst and
attach an updated patch. It still passes all of the tests from my
earlier mail and also piuparts.

> More fundamentally, I'll also have to rework the DEP17 section M18 as it
> doesn't work the way it is currently pictured.

I updated it.

Hope this is good. Would you mind uploading it to experimental?

Helmut
-------------- next part --------------
diff -Nru molly-guard-0.8.1/debian/changelog molly-guard-0.8.1+nmu1/debian/changelog
--- molly-guard-0.8.1/debian/changelog	2023-11-11 23:02:55.000000000 +0100
+++ molly-guard-0.8.1+nmu1/debian/changelog	2023-11-20 09:18:25.000000000 +0100
@@ -1,3 +1,10 @@
+molly-guard (0.8.1+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Attempt to fix the /usr-merge fallout. (Closes: #1056279)
+
+ -- Helmut Grohne <helmut at subdivi.de>  Mon, 20 Nov 2023 09:18:25 +0100
+
 molly-guard (0.8.1) unstable; urgency=medium
 
   * Upload to unstable
diff -Nru molly-guard-0.8.1/debian/control molly-guard-0.8.1+nmu1/debian/control
--- molly-guard-0.8.1/debian/control	2023-11-11 23:02:55.000000000 +0100
+++ molly-guard-0.8.1+nmu1/debian/control	2023-11-20 09:18:25.000000000 +0100
@@ -23,6 +23,7 @@
           systemd,
           sysvinit,
           upstart
+Breaks: systemd-sysv (<< 255), sysvinit-core, finit-sysv, runit-init
 Description: protects machines from accidental shutdowns/reboots
  The package installs a shell script that overrides the existing
  shutdown/reboot/halt/poweroff/coldreboot/pm-hibernate/pm-suspend* commands
diff -Nru molly-guard-0.8.1/debian/molly-guard.postinst molly-guard-0.8.1+nmu1/debian/molly-guard.postinst
--- molly-guard-0.8.1/debian/molly-guard.postinst	1970-01-01 01:00:00.000000000 +0100
+++ molly-guard-0.8.1+nmu1/debian/molly-guard.postinst	2023-11-20 09:18:25.000000000 +0100
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+
+# begin-remove-after: trixie
+if test "$1" = configure; then
+    for cmd in halt poweroff reboot shutdown coldreboot; do
+        dpkg-divert --package molly-guard --no-rename --remove "/sbin/$cmd"
+    done
+fi
+# end-remove-after
+
+#DEBHELPER#
+
+exit 0
diff -Nru molly-guard-0.8.1/debian/molly-guard.postrm molly-guard-0.8.1+nmu1/debian/molly-guard.postrm
--- molly-guard-0.8.1/debian/molly-guard.postrm	2023-11-11 23:02:55.000000000 +0100
+++ molly-guard-0.8.1+nmu1/debian/molly-guard.postrm	2023-11-20 09:18:25.000000000 +0100
@@ -16,18 +16,19 @@
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 
-
+# begin-remove-after: trixie
 case "$1" in
-    remove)
-        for cmd in halt poweroff reboot shutdown coldreboot ; do
-            dpkg-divert --package molly-guard --no-rename --remove /sbin/$cmd
-            dpkg-divert --package molly-guard --no-rename --remove "/usr/sbin/$cmd"
-	    if test -e "/usr/lib/molly-guard/$cmd"; then
-                mv "/usr/lib/molly-guard/$cmd" "/usr/sbin/$cmd"
-            fi
+    abort-install|abort-upgrade|failed-upgrade)
+        for cmd in halt poweroff shutdown coldreboot; do
+            dpkg-divert --package molly-guard --rename --remove "/sbin/$cmd"
         done
+    ;;
+esac
+# end-remove-after
 
-        for cmd in pm-hibernate pm-suspend pm-suspend-hybrid ; do
+case "$1" in
+    remove)
+        for cmd in halt poweroff reboot shutdown coldreboot pm-hibernate pm-suspend pm-suspend-hybrid ; do
             dpkg-divert --package molly-guard --rename --remove /usr/sbin/$cmd
         done
 
diff -Nru molly-guard-0.8.1/debian/molly-guard.preinst molly-guard-0.8.1+nmu1/debian/molly-guard.preinst
--- molly-guard-0.8.1/debian/molly-guard.preinst	2023-11-11 23:02:55.000000000 +0100
+++ molly-guard-0.8.1+nmu1/debian/molly-guard.preinst	2023-11-20 09:18:25.000000000 +0100
@@ -14,35 +14,55 @@
 
 case "$1" in
     install|upgrade)
-        mkdir -p /usr/lib/molly-guard
-
         # Cleanup erroneous diversions added in 0.6.0
         for cmd in pm-hibernate pm-suspend pm-suspend-hybrid ; do
             dpkg-divert --package molly-guard --rename --remove /sbin/$cmd
         done
 
         for cmd in halt poweroff reboot shutdown coldreboot ; do
-            dpkg-divert --package molly-guard --divert "/usr/lib/molly-guard/$cmd" --no-rename --add "/usr/sbin/$cmd"
-            # DEP17 M18 duplicated diversion. Can be removed after trixie.
-            dpkg-divert --package molly-guard --divert "/lib/molly-guard/$cmd" --no-rename --add "/sbin/$cmd"
-	    # Avoid --rename as long as we need duplicated diversions.
+            # begin-remove-after: trixie
+            # Remove possible pre-/usr-merge diversion
+            dpkg-divert --package molly-guard --divert "/lib/molly-guard/$cmd" --no-rename --remove  "/sbin/$cmd"
+            if test "$(dpkg-divert --truename "/usr/sbin/$cmd")" = "/usr/lib/molly-guard/$cmd"; then
+                dpkg-divert --package molly-guard --divert "/usr/lib/molly-guard/$cmd" --no-rename --remove "/usr/sbin/$cmd"
+                if test -e "/usr/lib/molly-guard/$cmd"; then
+                    mv "/usr/lib/molly-guard/$cmd" "/usr/sbin/$cmd.no-molly-guard"
+                fi
+                if test -e "/lib/molly-guard/$cmd"; then
+                    mv "/lib/molly-guard/$cmd" "/usr/sbin/$cmd.no-molly-guard.usr-is-merged"
+                fi
+            fi
+            # end-remove-after
+            # DEP17 M18 duplicated diversion. Can be --removed after trixie.
+            dpkg-divert --package molly-guard --divert "/sbin/$cmd.no-molly-guard.usr-is-merged" --no-rename --add "/sbin/$cmd"
+            # Add post-/usr-merge diversion meant to stay.
+            dpkg-divert --package molly-guard --divert "/usr/sbin/$cmd.no-molly-guard" --no-rename --add "/usr/sbin/$cmd"
+            # Avoid --rename as long as we need duplicated diversions.
             if test "$1" = install; then
                 if test -e "/usr/sbin/$cmd"; then
-                    mv "/usr/sbin/$cmd" "/usr/lib/molly-guard/$cmd"
+                    mv "/usr/sbin/$cmd" "/usr/sbin/$cmd.no-molly-guard"
                 fi
                 if test -e "/sbin/$cmd"; then
-                    mv "/sbin/$cmd" "/usr/lib/molly-guard/$cmd"
+                    mv "/sbin/$cmd" "/sbin/$cmd.no-molly-guard.usr-is-merged"
                 fi
             fi
         done
 
         for cmd in pm-hibernate pm-suspend pm-suspend-hybrid ; do
-            if test "$(dpkg-divert --truename "/usr/sbin/$cmd")" = "/lib/molly-guard/$cmd"; then
-                dpkg-divert --package molly-guard --divert "/lib/molly-guard/$cmd" --no-rename --remove "/usr/sbin/$cmd"
-                dpkg-divert --package molly-guard --divert "/usr/lib/molly-guard/$cmd" --no-rename --add "/usr/sbin/$cmd"
+            # begin-remove-after: trixie
+            truename="$(dpkg-divert --truename "/usr/sbin/$cmd")"
+            if test "${truename#/usr}" = "/lib/molly-guard/$cmd"; then
+                dpkg-divert --package molly-guard --divert "$truename" --no-rename --remove "/usr/sbin/$cmd"
+                dpkg-divert --package molly-guard --divert "/usr/sbin/$cmd.no-molly-guard" --no-rename --add "/usr/sbin/$cmd"
+                if test -e "/usr/lib/molly-guard/$cmd" -o -h "/usr/lib/molly-guard/$cmd"; then
+                     mv "/usr/lib/molly-guard/$cmd" "/usr/sbin/$cmd.no-molly-guard"
+                fi
             else
-                dpkg-divert --package molly-guard --divert "/usr/lib/molly-guard/$cmd" --rename "/usr/sbin/$cmd"
+            # end-remove-after: trixie
+                dpkg-divert --package molly-guard --divert "/usr/sbin/$cmd.no-molly-guard" --rename "/usr/sbin/$cmd"
+            # begin-remove-after: trixie
             fi
+            # end-remove-after: trixie
         done
     ;;
 
diff -Nru molly-guard-0.8.1/shutdown.in molly-guard-0.8.1+nmu1/shutdown.in
--- molly-guard-0.8.1/shutdown.in	2023-11-11 23:02:55.000000000 +0100
+++ molly-guard-0.8.1+nmu1/shutdown.in	2023-11-20 09:18:25.000000000 +0100
@@ -13,11 +13,10 @@
 SCRIPTSDIR="@cfgdir@/run.d"
 
 CMD="${0##*/}"
-EXEC="@REALPATH@/$CMD"
 
 case "$CMD" in
   halt|reboot|shutdown|poweroff|coldreboot|pm-hibernate|pm-suspend|pm-suspend-hybrid)
-    if [ ! -f $EXEC ]; then
+    if ! EXEC=$(command -v "$CMD.no-molly-guard"); then
       echo "E: not a regular file: $EXEC" >&2
       exit 4
     fi


More information about the Pkg-systemd-maintainers mailing list