Bug#1006655: [PATCH] Implement rm_conffile_if_unmodified (2/5)
From
Josh Triplett@1:229/2 to
All on Tue May 28 23:40:01 2024
[continued from previous message]
const char *endent, *endfn, *hashstart;
char *newptr;
int c, namelen, hashlen;
- bool obsolete, remove_on_upgrade;
+ bool obsolete, remove_on_upgrade, remove_if_unmodified;
c= *value++;
if (c == '\n') continue;
@@ -381,6 +382,12 @@ f_conffiles(struct pkginfo *pkg, struct pkgbin *pkgbin,
conffvalue_lastword(value, endfn, endent, &hashstart, &hashlen, &endfn,
ps);
+ remove_if_unmodified = (hashlen == sizeof(remove_if_unmodified_str) - 1 && + memcmp(hashstart, remove_if_unmodified_str, hashlen) == 0);
+ if (remove_if_unmodified)
+ conffvalue_lastword(value, endfn, endent, &hashstart, &hashlen, &endfn, + ps);
+
obsolete= (hashlen == sizeof(obsolete_str)-1 &&
memcmp(hashstart, obsolete_str, hashlen) == 0);
if (obsolete)
@@ -405,6 +412,7 @@ f_conffiles(struct pkginfo *pkg, struct pkgbin *pkgbin,
newlink->hash= newptr;
newlink->obsolete= obsolete;
newlink->remove_on_upgrade = remove_on_upgrade;
+ newlink->remove_if_unmodified = remove_if_unmodified;
newlink->next =NULL;
*lastp= newlink;
lastp= &newlink->next;
diff --git a/lib/dpkg/fsys.h b/lib/dpkg/fsys.h
index ede5cdff8..63256e10a 100644
--- a/lib/dpkg/fsys.h
+++ b/lib/dpkg/fsys.h
@@ -85,6 +85,8 @@ enum DPKG_ATTR_ENUM_FLAGS fsys_namenode_flags {
FNNF_FILTERED = DPKG_BIT(9),
/** Conffile removal requested by upgrade. */
FNNF_RM_CONFF_ON_UPGRADE = DPKG_BIT(10),
+ /** Conffile removal requested by upgrade if unmodified. */
+ FNNF_RM_CONFF_IF_UNMODIFIED = DPKG_BIT(11),
};
/**
diff --git a/man/deb-conffiles.pod b/man/deb-conffiles.pod
index e3a57b189..353c8e9f8 100644
--- a/man/deb-conffiles.pod
+++ b/man/deb-conffiles.pod
@@ -39,11 +39,25 @@ not accepted.
Files without a flag should exist in the binary package, otherwise L<dpkg(1)>
will ignore them.
-There is currently only one flag supported, B<remove-on-upgrade>, to mark -that a conffile needs to be removed on the next upgrade (since dpkg 1.20.6). +There are currently two flags supported:
+
+=over
+
+=item B<remove-on-upgrade> (since dpkg 1.20.6)
+
+to mark that a conffile needs to be removed on the next upgrade.
These files must not exist in the binar