Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoolkit r540 - trunk/src/glsa-check
Date: Tue, 20 Jan 2009 02:57:30
Message-Id: E1LP6nu-0001m8-Vq@stork.gentoo.org
1 Author: vapier
2 Date: 2009-01-20 02:57:26 +0000 (Tue, 20 Jan 2009)
3 New Revision: 540
4
5 Modified:
6 trunk/src/glsa-check/glsa-check
7 Log:
8 tighten up output
9
10 Modified: trunk/src/glsa-check/glsa-check
11 ===================================================================
12 --- trunk/src/glsa-check/glsa-check 2009-01-20 02:44:44 UTC (rev 539)
13 +++ trunk/src/glsa-check/glsa-check 2009-01-20 02:57:26 UTC (rev 540)
14 @@ -82,10 +82,10 @@
15 # sanity checking
16 if len(args) <= 0:
17 sys.stderr.write("no option given: what should I do ?\n")
18 - mode="help"
19 + mode = "HELP"
20 elif len(args) > 1:
21 sys.stderr.write("please use only one command per call\n")
22 - mode = "help"
23 + mode = "HELP"
24 else:
25 # in what mode are we ?
26 args = args[0]
27 @@ -96,32 +96,37 @@
28 except GetoptError, e:
29 sys.stderr.write("unknown option given: ")
30 sys.stderr.write(str(e)+"\n")
31 - mode = "help"
32 + mode = "HELP"
33
34 # we need a set of glsa for most operation modes
35 if len(params) <= 0 and mode in ["fix", "test", "pretend", "dump", "inject", "mail"]:
36 sys.stderr.write("\nno GLSA given, so we'll do nothing for now. \n")
37 sys.stderr.write("If you want to run on all GLSA please tell me so \n")
38 sys.stderr.write("(specify \"all\" as parameter)\n\n")
39 - mode = "help"
40 + mode = "HELP"
41 elif len(params) <= 0 and mode == "list":
42 params.append("new")
43
44 # show help message
45 -if mode == "help":
46 - sys.stderr.write("\nSyntax: glsa-check <option> [glsa-list]\n\n")
47 +if mode == "help" or mode == "HELP":
48 + msg = "Syntax: glsa-check <option> [glsa-list]\n\n"
49 for m in optionmap:
50 - sys.stderr.write(m[0] + "\t" + m[1] + " \t: " + m[-1] + "\n")
51 + msg += m[0] + "\t" + m[1] + " \t: " + m[-1] + "\n"
52 for o in m[2:-1]:
53 - sys.stderr.write("\t" + o + "\n")
54 - sys.stderr.write("\nglsa-list can contain an arbitrary number of GLSA ids, \n")
55 - sys.stderr.write("filenames containing GLSAs or the special identifiers \n")
56 - sys.stderr.write("'all', 'new' and 'affected'\n")
57 - sys.exit(1)
58 + msg += "\t" + o + "\n"
59 + msg += "\nglsa-list can contain an arbitrary number of GLSA ids, \n"
60 + msg += "filenames containing GLSAs or the special identifiers \n"
61 + msg += "'all', 'new' and 'affected'\n"
62 + if mode == "help":
63 + sys.stdout.write(msg)
64 + sys.exit(0)
65 + else:
66 + sys.stderr.write("\n" + msg)
67 + sys.exit(1)
68
69 # we need root priviledges for write access
70 if mode in ["fix", "inject"] and os.geteuid() != 0:
71 - sys.stderr.write("\nThis tool needs root access to "+mode+" this GLSA\n\n")
72 + sys.stderr.write(__program__ + ": root access is needed for \""+mode+"\" mode\n")
73 sys.exit(2)
74
75 # show version and copyright information
76 @@ -259,6 +264,8 @@
77 exitcode >>= 8
78 if exitcode:
79 sys.exit(exitcode)
80 + if len(mergelist):
81 + sys.stdout.write("\n")
82 myglsa.inject()
83 elif mode == "pretend":
84 sys.stdout.write("Checking GLSA "+myid+"\n")
85 @@ -276,10 +283,10 @@
86 sys.stdout.write(" " + pkg + " (" + oldver + ")\n")
87 else:
88 sys.stdout.write("Nothing to do for this GLSA\n")
89 + sys.stdout.write("\n")
90 elif mode == "inject":
91 sys.stdout.write("injecting " + myid + "\n")
92 myglsa.inject()
93 - sys.stdout.write("\n")
94 sys.exit(0)
95
96 # test is a bit different as Glsa.test() produces no output