This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=17456a341a1c63501e8dbfa6e93c4bf08cb8354e

commit 17456a341a1c63501e8dbfa6e93c4bf08cb8354e
Author: Guillem Jover <[email protected]>
AuthorDate: Fri May 31 00:21:15 2024 +0200

    Merge conffile obsolete and remove-on-upgrade into a single flags member
    
    Use a single flag member, so that it's easier to copy around, and test
    for multiple conditions at once, or delegate the check to a function via
    a bitmask.
    
    Changelog: internal
---
 lib/dpkg/dpkg-db.h  | 12 ++++++++++--
 lib/dpkg/dump.c     |  4 ++--
 lib/dpkg/fields.c   | 20 +++++++++++---------
 src/main/archives.c |  2 +-
 src/main/help.c     |  4 ++--
 src/main/remove.c   |  2 +-
 src/main/unpack.c   |  8 +++++---
 7 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 61f220506..f223d745e 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -77,12 +77,20 @@ struct arbitraryfield {
   const char *value;
 };
 
+enum DPKG_ATTR_ENUM_FLAGS conffile_flags {
+  /** No flags. */
+  CONFFILE_NONE                        = 0,
+  /** The conffile is not shipped anymore in the new package. */
+  CONFFILE_OBSOLETE            = DPKG_BIT(0),
+  /** The conffile is marked to be removed during package upgrade. */
+  CONFFILE_REMOVE_ON_UPGRADE   = DPKG_BIT(1),
+};
+
 struct conffile {
   struct conffile *next;
   const char *name;
   const char *hash;
-  bool obsolete;
-  bool remove_on_upgrade;
+  enum conffile_flags flags;
 };
 
 struct archivedetails {
diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c
index 8a1e30481..1883d3cb7 100644
--- a/lib/dpkg/dump.c
+++ b/lib/dpkg/dump.c
@@ -390,9 +390,9 @@ w_conffiles(struct varbuf *vb,
     varbuf_add_str(vb, i->name);
     varbuf_add_char(vb, ' ');
     varbuf_add_str(vb, i->hash);
-    if (i->obsolete)
+    if (i->flags & CONFFILE_OBSOLETE)
       varbuf_add_str(vb, " obsolete");
-    if (i->remove_on_upgrade)
+    if (i->flags & CONFFILE_REMOVE_ON_UPGRADE)
       varbuf_add_str(vb, " remove-on-upgrade");
   }
   if (flags&fw_printheader)
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index 525dc0a15..efcfb26c6 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -363,7 +363,7 @@ f_conffiles(struct pkginfo *pkg, struct pkgbin *pkgbin,
     const char *endent, *endfn, *hashstart;
     char *newptr;
     int c, namelen, hashlen;
-    bool obsolete, remove_on_upgrade;
+    int flags = CONFFILE_NONE;
 
     c= *value++;
     if (c == '\n') continue;
@@ -375,18 +375,21 @@ f_conffiles(struct pkginfo *pkg, struct pkgbin *pkgbin,
     conffvalue_lastword(value, endent, endent,
                        &hashstart, &hashlen, &endfn,
                         ps);
-    remove_on_upgrade = (hashlen == sizeof(remove_on_upgrade_str) - 1 &&
-                         memcmp(hashstart, remove_on_upgrade_str, hashlen) == 
0);
-    if (remove_on_upgrade)
+    if (hashlen == sizeof(remove_on_upgrade_str) - 1 &&
+        memcmp(hashstart, remove_on_upgrade_str, hashlen) == 0) {
+      flags |= CONFFILE_REMOVE_ON_UPGRADE;
       conffvalue_lastword(value, endfn, endent, &hashstart, &hashlen, &endfn,
                           ps);
+    }
 
-    obsolete= (hashlen == sizeof(obsolete_str)-1 &&
-               memcmp(hashstart, obsolete_str, hashlen) == 0);
-    if (obsolete)
+    if (hashlen == sizeof(obsolete_str) - 1 &&
+        memcmp(hashstart, obsolete_str, hashlen) == 0) {
+      flags |= CONFFILE_OBSOLETE;
       conffvalue_lastword(value, endfn, endent,
                          &hashstart, &hashlen, &endfn,
                          ps);
+    }
+
     newlink = nfmalloc(sizeof(*newlink));
     value = path_skip_slash_dotslash(value);
     namelen= (int)(endfn-value);
@@ -403,8 +406,7 @@ f_conffiles(struct pkginfo *pkg, struct pkgbin *pkgbin,
     memcpy(newptr, hashstart, hashlen);
     newptr[hashlen] = '\0';
     newlink->hash= newptr;
-    newlink->obsolete= obsolete;
-    newlink->remove_on_upgrade = remove_on_upgrade;
+    newlink->flags = flags;
     newlink->next =NULL;
     *lastp= newlink;
     lastp= &newlink->next;
diff --git a/src/main/archives.c b/src/main/archives.c
index 38a57eb69..d7279e1f5 100644
--- a/src/main/archives.c
+++ b/src/main/archives.c
@@ -887,7 +887,7 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti)
         for (conff = otherpkg->installed.conffiles;
              conff;
              conff = conff->next) {
-          if (!conff->obsolete)
+          if (!(conff->flags & CONFFILE_OBSOLETE))
             continue;
           if (strcmp(conff->name, nifd->namenode->name) == 0)
             break;
diff --git a/src/main/help.c b/src/main/help.c
index fded5f1c3..c6abc8a0e 100644
--- a/src/main/help.c
+++ b/src/main/help.c
@@ -278,7 +278,7 @@ dir_is_used_by_pkg(struct fsys_namenode *file, struct 
pkginfo *pkg,
 bool
 conffile_is_disappearing(struct conffile *conff)
 {
-  return conff->obsolete || conff->remove_on_upgrade;
+  return conff->flags & (CONFFILE_OBSOLETE | CONFFILE_REMOVE_ON_UPGRADE);
 }
 
 /**
@@ -296,7 +296,7 @@ conffile_mark_obsolete(struct pkginfo *pkg, struct 
fsys_namenode *namenode)
     if (strcmp(conff->name, namenode->name) == 0) {
       debug(dbg_conff, "marking %s conffile %s as obsolete",
             pkg_name(pkg, pnaw_always), conff->name);
-      conff->obsolete = true;
+      conff->flags |= CONFFILE_OBSOLETE;
       return;
     }
   }
diff --git a/src/main/remove.c b/src/main/remove.c
index 84f320b0c..56514bdd6 100644
--- a/src/main/remove.c
+++ b/src/main/remove.c
@@ -528,7 +528,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo 
*pkg) {
     static struct varbuf fnvb, removevb;
       struct varbuf_state removevb_state;
 
-      if (conff->obsolete) {
+      if (conff->flags & CONFFILE_OBSOLETE) {
        debug(dbg_conffdetail, "removal_bulk conffile obsolete %s",
              conff->name);
       }
diff --git a/src/main/unpack.c b/src/main/unpack.c
index 20d30c6c8..18f25e091 100644
--- a/src/main/unpack.c
+++ b/src/main/unpack.c
@@ -919,9 +919,11 @@ pkg_update_fields(struct pkginfo *pkg, struct 
fsys_namenode_queue *newconffiles)
     newiconff->next = NULL;
     newiconff->name = nfstrsave(cfile->namenode->name);
     newiconff->hash = nfstrsave(cfile->namenode->oldhash);
-    newiconff->obsolete = !!(cfile->namenode->flags & FNNF_OBS_CONFF);
-    newiconff->remove_on_upgrade = !!(
-        cfile->namenode->flags & FNNF_RM_CONFF_ON_UPGRADE);
+    newiconff->flags = CONFFILE_NONE;
+    if (cfile->namenode->flags & FNNF_OBS_CONFF)
+      newiconff->flags |= CONFFILE_OBSOLETE;
+    if (cfile->namenode->flags & FNNF_RM_CONFF_ON_UPGRADE)
+      newiconff->flags |= CONFFILE_REMOVE_ON_UPGRADE;
     *iconffileslastp = newiconff;
     iconffileslastp = &newiconff->next;
   }

-- 
Dpkg.Org's dpkg

Reply via email to