From 9b5d4e0f4fabc671259d2b21fc0ed6b9b5488e97 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sun, 6 Jul 2008 11:44:17 -0700 Subject: [PATCH] Also handle the abort-upgrade postrm case When the diversion was added in a particular version of a package, an aborted upgrade to a newer version with the diversion from an older version without the diversion should remove the diversion when rolling back to the older version. Add the necessary postrm code and explanation. Thanks to Raphael Hertzog for the review. --- policy.sgml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/policy.sgml b/policy.sgml index 127c6a2..5975d37 100644 --- a/policy.sgml +++ b/policy.sgml @@ -10577,10 +10577,21 @@ install-info --quiet --remove /usr/share/info/foobar.info dpkg-divert --package smailwrapper --remove --rename \ --divert /usr/sbin/smail.real /usr/sbin/smail fi - The postrm should not remove the diversion on upgrades - both because there's no reason to remove the diversion only to - immediately re-add it and since the postrm of the old package is - run after unpacking so the removal of the diversion will fail. + If the diversion was added at a particular version, the + postrm should also handle the failure case of upgrading from an + older version (unless the older version is so old that direct + upgrades are no longer supported): + + if [ abort-upgrade = "$1" ] && dpkg --compare-versions "$2" lt 1.0-2; then + dpkg-divert --package smailwrapper --remove --rename \ + --divert /usr/sbin/smail.real /usr/sbin/smail + fi + where 1.02-2 is the version at which the + diversion was first added to the package. The postrm should not + remove the diversion on upgrades both because there's no reason to + remove the diversion only to immediately re-add it and since the + postrm of the old package is run after unpacking so the removal of + the diversion will fail.

-- 2.39.5