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=b11ffedcae076e420b55c28d46c885a7280b92c3

commit b11ffedcae076e420b55c28d46c885a7280b92c3
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Fri May 31 00:31:15 2024 +0200

    dpkg: Refactor conffile disappearing check into a new function
    
    Centralize the check into a function, which will make it easier to
    extend its logic in the future.
    
    Changelog: internal
---
 src/main/archives.c  |  2 +-
 src/main/configure.c |  4 ++--
 src/main/help.c      | 12 +++++++++++-
 src/main/main.h      |  2 ++
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/main/archives.c b/src/main/archives.c
index fa703f048..38a57eb69 100644
--- a/src/main/archives.c
+++ b/src/main/archives.c
@@ -240,7 +240,7 @@ md5hash_prev_conffile(struct pkginfo *pkg, char *oldhash, 
const char *oldname,
                              &otherpkg->configversion) != 0)
       continue;
     for (conff = otherpkg->installed.conffiles; conff; conff = conff->next) {
-      if (conff->obsolete || conff->remove_on_upgrade)
+      if (conffile_is_disappearing(conff))
         continue;
       if (strcmp(conff->name, namenode->name) == 0)
         break;
diff --git a/src/main/configure.c b/src/main/configure.c
index b12b06808..fd760a95c 100644
--- a/src/main/configure.c
+++ b/src/main/configure.c
@@ -356,7 +356,7 @@ deferred_configure_ghost_conffile(struct pkginfo *pkg, 
struct conffile *conff)
 
                for (otherconff = otherpkg->installed.conffiles; otherconff;
                     otherconff = otherconff->next) {
-                       if (otherconff->obsolete || 
otherconff->remove_on_upgrade)
+                       if (conffile_is_disappearing(otherconff))
                                continue;
 
                        /* Check if we need to propagate the new hash from
@@ -652,7 +652,7 @@ deferred_configure(struct pkginfo *pkg)
                 * ‘*.dpkg-new’ no longer exists we assume that we've
                 * already processed this one. */
                for (conff = pkg->installed.conffiles; conff; conff = 
conff->next) {
-                       if (conff->obsolete || conff->remove_on_upgrade)
+                       if (conffile_is_disappearing(conff))
                                continue;
                        deferred_configure_conffile(pkg, conff);
                }
diff --git a/src/main/help.c b/src/main/help.c
index 59e730e1c..fded5f1c3 100644
--- a/src/main/help.c
+++ b/src/main/help.c
@@ -196,7 +196,7 @@ dir_has_conffiles(struct fsys_namenode *file, struct 
pkginfo *pkg)
         pkg_name(pkg, pnaw_always));
   namelen = strlen(file->name);
   for (conff= pkg->installed.conffiles; conff; conff= conff->next) {
-      if (conff->obsolete || conff->remove_on_upgrade)
+      if (conffile_is_disappearing(conff))
         continue;
       if (strncmp(file->name, conff->name, namelen) == 0 &&
           strlen(conff->name) > namelen && conff->name[namelen] == '/') {
@@ -271,6 +271,16 @@ dir_is_used_by_pkg(struct fsys_namenode *file, struct 
pkginfo *pkg,
   return false;
 }
 
+/**
+ * Returns whether the conffile is disappearing, because it is obsolete
+ * or marked for removal on upgrade.
+ */
+bool
+conffile_is_disappearing(struct conffile *conff)
+{
+  return conff->obsolete || conff->remove_on_upgrade;
+}
+
 /**
  * Mark a conffile as obsolete.
  *
diff --git a/src/main/main.h b/src/main/main.h
index f841e8d46..118ad18b5 100644
--- a/src/main/main.h
+++ b/src/main/main.h
@@ -220,6 +220,8 @@ bool ignore_depends(const struct pkginfo *pkg);
 bool force_breaks(struct deppossi *possi);
 bool force_depends(struct deppossi *possi);
 bool force_conflicts(struct deppossi *possi);
+bool
+conffile_is_disappearing(struct conffile *conff);
 void
 conffile_mark_obsolete(struct pkginfo *pkg, struct fsys_namenode *namenode);
 void pkg_conffiles_mark_old(struct pkginfo *pkg);

-- 
Dpkg.Org's dpkg

Reply via email to