Control: tags -1 + patch

On Tue, Nov 07, 2023 at 09:35:54PM +0100, Helmut Grohne wrote:
> On Tue, Nov 07, 2023 at 08:11:19PM +0000, Luca Boccassi wrote:
> > On Tue, 7 Nov 2023 at 20:04, Francois Marier <franc...@debian.org> wrote:
> > > What's the best way to coordinate a fix for this?
> > >
> > > I assume that we shouldn't upload a new molly-guard packages until the 
> > > files
> > > have actually moved in the systemd package?
> > >
> > > Should we wait until systemd is in unstable to push a new molly-guard out?
> 
> If the workaround is correctly implemented, it can go to unstable
> directly. Note that it's not simply changing the diversions from the old
> location to the new location. The workaround is duplicating them. At
> that point, you can no longer use --rename and have to do the renaming
> by hand. I'm happy to review a patch. For opensysusers I sent one, but I
> haven't gotten down to molly-guard yet.

Proposed patch attached.

Helmut
diff --minimal -Nru molly-guard-0.7.2/Makefile molly-guard-0.7.2+nmu1/Makefile
--- molly-guard-0.7.2/Makefile  2019-07-09 18:50:53.000000000 +0200
+++ molly-guard-0.7.2+nmu1/Makefile     2023-11-08 14:16:52.000000000 +0100
@@ -1,7 +1,7 @@
 PREFIX?=/usr
 cfgdir?=/etc/molly-guard
-libdir?=/lib
-sbindir?=/sbin
+libdir?=$(PREFIX)/lib
+sbindir?=$(PREFIX)/sbin
 REALPATH?=$(libdir)/molly-guard
 
 all: molly-guard.8 shutdown
diff --minimal -Nru molly-guard-0.7.2/debian/changelog 
molly-guard-0.7.2+nmu1/debian/changelog
--- molly-guard-0.7.2/debian/changelog  2019-07-09 18:50:53.000000000 +0200
+++ molly-guard-0.7.2+nmu1/debian/changelog     2023-11-08 14:47:40.000000000 
+0100
@@ -1,3 +1,11 @@
+molly-guard (0.7.2+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Duplicate aliased diversions for DEP17 M18. (Closes: #-1)
+  * Move all files to /usr.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Wed, 08 Nov 2023 14:47:40 +0100
+
 molly-guard (0.7.2) unstable; urgency=medium
 
   * upload to unstable
diff --minimal -Nru molly-guard-0.7.2/debian/molly-guard.lintian-overrides 
molly-guard-0.7.2+nmu1/debian/molly-guard.lintian-overrides
--- molly-guard-0.7.2/debian/molly-guard.lintian-overrides      2019-07-09 
18:50:53.000000000 +0200
+++ molly-guard-0.7.2+nmu1/debian/molly-guard.lintian-overrides 2023-11-08 
14:47:40.000000000 +0100
@@ -1,9 +1,9 @@
-molly-guard: binary-without-manpage sbin/coldreboot
-molly-guard: binary-without-manpage sbin/halt
-molly-guard: binary-without-manpage sbin/pm-hibernate
-molly-guard: binary-without-manpage sbin/pm-suspend
-molly-guard: binary-without-manpage sbin/pm-suspend-hybrid
-molly-guard: binary-without-manpage sbin/poweroff
-molly-guard: binary-without-manpage sbin/reboot
-molly-guard: binary-without-manpage sbin/shutdown
-molly-guard: diversion-for-unknown-file usr/sbin/* preinst:29
+molly-guard: no-manual-page [usr/sbin/coldreboot]
+molly-guard: no-manual-page [usr/sbin/halt]
+molly-guard: no-manual-page [usr/sbin/pm-hibernate]
+molly-guard: no-manual-page [usr/sbin/pm-suspend]
+molly-guard: no-manual-page [usr/sbin/pm-suspend-hybrid]
+molly-guard: no-manual-page [usr/sbin/poweroff]
+molly-guard: no-manual-page [usr/sbin/reboot]
+molly-guard: no-manual-page [usr/sbin/shutdown]
+molly-guard: diversion-for-unknown-file sbin/* preinst:*
diff --minimal -Nru molly-guard-0.7.2/debian/molly-guard.postrm 
molly-guard-0.7.2+nmu1/debian/molly-guard.postrm
--- molly-guard-0.7.2/debian/molly-guard.postrm 2019-07-09 18:50:53.000000000 
+0200
+++ molly-guard-0.7.2+nmu1/debian/molly-guard.postrm    2023-11-08 
14:47:40.000000000 +0100
@@ -20,7 +20,11 @@
 case "$1" in
     remove)
         for cmd in halt poweroff reboot shutdown coldreboot ; do
-            dpkg-divert --package molly-guard --rename --remove /sbin/$cmd
+            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
         done
 
         for cmd in pm-hibernate pm-suspend pm-suspend-hybrid ; do
diff --minimal -Nru molly-guard-0.7.2/debian/molly-guard.preinst 
molly-guard-0.7.2+nmu1/debian/molly-guard.preinst
--- molly-guard-0.7.2/debian/molly-guard.preinst        2019-07-09 
18:50:53.000000000 +0200
+++ molly-guard-0.7.2+nmu1/debian/molly-guard.preinst   2023-11-08 
14:47:40.000000000 +0100
@@ -14,7 +14,7 @@
 
 case "$1" in
     install|upgrade)
-        mkdir -p /lib/molly-guard
+        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
@@ -22,11 +22,27 @@
         done
 
         for cmd in halt poweroff reboot shutdown coldreboot ; do
-            dpkg-divert --package molly-guard --divert /lib/molly-guard/$cmd 
--rename /sbin/$cmd
+            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.
+            if test "$1" = install; then
+                if test -e "/usr/sbin/$cmd"; then
+                    mv "/usr/sbin/$cmd" "/usr/lib/molly-guard/$cmd"
+                fi
+                if test -e "/sbin/$cmd"; then
+                    mv "/sbin/$cmd" "/usr/lib/molly-guard/$cmd"
+                fi
+            fi
         done
 
         for cmd in pm-hibernate pm-suspend pm-suspend-hybrid ; do
-            dpkg-divert --package molly-guard --divert /lib/molly-guard/$cmd 
--rename /usr/sbin/$cmd
+            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"
+            else
+                dpkg-divert --package molly-guard --divert 
"/usr/lib/molly-guard/$cmd" --rename "/usr/sbin/$cmd"
+            fi
         done
     ;;
 

Reply via email to