diff options
Diffstat (limited to 'src/glsa-check/glsa-check')
-rwxr-xr-x | src/glsa-check/glsa-check | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/glsa-check/glsa-check b/src/glsa-check/glsa-check index 67ef7de..5150d2c 100755 --- a/src/glsa-check/glsa-check +++ b/src/glsa-check/glsa-check @@ -36,7 +36,8 @@ optionmap = [ ["-V", "--version", "some information about this tool"], ["-v", "--verbose", "print more information (option)"], ["-c", "--cve", "show CVE ids in listing mode (option)"], -["-m", "--mail", "send a mail with the given GLSAs to the administrator"] +["-q", "--quiet", "be less verbose and do not send empty mail (option)"], +["-m", "--mail", "send a mail with the given GLSAs to the administrator"], ] # print a warning as this is beta code (but proven by now, so no more warning) @@ -53,7 +54,6 @@ params = [] try: args, params = getopt(sys.argv[1:], "".join([o[0][1] for o in optionmap]), \ [x[2:] for x in reduce(lambda x,y: x+y, [z[1:-1] for z in optionmap])]) -# ["dump", "print", "list", "pretend", "fix", "inject", "help", "verbose", "version", "test", "nocolor", "cve", "mail"]) args = [a for a,b in args] for option in ["--nocolor", "-n"]: @@ -79,6 +79,13 @@ try: least_change = False args.remove(option) + quiet = False + for option in ["--quiet", "-q"]: + if option in args: + quiet = True + args.remove(option) + + # sanity checking if len(args) <= 0: sys.stderr.write("no option given: what should I do ?\n") @@ -141,6 +148,9 @@ from glsa import * glsaconfig = checkconfig(portage.config(clone=portage.settings)) +if quiet: + glsaconfig["EMERGE_OPTS"] += " --quiet" + vardb = portage.db["/"]["vartree"].dbapi portdb = portage.db["/"]["porttree"].dbapi @@ -188,9 +198,10 @@ for p in params[:]: glsalist.extend([g for g in params if g not in glsalist]) def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr): - fd2.write(white("[A]")+" means this GLSA was already applied,\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 already applied,\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: @@ -361,9 +372,10 @@ if mode == "mail": myglsa.dump(outstream=myfd) myattachments.append(MIMEText(str(myfd.getvalue()), _charset="utf8")) myfd.close() - - mymessage = portage_mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments) - portage_mail.send_mail(glsaconfig, mymessage) + + if glsalist or not quiet: + mymessage = portage_mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments) + portage_mail.send_mail(glsaconfig, mymessage) sys.exit(0) |