Lines 36-42
optionmap = [
Link Here
|
36 |
["-V", "--version", "some information about this tool"], |
36 |
["-V", "--version", "some information about this tool"], |
37 |
["-v", "--verbose", "print more information (option)"], |
37 |
["-v", "--verbose", "print more information (option)"], |
38 |
["-c", "--cve", "show CVE ids in listing mode (option)"], |
38 |
["-c", "--cve", "show CVE ids in listing mode (option)"], |
39 |
["-m", "--mail", "send a mail with the given GLSAs to the administrator"] |
39 |
["-q", "--quiet", "be less verbose and do not send empty mail (option)"], |
|
|
40 |
["-m", "--mail", "send a mail with the given GLSAs to the administrator"], |
40 |
] |
41 |
] |
41 |
|
42 |
|
42 |
# print a warning as this is beta code (but proven by now, so no more warning) |
43 |
# print a warning as this is beta code (but proven by now, so no more warning) |
Lines 53-59
params = []
Link Here
|
53 |
try: |
54 |
try: |
54 |
args, params = getopt(sys.argv[1:], "".join([o[0][1] for o in optionmap]), \ |
55 |
args, params = getopt(sys.argv[1:], "".join([o[0][1] for o in optionmap]), \ |
55 |
[x[2:] for x in reduce(lambda x,y: x+y, [z[1:-1] for z in optionmap])]) |
56 |
[x[2:] for x in reduce(lambda x,y: x+y, [z[1:-1] for z in optionmap])]) |
56 |
# ["dump", "print", "list", "pretend", "fix", "inject", "help", "verbose", "version", "test", "nocolor", "cve", "mail"]) |
|
|
57 |
args = [a for a,b in args] |
57 |
args = [a for a,b in args] |
58 |
|
58 |
|
59 |
for option in ["--nocolor", "-n"]: |
59 |
for option in ["--nocolor", "-n"]: |
Lines 79-84
try:
Link Here
|
79 |
least_change = False |
79 |
least_change = False |
80 |
args.remove(option) |
80 |
args.remove(option) |
81 |
|
81 |
|
|
|
82 |
quiet = False |
83 |
for option in ["--quiet", "-q"]: |
84 |
if option in args: |
85 |
quiet = True |
86 |
args.remove(option) |
87 |
|
88 |
|
82 |
# sanity checking |
89 |
# sanity checking |
83 |
if len(args) <= 0: |
90 |
if len(args) <= 0: |
84 |
sys.stderr.write("no option given: what should I do ?\n") |
91 |
sys.stderr.write("no option given: what should I do ?\n") |
Lines 141-146
from glsa import *
Link Here
|
141 |
|
148 |
|
142 |
glsaconfig = checkconfig(portage.config(clone=portage.settings)) |
149 |
glsaconfig = checkconfig(portage.config(clone=portage.settings)) |
143 |
|
150 |
|
|
|
151 |
if quiet: |
152 |
glsaconfig["EMERGE_OPTS"] += " --quiet" |
153 |
|
144 |
vardb = portage.db["/"]["vartree"].dbapi |
154 |
vardb = portage.db["/"]["vartree"].dbapi |
145 |
portdb = portage.db["/"]["porttree"].dbapi |
155 |
portdb = portage.db["/"]["porttree"].dbapi |
146 |
|
156 |
|
Lines 188-196
for p in params[:]:
Link Here
|
188 |
glsalist.extend([g for g in params if g not in glsalist]) |
198 |
glsalist.extend([g for g in params if g not in glsalist]) |
189 |
|
199 |
|
190 |
def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr): |
200 |
def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr): |
191 |
fd2.write(white("[A]")+" means this GLSA was already applied,\n") |
201 |
if not quiet: |
192 |
fd2.write(green("[U]")+" means the system is not affected and\n") |
202 |
fd2.write(white("[A]")+" means this GLSA was already applied,\n") |
193 |
fd2.write(red("[N]")+" indicates that the system might be affected.\n\n") |
203 |
fd2.write(green("[U]")+" means the system is not affected and\n") |
|
|
204 |
fd2.write(red("[N]")+" indicates that the system might be affected.\n\n") |
194 |
|
205 |
|
195 |
myglsalist.sort() |
206 |
myglsalist.sort() |
196 |
for myid in myglsalist: |
207 |
for myid in myglsalist: |
Lines 361-369
if mode == "mail":
Link Here
|
361 |
myglsa.dump(outstream=myfd) |
372 |
myglsa.dump(outstream=myfd) |
362 |
myattachments.append(MIMEText(str(myfd.getvalue()), _charset="utf8")) |
373 |
myattachments.append(MIMEText(str(myfd.getvalue()), _charset="utf8")) |
363 |
myfd.close() |
374 |
myfd.close() |
364 |
|
375 |
|
365 |
mymessage = portage_mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments) |
376 |
if glsalist or not quiet: |
366 |
portage_mail.send_mail(glsaconfig, mymessage) |
377 |
mymessage = portage_mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments) |
|
|
378 |
portage_mail.send_mail(glsaconfig, mymessage) |
367 |
|
379 |
|
368 |
sys.exit(0) |
380 |
sys.exit(0) |
369 |
|
381 |
|