The following commit has been merged in the master branch:
commit 69c9250259d3abb8feb632898e5a495e74a33fc8
Author: Guillem Jover <guil...@debian.org>
Date:   Thu Feb 26 07:35:17 2009 +0200

    dpkg: Add progress reporting while reading the file list database
    
    Reading the files database can take a while on machines with slow disks
    and an empty cache. To make the wait more tolerable try to display a
    progress indicator if the output is a terminal.
    
    Based-on-patch-by: Romain Francoise <rfranco...@debian.org>

diff --git a/ChangeLog b/ChangeLog
index 1c6b4dd..955fa43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
 2009-02-26  Romain Francoise <rfranco...@debian.org>,
             Guillem Jover  <guil...@debian.org>
 
+       * src/filesdb.c: Include 'progress.h'.
+       (ensure_allinstfiles_available): Call progress_init instead of
+       directly printing. Call progress_step if needing to print on each
+       package iteration. And call progress_done if needing to print when
+       finished.
+
+2009-02-26  Romain Francoise <rfranco...@debian.org>,
+            Guillem Jover  <guil...@debian.org>
+
        * lib/Makefile.am (libdpkg_a_SOURCES): Add 'progress.h' and
        'progress.c'.
        * lib/progress.h: New file.
diff --git a/debian/changelog b/debian/changelog
index 09c6bb7..4d76100 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -60,6 +60,8 @@ dpkg (1.15.0) UNRELEASED; urgency=low
   * Document in deb.5 in detail the currently supported format, ar member
     names, types of tar archives and data.tar members.
   * Print correct feature name on «dpkg --assert-*» failures.
+  * Add progress reporting to dpkg while reading the file list database.
+    Based on a patch by Romain Francoise.
 
   [ Raphael Hertzog ]
   * Enhance dpkg-shlibdeps's error message when a library can't be found to
diff --git a/src/filesdb.c b/src/filesdb.c
index e9a1a91..b68b2d2 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -40,6 +40,7 @@
 #include <dpkg-db.h>
 #include <dpkg-priv.h>
 
+#include "progress.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -214,19 +215,28 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
 void ensure_allinstfiles_available(void) {
   struct pkgiterator *it;
   struct pkginfo *pkg;
-    
+  struct progress progress;
+
   if (allpackagesdone) return;
   if (saidread<2) {
+    int max = countpackages();
+
     saidread=1;
-    printf(_("(Reading database ... "));
+    progress_init(&progress, _("(Reading database ... "), max);
   }
+
   it= iterpkgstart();
-  while ((pkg = iterpkgnext(it)) != NULL)
+  while ((pkg = iterpkgnext(it)) != NULL) {
     ensure_packagefiles_available(pkg);
+
+    if (saidread == 1)
+      progress_step(&progress);
+  }
   iterpkgend(it);
   allpackagesdone= 1;
 
   if (saidread==1) {
+    progress_done(&progress);
     printf(_("%d files and directories currently installed.)\n"),nfiles);
     saidread=2;
   }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to