Package: dash
Version: 0.5.12-9
Severity: serious
Justification: all dep17 bugs are have become rc since 2024-08-06
User: helm...@debian.org
Usertags: dep17p3
X-Debbugs-Cc: Thorsten Glaser <t...@mirbsd.de>

Hi Andrew and Thorsten,

in my conversion of dash I slightly neglected the fact that /bin/sh is a
relatively common thing to divert. It was and still is planned to add a
note to the release-notes asking administrators to review their local
diversions before proceeding the upgrade, but diversions of /bin/sh are
quite delicate, so it is better to be safe here.

The upgrade of dash may render a diversion of /bin/sh by an
administrator ineffective and thus revert from a prior choice of e.g.
lksh from the mksh package back to dash. This is not resolvable on the
dash side, but dash may support here by aborting the upgrade and giving
the administrator guidance on how to resolve the situation.

I am attaching a patch that adds a dash.preinst checking for affected
upgrade scenarios and aborting those that require manual changes. I also
attach a script for testing various upgrade scenarios and ran it locally
to verify the correctness of the proposed change.

Note that the rc-severity merely indicates that this needs to be fixed
for trixie but does not otherwise imply urgency.

Helmut
diff --minimal -Nru dash-0.5.12/debian/changelog dash-0.5.12/debian/changelog
--- dash-0.5.12/debian/changelog        2024-06-05 10:08:31.000000000 +0200
+++ dash-0.5.12/debian/changelog        2024-08-07 11:13:50.000000000 +0200
@@ -1,3 +1,10 @@
+dash (0.5.12-9.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Notify users about ineffective diversions of /bin/sh (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Wed, 07 Aug 2024 11:13:50 +0200
+
 dash (0.5.12-9) unstable; urgency=medium
 
   [ Helmut Grohne ]
diff --minimal -Nru dash-0.5.12/debian/dash.preinst 
dash-0.5.12/debian/dash.preinst
--- dash-0.5.12/debian/dash.preinst     1970-01-01 01:00:00.000000000 +0100
+++ dash-0.5.12/debian/dash.preinst     2024-08-07 11:13:50.000000000 +0200
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = upgrade ] && dpkg --compare-versions "$2" lt 0.5.12-9~; then
+       # Upgrading from pre-/usr-move DEP17
+       truename=$(dpkg-divert --truename /bin/sh)
+       if [ "$truename" != /bin/sh ] &&
+               [ "$(dpkg-divert --listpackage /bin/sh)_$truename" != 
"dash_/bin/sh.distrib" ] &&
+               [ "$(dpkg-divert --truename /usr/bin/sh)" = "/usr/bin/sh" ]; 
then
+               # There is a diversion of /bin/sh and it is not our own
+               # diversion to /bin/sh.distrib that will be removed in
+               # postinst and there is no matching diversion of /usr/bin/sh.
+               cat <<EOF
+A diversion of /bin/sh was detected with the following details:
+
+$(dpkg-divert --list /bin/sh)
+
+Since this update of dash moves /bin/sh to /usr/bin/sh in the dpkg database,
+the aforementioned diversion will no longer apply. No diversion of the new
+location /usr/bin/sh has been found.
+
+Please either remove the diversion of /bin/sh or create another diversion for
+/usr/bin/sh to retry the upgrade. After successful upgrade, the diversion of
+/bin/sh is no longer required.
+
+Aborting upgrade.
+EOF
+               exit 1
+       fi
+fi
+
+#DEBHELPER#
+
+exit 0

Attachment: test.sh
Description: Bourne shell script

Reply via email to