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 1/2] glsa-check: Add --quiet option
Date: Thu, 29 Aug 2019 19:17:50
Message-Id: 20190829191624.6949-2-zmedico@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 0/2] glsa-check: Forward port --quiet option from gentoolkit by Zac Medico
1 This patch is a forward port of the following commit:
2
3 https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=cd5a8e80f949f649b6d2b174bc899f1f092684fd
4
5 commit cd5a8e80f949f649b6d2b174bc899f1f092684fd
6 Author: fuzzyray <fuzzyray@g.o>
7 AuthorDate: 2009-05-07 22:15:50 +0000
8 Commit: fuzzyray <fuzzyray@g.o>
9 CommitDate: 2009-05-07 22:15:50 +0000
10
11 Add patch from Robert Buchholz: Add quiet option
12 Incorporate option to quiet down glsa-check, based on a patch by Thilo
13 Bangert <bangert@g.o> in bug #170784.
14 This option will also suppress sending of empty mail, based on a patch
15 by Christian Gut <cycloon@×××××××.org> in bug #182990.
16
17 svn path=/trunk/gentoolkit/; revision=633
18
19 Bug: https://bugs.gentoo.org/692872
20 Signed-off-by: Zac Medico <zmedico@g.o>
21 ---
22 bin/glsa-check | 15 ++++++++++-----
23 man/glsa-check.1 | 3 +++
24 2 files changed, 13 insertions(+), 5 deletions(-)
25
26 diff --git a/bin/glsa-check b/bin/glsa-check
27 index 83ea6b7c3..2e6d6b41f 100755
28 --- a/bin/glsa-check
29 +++ b/bin/glsa-check
30 @@ -57,6 +57,8 @@ modes.add_argument("-m", "--mail", action="store_const",
31 help="Send a mail with the given GLSAs to the administrator")
32 parser.add_argument("-V", "--version", action="store_true",
33 help="Show information about glsa-check")
34 +parser.add_argument("-q", "--quiet", action="store_true", dest="quiet",
35 + help="Be less verbose and do not send empty mail")
36 parser.add_argument("-v", "--verbose", action="store_true", dest="verbose",
37 help="Print more messages")
38 parser.add_argument("-n", "--nocolor", action="store_true",
39 @@ -80,6 +82,7 @@ if options.version:
40 mode = options.mode
41 least_change = options.least_change
42 list_cve = options.list_cve
43 +quiet = options.quiet
44 verbose = options.verbose
45
46 # Sanity checking
47 @@ -153,9 +156,10 @@ def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr, encoding="utf-8"):
48 fd2 = fd2.buffer
49 fd1 = codecs.getwriter(encoding)(fd1)
50 fd2 = codecs.getwriter(encoding)(fd2)
51 - fd2.write(white("[A]")+" means this GLSA was marked as applied (injected),\n")
52 - fd2.write(green("[U]")+" means the system is not affected and\n")
53 - fd2.write(red("[N]")+" indicates that the system might be affected.\n\n")
54 + if not quiet:
55 + fd2.write(white("[A]")+" means this GLSA was marked as applied (injected),\n")
56 + fd2.write(green("[U]")+" means the system is not affected and\n")
57 + fd2.write(red("[N]")+" indicates that the system might be affected.\n\n")
58
59 myglsalist.sort()
60 for myid in myglsalist:
61 @@ -331,8 +335,9 @@ if mode == "mail":
62 myattachments.append(MIMEText(attachment, _charset="utf8"))
63 myfd.close()
64
65 - mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments)
66 - portage.mail.send_mail(portage.settings, mymessage)
67 + if glsalist or not quiet:
68 + mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments)
69 + portage.mail.send_mail(portage.settings, mymessage)
70
71 sys.exit(0)
72
73 diff --git a/man/glsa-check.1 b/man/glsa-check.1
74 index a0d49d4dd..f1041737f 100644
75 --- a/man/glsa-check.1
76 +++ b/man/glsa-check.1
77 @@ -37,6 +37,9 @@
78 \fBV\fR, \fB\-\-version\fR Show information about \fBglsa\-check\fR\.
79 .
80 .P
81 +\fB\-q\fR, \fB\-\-quiet\fR Be less verbose and do not send empty mail\.
82 +.
83 +.P
84 \fB\-v\fR, \fB\-\-verbose\fR Print more messages\.
85 .
86 .P
87 --
88 2.21.0