Bug#1036569: openvswitch-common: leaves alternatives after purge: /usr/sbin/ovs-vswitchd -> /etc/alternatives/ovs-vswitchd

2023-06-30 Thread Andreas Beckmann
Followup-For: Bug #1036569
Control: tag -1 patch

find attached a patch to reintroduce openvswictch-common.postinst which
clean up the forgotten alternative


Andreas
>From 082e6d3c316f32e203debc285fa1c20ba460c3b1 Mon Sep 17 00:00:00 2001
From: Andreas Beckmann 
Date: Fri, 30 Jun 2023 14:19:38 +0200
Subject: [PATCH] Remove obsolete alternative dating back to bullseye

Closes: #1036569
---
 debian/openvswitch-common.postinst | 10 ++
 1 file changed, 10 insertions(+)
 create mode 100644 debian/openvswitch-common.postinst

diff --git a/debian/openvswitch-common.postinst 
b/debian/openvswitch-common.postinst
new file mode 100644
index 0..3949d46df
--- /dev/null
+++ b/debian/openvswitch-common.postinst
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+if [ "$1" = "configure" ] && dpkg --compare-versions "$2" lt-nl "3.1.2-2~"
+then
+   # remove obsolete alternative from bullseye
+   update-alternatives --remove ovs-vswitchd 
/usr/lib/openvswitch-common/ovs-vswitchd
+fi
+
+#DEBHELPER#
-- 
2.20.1



Bug#1036569: openvswitch-common: leaves alternatives after purge: /usr/sbin/ovs-vswitchd -> /etc/alternatives/ovs-vswitchd

2023-05-22 Thread Andreas Beckmann
Package: openvswitch-common
Version: 3.1.0-2
Severity: important
User: debian...@lists.debian.org
Usertags: piuparts

Hi,

during a test with piuparts I noticed your package left unowned files on
the system after purge, which is a violation of policy 6.8:

https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#details-of-removal-and-or-configuration-purging

The leftover files are actually alternatives that were installed by the
package but have not been properly removed.

While there is ongoing discussion how to remove alternatives correctly
(see https://bugs.debian.org/71621 for details) the following strategy
should work for regular cases:
* 'postinst configure' always installs the alternative
* 'prerm remove' removes the alternative
* 'postrm remove' and 'postrm disappear' remove the alternative
In all other cases a maintainer script is invoked (e.g. upgrade,
deconfigure) the alternatives are not modified to preserve user
configuration.
Removing the alternative in 'prerm remove' avoids having a dangling link
once the actual file gets removed, but 'prerm remove' is not called in
all cases (e.g. unpacked but not configured packages or disappearing
packages) so the postrm must remove the alternative again
(update-alternatives gracefully handles removal of non-existing
alternatives).

Note that the arguments for adding and removing alternatives differ, for
removal it's 'update-alternatives --remove  '.

Filing this as important as having a piuparts clean archive is a release
goal since lenny.

>From the attached log (scroll to the bottom...):

1m7.2s INFO: Warning: Package purging left files on system:
  /etc/alternatives/libofproto.so -> 
/usr/lib/openvswitch-common/libofproto-2.15.so.0.0.0not owned
  /etc/alternatives/libopenvswitch.so -> 
/usr/lib/openvswitch-common/libopenvswitch-2.15.so.0.0.0not owned
  /etc/alternatives/ovs-vswitchd -> /usr/lib/openvswitch-common/ovs-vswitchd
 not owned
  /usr/sbin/ovs-vswitchd -> /etc/alternatives/ovs-vswitchd   not owned

This looks like some obsolete alternatives not getting removed during
upgrades from bullseye to bookworm.


cheers,

Andreas


openvswitch-common_3.1.0-2.log.gz
Description: application/gzip