Bug#1006655: [PATCH] Implement rm_conffile_if_unmodified (3/5)
From
Josh Triplett@1:229/2 to
All on Tue May 28 23:40:01 2024
[continued from previous message]
ohshite(_("conffile '%.250s' is not stattable"), conffilename);
- } else if (remove_on_upgrade) {
+ } else if (remove_on_upgrade || remove_if_unmodified) {
ohshit(_("conffile '%s' is present but is requested to be removed"),
conffilename);
} else if (!S_ISREG(controlstab.st_mode)) {
diff --git a/src/dpkg-maintscript-helper.sh b/src/dpkg-maintscript-helper.sh index d799aa8fe..b8b3cb329 100755
--- a/src/dpkg-maintscript-helper.sh
+++ b/src/dpkg-maintscript-helper.sh
@@ -27,6 +27,12 @@
## Functions to remove an obsolete conffile during upgrade
##
rm_conffile() {
+ local IF_UNMODIFIED=
+ if [ "$1" = "--if-unmodified" ]; then
+ IF_UNMODIFIED="$1"
+ shift
+ fi
+
local CONFFILE="$1"
local LASTVERSION="$2"
local PACKAGE="$3"
@@ -63,13 +69,13 @@ rm_conffile() {
preinst)
if [ "$1" = "install" -o "$1" = "upgrade" ] && [ -n "$2" ] &&
dpkg --compare-versions -- "$2" le-nl "$LASTVERSION"; then
- prepare_rm_conffile "$CONFFILE" "$PACKAGE"
+ prepare_rm_conffile $IF_UNMODIFIED "$CONFFILE" "$PACKAGE"
fi
;;
postinst)
if [ "$1" = "configure" ] && [ -n "$2" ] &&
dpkg --compare-versions -- "$2" le-nl "$LASTVERSION"; then
- finish_rm_conffile "$CONFFILE"
+ finish_rm_conffile $IF_UNMODIFIED "$CONFFILE"
fi
;;
postrm)
@@ -81,7 +87,7 @@ rm_conffile() {
if [ "$1" = "abort-install" -o "$1" = "a