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

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=3c4272bb90086c05436b6e4b7a19fc11780c2afb

commit 3c4272bb90086c05436b6e4b7a19fc11780c2afb
Author: Guillem Jover <[email protected]>
AuthorDate: Fri Oct 22 01:11:42 2010 +0200

    Track package status dirtinness
    
    Now that the status changes are abstracted via a setter, which makes
    sure only new changes are recorded, we can also record whether those
    changes happened, so that we avoid unnecessarily logging unchanged
    states.
    
    Closes: #365921
---
 debian/changelog    |  2 ++
 lib/dpkg/dbmodify.c | 14 +++++++++-----
 lib/dpkg/dpkg-db.h  |  3 +++
 lib/dpkg/pkg.c      |  2 ++
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 58308cfdb..80211a553 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -71,6 +71,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
   * Only check required build dependencies for known targets specified with
     dpkg-buildpackage --rules-target option.
     Reported by Johannes Schauer <[email protected]>.
+  * Track package status dirtiness in dpkg to only log and report in status-fd
+    when it has changed, removing duplication in output. Closes: #365921
   * Architecture support:
     - Add support for riscv64 CPU. Closes: #822914
       Thanks to Manuel A. Fernandez Montecelo <[email protected]>
diff --git a/lib/dpkg/dbmodify.c b/lib/dpkg/dbmodify.c
index 4e1457429..7351f3d00 100644
--- a/lib/dpkg/dbmodify.c
+++ b/lib/dpkg/dbmodify.c
@@ -442,11 +442,15 @@ void modstatdb_note(struct pkginfo *pkg) {
     pkg->trigaw.head = pkg->trigaw.tail = NULL;
   }
 
-  log_message("status %s %s %s", pkg_status_name(pkg),
-              pkg_name(pkg, pnaw_always),
-             versiondescribe(&pkg->installed.version, vdew_nonambig));
-  statusfd_send("status: %s: %s", pkg_name(pkg, pnaw_nonambig),
-                pkg_status_name(pkg));
+  if (pkg->status_dirty) {
+    log_message("status %s %s %s", pkg_status_name(pkg),
+                pkg_name(pkg, pnaw_always),
+                versiondescribe(&pkg->installed.version, vdew_nonambig));
+    statusfd_send("status: %s: %s", pkg_name(pkg, pnaw_nonambig),
+                  pkg_status_name(pkg));
+
+    pkg->status_dirty = false;
+  }
 
   if (cstatus >= msdbrw_write)
     modstatdb_note_core(pkg);
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 56b4b5c39..2152ba26d 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -216,6 +216,9 @@ struct pkginfo {
   /* ->pend == this, non-NULL for us when Triggers-Pending. */
   struct trigaw *othertrigaw_head;
   struct trigpend *trigpend_head;
+
+  /* The status has changed, it needs to be logged. */
+  bool status_dirty;
 };
 
 /**
diff --git a/lib/dpkg/pkg.c b/lib/dpkg/pkg.c
index 4141fddb2..4f1828bbc 100644
--- a/lib/dpkg/pkg.c
+++ b/lib/dpkg/pkg.c
@@ -47,6 +47,7 @@ pkg_set_status(struct pkginfo *pkg, enum pkgstatus status)
                          pkg->set->name, pkg->set->installed_instances);
 
        pkg->status = status;
+       pkg->status_dirty = true;
 }
 
 /**
@@ -115,6 +116,7 @@ void
 pkg_blank(struct pkginfo *pkg)
 {
        pkg->status = PKG_STAT_NOTINSTALLED;
+       pkg->status_dirty = false;
        pkg->eflag = PKG_EFLAG_OK;
        pkg->want = PKG_WANT_UNKNOWN;
        pkg->priority = PKG_PRIO_UNKNOWN;

-- 
Dpkg.Org's dpkg

Reply via email to