Make --pretend output in glsa-check nicer. Add colors and fix linebreaks.
authorrbu <rbu@gentoo.org>
Tue, 18 Aug 2009 17:47:20 +0000 (17:47 -0000)
committerrbu <rbu@gentoo.org>
Tue, 18 Aug 2009 17:47:20 +0000 (17:47 -0000)
svn path=/trunk/gentoolkit/; revision=670

bin/glsa-check

index a66371ce574624340d724f275b617d3086ca0027..9f2e344c1e1eb2443cefe59c8bfd120d80697d7b 100755 (executable)
@@ -298,13 +298,22 @@ if mode in ["dump", "fix", "inject", "pretend"]:
                                for (vuln, update) in myglsa.getAffectionTable(least_change=least_change):
                                        mergedict.setdefault(update, []).append(vuln)
                                
-                               sys.stdout.write(">>> The following updates will be performed for this GLSA:\n")
-                               for pkg in mergedict:
-                                       if pkg != "":
-                                               sys.stdout.write("     " + pkg + " (vulnerable: " + ", ".join(mergedict[pkg]) + ")\n")
+                               # first, extract the atoms that cannot be upgraded (where key == "")
+                               no_upgrades = []
                                if "" in mergedict:
-                                       sys.stdout.write("\n>>> For the following packages, no upgrade path exists:\n")
-                                       sys.stdout.write("     " + ", ".join(mergedict[""]))
+                                       no_upgrades = mergedict[""]
+                                       del mergedict[""]
+
+                               # see if anything is left that can be upgraded
+                               if mergedict:
+                                       sys.stdout.write(">>> Updates that will be performed:\n")
+                                       for (upd, vuln) in mergedict.iteritems():
+                                               sys.stdout.write("     " + green(upd) + " (vulnerable: " + red(", ".join(vuln)) + ")\n")
+
+                               if no_upgrades:
+                                       sys.stdout.write(">>> No upgrade path exists for these packages:\n")
+                                       sys.stdout.write("     " + red(", ".join(no_upgrades)) + "\n")
+                       sys.stdout.write("\n")
                elif mode == "inject":
                        sys.stdout.write("injecting " + myid + "\n")
                        myglsa.inject()