Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH 2/2] glsa-check: Hide non-vuln glsas in quiet mode
Date: Thu, 29 Aug 2019 19:17:53
Message-Id: 20190829191624.6949-3-zmedico@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 0/2] glsa-check: Forward port --quiet option from gentoolkit by Zac Medico
This patch is a forward port of the following commit:

https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=d3e4aad5a03efbd5089f96558d2ddd1e9bf158a8

commit d3e4aad5a03efbd5089f96558d2ddd1e9bf158a8
Author:     vapier <vapier@g.o>
AuthorDate: 2010-03-07 01:37:57 +0000
Commit:     vapier <vapier@g.o>
CommitDate: 2010-03-07 01:37:57 +0000

    glsa-check: hide non-vuln glsas in quiet mode

    svn path=/trunk/gentoolkit/; revision=750

Bug: https://bugs.gentoo.org/692872
Signed-off-by: Zac Medico <zmedico@g.o>
---
 bin/glsa-check | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/bin/glsa-check b/bin/glsa-check
index 2e6d6b41f..36c495221 100755
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -222,10 +222,14 @@ if mode in ["dump", "fix", "inject", "pretend"]:
 		if mode == "dump":
 			myglsa.dump()
 		elif mode == "fix":
-			sys.stdout.write("Fixing GLSA "+myid+"\n")
+			if not quiet:
+				sys.stdout.write("Fixing GLSA "+myid+"\n")
 			if not myglsa.isVulnerable():
-				sys.stdout.write(">>> no vulnerable packages installed\n")
+				if not quiet:
+					sys.stdout.write(">>> no vulnerable packages installed\n")
 			else:
+				if quiet:
+					sys.stdout.write("Fixing GLSA "+myid+"\n")
 				mergelist = myglsa.getMergeList(least_change=least_change)
 				if mergelist == []:
 					sys.stdout.write(">>> cannot fix GLSA, no unaffected packages available\n")
@@ -247,10 +251,14 @@ if mode in ["dump", "fix", "inject", "pretend"]:
 			if len(mergelist):
 				sys.stdout.write("\n")
 		elif mode == "pretend":
-			sys.stdout.write("Checking GLSA "+myid+"\n")
+			if not quiet:
+				sys.stdout.write("Checking GLSA "+myid+"\n")
 			if not myglsa.isVulnerable():
-				sys.stdout.write(">>> no vulnerable packages installed\n")
+				if not quiet:
+					sys.stdout.write(">>> no vulnerable packages installed\n")
 			else:
+				if quiet:
+					sys.stdout.write("Checking GLSA "+myid+"\n")
 				mergedict = {}
 				for (vuln, update) in myglsa.getAffectionTable(least_change=least_change):
 					mergedict.setdefault(update, []).append(vuln)
-- 
2.21.0