Browse Source

dpkg: Do not log nor print duplicate removal action

We print “Removing <package> (<version>)” lines and log remove action
twice when purging a package from frontends, because they usually first
call --remove and then --purge sequentially. When purging a package
which is already in config-files (i.e. it has been removed before),
do not print nor log the remove action.
Guillem Jover 7 years ago
parent
commit
b4e88220c2
2 changed files with 14 additions and 3 deletions
  1. 6 0
      debian/changelog
  2. 8 3
      src/remove.c

+ 6 - 0
debian/changelog

@@ -46,6 +46,12 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
     version of this function we can avoid the dependency on either libstdc++
     or libsup++.
   * Include missing <new> for new and delete operator declarations.
+  * Do not log nor print duplicate dpkg removal action. We print
+    “Removing <package> (<version>)” lines and log remove action twice
+    when purging a package from frontends, because they usually first call
+    --remove and then --purge sequentially. When purging a package which is
+    already in config-files (i.e. it has been removed before), do not print
+    nor log the remove action.
   * Architecture support:
     - Add support for AIX operating system.
   * Portability:

+ 8 - 3
src/remove.c

@@ -171,9 +171,14 @@ void deferred_remove(struct pkginfo *pkg) {
 
   pkg_conffiles_mark_old(pkg);
 
-  printf(_("Removing %s (%s) ...\n"), pkg_name(pkg, pnaw_nonambig),
-         versiondescribe(&pkg->installed.version, vdew_nonambig));
-  log_action("remove", pkg, &pkg->installed);
+  /* Only print and log removal action once. This avoids duplication when
+   * using --remove and --purge in sequence. */
+  if (pkg->status > PKG_STAT_CONFIGFILES) {
+    printf(_("Removing %s (%s) ...\n"), pkg_name(pkg, pnaw_nonambig),
+           versiondescribe(&pkg->installed.version, vdew_nonambig));
+    log_action("remove", pkg, &pkg->installed);
+  }
+
   trig_activate_packageprocessing(pkg);
   if (pkg->status >= PKG_STAT_HALFCONFIGURED) {
     static enum pkgstatus oldpkgstatus;