Hi Guys,

I cobbled together a quick little hack to have a little bit more interactivity 
during the "Updating Portage cache" phase.  It prints out the name of the 
package it is updating, along with the percentage progress.

-jason
--- emerge.orig	2006-01-25 21:36:09.000000000 -0600
+++ emerge	2006-01-25 21:45:08.000000000 -0600
@@ -2647,7 +2647,7 @@
 
 	if os.path.exists(myportdir+"/metadata/cache") and updatecache_flg:
 		if "--quiet" not in myopts:
-			print "\n>>> Updating Portage cache:      ",
+			print "\n>>> Updating Portage cache: ",
 		os.umask(0002)
 		cachedir = os.path.normpath(portage.settings.depcachedir)
 		if cachedir in ["/",    "/bin", "/dev",  "/etc",  "/home",
@@ -2731,15 +2731,20 @@
 		savelist = []
 		catlist = []
 		oldcat = portage.catsplit(cp_list[0])[0]
+		prev_msg_len = 0
 		for cp in cp_list:
 			current += 1
 			if current >= nextupdate:
 				pcnt += 1
 				nextupdate += pcntcount
-				if "--quiet" not in myopts:
-					pcntstr = str(pcnt)
-					sys.stdout.write("\b"*(len(pcntstr)+1)+pcntstr+"%")
-					sys.stdout.flush()
+			if "--quiet" not in myopts:
+				pcntstr = str(pcnt)
+				bksp = "\b" * prev_msg_len
+				msg = pcntstr + "% (" + cp + ")"
+				erasure = " " * max((prev_msg_len - len(msg)),0)
+				prev_msg_len = len(msg + erasure)
+				sys.stdout.write(bksp + msg + erasure)
+				sys.stdout.flush()
 			cat = portage.catsplit(cp)[0]
 			if cat != oldcat:
 				catlist.append(oldcat)

Reply via email to