Explorar o código

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 <rfrancoise@debian.org>
Guillem Jover %!s(int64=17) %!d(string=hai) anos
pai
achega
69c9250259
Modificáronse 3 ficheiros con 24 adicións e 3 borrados
  1. 9 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 13 3
      src/filesdb.c

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+2009-02-26  Romain Francoise <rfrancoise@debian.org>,
+            Guillem Jover  <guillem@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 <rfrancoise@debian.org>,
             Guillem Jover  <guillem@debian.org>
 

+ 2 - 0
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

+ 13 - 3
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;
   }