aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2019-08-29 10:49:54 -0700
committerZac Medico <zmedico@gentoo.org>2019-08-29 12:27:19 -0700
commit57e5ea479030de69e43252bd8dc6c93e6a87369a (patch)
tree4cbb455d15aee22bbea95df011938a76c464d73e /bin/glsa-check
parentbin/glsa-check: align help menu with the man page updates (diff)
downloadportage-57e5ea479030de69e43252bd8dc6c93e6a87369a.tar.gz
portage-57e5ea479030de69e43252bd8dc6c93e6a87369a.tar.bz2
portage-57e5ea479030de69e43252bd8dc6c93e6a87369a.zip
glsa-check: Add --quiet option
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>
Diffstat (limited to 'bin/glsa-check')
-rwxr-xr-xbin/glsa-check17
1 files changed, 11 insertions, 6 deletions
diff --git a/bin/glsa-check b/bin/glsa-check
index 83ea6b7c3..bfcbaa61f 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:
@@ -231,7 +235,7 @@ if mode in ["dump", "fix", "inject", "pretend"]:
# using emerge for the actual merging as it contains the dependency
# code and we want to be consistent in behaviour. Also this functionality
# will be integrated in emerge later, so it shouldn't hurt much.
- emergecmd = "emerge --oneshot " + " =" + pkg
+ emergecmd = "emerge --oneshot" + (" --quiet" if quiet else "") + " =" + pkg
if verbose:
sys.stderr.write(emergecmd+"\n")
exitcode = os.system(emergecmd)
@@ -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)