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