• Bug#1006655: [PATCH] Implement rm_conffile_if_unmodified (4/5)

    From Josh Triplett@1:229/2 to All on Tue May 28 23:40:01 2024
    [continued from previous message]

    - if (conff->obsolete || conff->remove_on_upgrade)
    + if (conff->obsolete ||
    + conff->remove_on_upgrade ||
    + conff->remove_if_unmodified)
    continue;
    if (strncmp(file->name, conff->name, namelen) == 0 &&
    strlen(conff->name) > namelen && conff->name[namelen] == '/') {
    diff --git a/src/main/unpack.c b/src/main/unpack.c
    index 20d30c6c8..0708b437a 100644
    --- a/src/main/unpack.c
    +++ b/src/main/unpack.c
    @@ -386,6 +386,9 @@ deb_parse_conffiles(const struct pkginfo *pkg, const char *control_conffiles,
    if (strcmp(flag, "remove-on-upgrade") == 0) {
    confflags |= FNNF_RM_CONFF_ON_UPGRADE;
    confflags &= ~FNNF_NEW_CONFF;
    + } else if (strcmp(flag, "remove-if-unmodified") == 0) {
    + confflags |= FNNF_RM_CONFF_IF_UNMODIFIED;
    + confflags &= ~FNNF_NEW_CONFF;
    } else {
    if (c_isspace(flag[0]))
    warning(_("line with conffile filename '%s' has leading white spaces"),
    @@ -657,15 +660,17 @@ pkg_remove_conffile_on_upgrade(struct pkginfo *pkg, struct fsys_namenode *nameno
    }

    /* Otherwise, preserve the modified conffile. */
    - varbuf_rollback(&cdrext_state);
    - varbuf_add_str(&cdrext, DPKGOLDEXT);
    + if (namenode->flags & FNNF_RM_CONFF_ON_UPGRADE) {
    + varbuf_rollback(&cdrext_state);
    + varbuf_add_str(&cdrext, DPKGOLDEXT);

    - printf(_("Obsolete conffile '%s' has been modified by y