public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH 0/2] glsa-check: Forward port --quiet option from gentoolkit
@ 2019-08-29 19:16 Zac Medico
  2019-08-29 19:16 ` [gentoo-portage-dev] [PATCH 1/2] glsa-check: Add --quiet option Zac Medico
  2019-08-29 19:16 ` [gentoo-portage-dev] [PATCH 2/2] glsa-check: Hide non-vuln glsas in quiet mode Zac Medico
  0 siblings, 2 replies; 3+ messages in thread
From: Zac Medico @ 2019-08-29 19:16 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

Add a glsa-check --quiet option which is compatible with gentoolkit's
glsa-check.

Bug: https://bugs.gentoo.org/692872

Zac Medico (2):
  glsa-check: Add --quiet option
  glsa-check: Hide non-vuln glsas in quiet mode

 bin/glsa-check   | 31 ++++++++++++++++++++++---------
 man/glsa-check.1 |  3 +++
 2 files changed, 25 insertions(+), 9 deletions(-)

-- 
2.21.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gentoo-portage-dev] [PATCH 1/2] glsa-check: Add --quiet option
  2019-08-29 19:16 [gentoo-portage-dev] [PATCH 0/2] glsa-check: Forward port --quiet option from gentoolkit Zac Medico
@ 2019-08-29 19:16 ` Zac Medico
  2019-08-29 19:16 ` [gentoo-portage-dev] [PATCH 2/2] glsa-check: Hide non-vuln glsas in quiet mode Zac Medico
  1 sibling, 0 replies; 3+ messages in thread
From: Zac Medico @ 2019-08-29 19:16 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

This patch is a forward port of the following commit:

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

commit cd5a8e80f949f649b6d2b174bc899f1f092684fd
Author:     fuzzyray <fuzzyray@gentoo.org>
AuthorDate: 2009-05-07 22:15:50 +0000
Commit:     fuzzyray <fuzzyray@gentoo.org>
CommitDate: 2009-05-07 22:15:50 +0000

    Add patch from Robert Buchholz: Add quiet option
    Incorporate option to quiet down glsa-check, based on a patch by Thilo
    Bangert <bangert@gentoo.org> in bug #170784.
    This option will also suppress sending of empty mail, based on a patch
    by Christian Gut <cycloon@is-root.org> in bug #182990.

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

Bug: https://bugs.gentoo.org/692872
Signed-off-by: Zac Medico <zmedico@gentoo.org>
---
 bin/glsa-check   | 15 ++++++++++-----
 man/glsa-check.1 |  3 +++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/bin/glsa-check b/bin/glsa-check
index 83ea6b7c3..2e6d6b41f 100755
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -57,6 +57,8 @@ modes.add_argument("-m", "--mail", action="store_const",
 		help="Send a mail with the given GLSAs to the administrator")
 parser.add_argument("-V", "--version", action="store_true",
 		help="Show information about glsa-check")
+parser.add_argument("-q", "--quiet", action="store_true", dest="quiet",
+		help="Be less verbose and do not send empty mail")
 parser.add_argument("-v", "--verbose", action="store_true", dest="verbose",
 		help="Print more messages")
 parser.add_argument("-n", "--nocolor", action="store_true",
@@ -80,6 +82,7 @@ if options.version:
 mode = options.mode
 least_change = options.least_change
 list_cve = options.list_cve
+quiet = options.quiet
 verbose = options.verbose
 
 # Sanity checking
@@ -153,9 +156,10 @@ def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr, encoding="utf-8"):
 		fd2 = fd2.buffer
 	fd1 = codecs.getwriter(encoding)(fd1)
 	fd2 = codecs.getwriter(encoding)(fd2)
-	fd2.write(white("[A]")+" means this GLSA was marked as applied (injected),\n")
-	fd2.write(green("[U]")+" means the system is not affected and\n")
-	fd2.write(red("[N]")+" indicates that the system might be affected.\n\n")
+	if not quiet:
+		fd2.write(white("[A]")+" means this GLSA was marked as applied (injected),\n")
+		fd2.write(green("[U]")+" means the system is not affected and\n")
+		fd2.write(red("[N]")+" indicates that the system might be affected.\n\n")
 
 	myglsalist.sort()
 	for myid in myglsalist:
@@ -331,8 +335,9 @@ if mode == "mail":
 		myattachments.append(MIMEText(attachment, _charset="utf8"))
 		myfd.close()
 
-	mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments)
-	portage.mail.send_mail(portage.settings, mymessage)
+	if glsalist or not quiet:
+		mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments)
+		portage.mail.send_mail(portage.settings, mymessage)
 
 	sys.exit(0)
 
diff --git a/man/glsa-check.1 b/man/glsa-check.1
index a0d49d4dd..f1041737f 100644
--- a/man/glsa-check.1
+++ b/man/glsa-check.1
@@ -37,6 +37,9 @@
 \fBV\fR, \fB\-\-version\fR Show information about \fBglsa\-check\fR\.
 .
 .P
+\fB\-q\fR, \fB\-\-quiet\fR Be less verbose and do not send empty mail\.
+.
+.P
 \fB\-v\fR, \fB\-\-verbose\fR Print more messages\.
 .
 .P
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-portage-dev] [PATCH 2/2] glsa-check: Hide non-vuln glsas in quiet mode
  2019-08-29 19:16 [gentoo-portage-dev] [PATCH 0/2] glsa-check: Forward port --quiet option from gentoolkit Zac Medico
  2019-08-29 19:16 ` [gentoo-portage-dev] [PATCH 1/2] glsa-check: Add --quiet option Zac Medico
@ 2019-08-29 19:16 ` Zac Medico
  1 sibling, 0 replies; 3+ messages in thread
From: Zac Medico @ 2019-08-29 19:16 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: 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@gentoo.org>
AuthorDate: 2010-03-07 01:37:57 +0000
Commit:     vapier <vapier@gentoo.org>
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@gentoo.org>
---
 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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-29 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-29 19:16 [gentoo-portage-dev] [PATCH 0/2] glsa-check: Forward port --quiet option from gentoolkit Zac Medico
2019-08-29 19:16 ` [gentoo-portage-dev] [PATCH 1/2] glsa-check: Add --quiet option Zac Medico
2019-08-29 19:16 ` [gentoo-portage-dev] [PATCH 2/2] glsa-check: Hide non-vuln glsas in quiet mode Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox