Package: dpkg
Version: 1.15.3.1
Severity: wishlist
Tags: patch

When the output of package installations are logged to a file, the 
progress counter updates while reading the database are distracting.

This is especially the case in Debian Installer where multiple package 
installations are started and all are logged to the syslog. For an 
example of the result, see the syslog attached in [1].

Another example is buildd logs, for example [2].

The attached patch adds an option --no-db-progress that allows to suppress 
the progress updates in such situations.

If you'd like any changes (maybe a more generic name for the option?) or 
if I've forgotten anything, then please let me know.

The patch is based on current git:
commit 173652e75fad004c42906608fe0ff4556be29b19
Author: Helge Kreutzmann <deb...@helgefjell.de>
Date:   Thu Jul 30 18:38:57 2009 +0200
    Fix errors in a paragraph in the German man page translation.

[1]http://bugs.debian.org/538344#15 (see lines starting at 00:26:43)
[2]https://buildd.debian.org/fetch.cgi?pkg=clock-setup&arch=i386&ver=0.99&stamp=1249206304&file=log&as=raw
diff --git a/man/dpkg.1 b/man/dpkg.1
index 665519f..e925a2e 100644
--- a/man/dpkg.1
+++ b/man/dpkg.1
@@ -556,6 +556,10 @@ may leave packages in the improper \fBtriggers\-awaited\fP and
 .TP
 \fB\-\-triggers\fP
 Cancels a previous \fB\-\-no\-triggers\fP.
+.TP
+\fB\-\-no-db-progress\fP
+Do not report progress while reading database. This can be useful when
+logging the output of dpkg to a file.
 .
 .SH FILES
 .TP
diff --git a/src/filesdb.c b/src/filesdb.c
index da8cde2..dc0bfad 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -219,21 +219,25 @@ void ensure_allinstfiles_available(void) {
     int max = countpackages();
 
     saidread=1;
-    progress_init(&progress, _("(Reading database ... "), max);
+    if (!f_nodbprogr)
+      progress_init(&progress, _("(Reading database ... "), max);
+    else
+      printf(_("(Reading database ... "));
   }
 
   it= iterpkgstart();
   while ((pkg = iterpkgnext(it)) != NULL) {
     ensure_packagefiles_available(pkg);
 
-    if (saidread == 1)
+    if (!f_nodbprogr && saidread == 1)
       progress_step(&progress);
   }
   iterpkgend(it);
   allpackagesdone= 1;
 
   if (saidread==1) {
-    progress_done(&progress);
+    if (!f_nodbprogr)
+      progress_done(&progress);
     printf(_("%d files and directories currently installed.)\n"),nfiles);
     saidread=2;
   }
diff --git a/src/main.c b/src/main.c
index ad9b4b8..6a5fed8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -136,6 +136,7 @@ usage(void)
 "  --no-force-...|--refuse-...\n"
 "                             Stop when problems encountered.\n"
 "  --abort-after <n>          Abort after encountering <n> errors.\n"
+"  --no-db-progress           Do not report progress while reading database.\n"
 "\n"), ADMINDIR) < 0) werr ("stdout");
 
   if (fprintf (stdout, _(
@@ -164,7 +165,7 @@ const char printforhelp[]= N_(
 
 const struct cmdinfo *cipaction = NULL;
 int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
-int f_autodeconf=0, f_nodebsig=0;
+int f_autodeconf=0, f_nodebsig=0, f_nodbprogr=0;
 int f_triggers = 0;
 unsigned long f_debug=0;
 /* Change fc_overwrite to 1 to enable force-overwrite by default */
@@ -442,6 +443,7 @@ static const struct cmdinfo cmdinfos[]= {
   { "selected-only",     'O', 0, &f_alsoselect, NULL,      NULL,    0 },
   { "triggers",           0,  0, &f_triggers,   NULL,      NULL,    1 },
   { "no-triggers",        0,  0, &f_triggers,   NULL,      NULL,   -1 },
+  { "no-db-progress",     0,  0, &f_nodbprogr,  NULL,      NULL,    1 },
   /* FIXME: Remove ('N') sometime. */
   { "no-also-select",    'N', 0, &f_alsoselect, NULL,      NULL,    0 },
   { "skip-same-version", 'E', 0, &f_skipsame,   NULL,      NULL,    1 },
diff --git a/src/main.h b/src/main.h
index cd8c7b6..d235ed4 100644
--- a/src/main.h
+++ b/src/main.h
@@ -84,7 +84,7 @@ extern const char *const statusstrings[];
 
 extern const struct cmdinfo *cipaction;
 extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
-extern int f_autodeconf, f_nodebsig;
+extern int f_autodeconf, f_nodebsig, f_nodbprogr;
 extern int f_triggers;
 extern unsigned long f_debug;
 extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
diff --git a/src/query.c b/src/query.c
index 48eacc0..2d06446 100644
--- a/src/query.c
+++ b/src/query.c
@@ -492,7 +492,7 @@ Use --license for copyright license and lack of warranty (GNU GPL).");
 
 const struct cmdinfo *cipaction = NULL;
 int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
-int f_autodeconf=0, f_nodebsig=0;
+int f_autodeconf=0, f_nodebsig=0, f_nodbprogr=0;
 unsigned long f_debug=0;
 /* Change fc_overwrite to 1 to enable force-overwrite by default */
 int fc_hold=0;

Reply via email to