[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-portage-dev
Subject:    [gentoo-portage-dev] [PATCH 1/2] glsa-check: Add --quiet option
From:       Zac Medico <zmedico () gentoo ! org>
Date:       2019-08-29 19:16:23
Message-ID: 20190829191624.6949-2-zmedico () gentoo ! org
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic