yum 3.0.1 generates redundant progress output while installing
packages: rpm calls back into yum for every file it touches, which
causes yum to refresh the progress indicator even if neither the
percentage nor the hash marks have changed.

When installing a package with ~23000 files (a complete kernel source
tree), yum writes about 1.8 Mbytes to stdout. This is pretty painful
when SSHing over a slow link or even when working locally using a
fancy terminal like the xemacs shell.

The attached patch suppresses redundant progress updates but does not
otherwise alter any functionality. With the patch, yum generates only
3756 bytes to stdout when installing the same package, a savings of
approximately 100% :-)

Feedback welcome.

--Ed
--- ../../usr/share/yum-cli/callback.py	2006-11-10 08:59:10.000000000 -0800
+++ /usr/share/yum-cli/callback.py	2007-01-25 13:16:08.000000000 -0800
@@ -33,6 +33,7 @@
         self.total_removed = 0
         self.mark = "#"
         self.marks = 27
+        self.lastmsg = None
         self.logger = logging.getLogger('yum.filelogging.RPMInstallCallback')
 
         self.myprocess = { TS_UPDATE : 'Updating', 
@@ -106,6 +107,7 @@
             pass
 
         elif what == rpm.RPMCALLBACK_INST_OPEN_FILE:
+            self.lastmsg = None
             hdr = None
             if h is not None:
                 hdr, rpmloc = h
@@ -157,9 +159,11 @@
                         msg = fmt % ('Repackage', h)
                         if bytes == total:
                             msg = msg + "\n"
-                            
-                        sys.stdout.write(msg)
-                        sys.stdout.flush()
+
+                        if msg != self.lastmsg:
+                            sys.stdout.write(msg)
+                            sys.stdout.flush()
+                            self.lastmsg = msg
                 else:
                     hdr, rpmloc = h
                     if total == 0:
@@ -179,8 +183,10 @@
                             if self.output and (sys.stdout.isatty() or bytes == total):
                                 fmt = self._makefmt(percent)
                                 msg = fmt % (process, hdr['name'])
-                                sys.stdout.write(msg)
-                                sys.stdout.flush()
+                                if msg != self.lastmsg:
+                                    sys.stdout.write(msg)
+                                    sys.stdout.flush()
+                                    self.lastmsg = msg
                                 if bytes == total:
                                     print " "
 
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to