1 |
commit: 3c20e14c939bf0efa495dead6243f8035d699b86 |
2 |
Author: Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Feb 28 04:50:06 2013 +0000 |
4 |
Commit: Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Feb 28 04:50:06 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=3c20e14c |
7 |
|
8 |
Stabilization candidates: split out the bug filing script. |
9 |
|
10 |
--- |
11 |
file-stabilization-bugs.py | 103 +++++++++++++++++++++++++++++++++++++++++++ |
12 |
stabilization-candidates.py | 66 +++++++++++++--------------- |
13 |
2 files changed, 134 insertions(+), 35 deletions(-) |
14 |
|
15 |
diff --git a/file-stabilization-bugs.py b/file-stabilization-bugs.py |
16 |
new file mode 100755 |
17 |
index 0000000..4963937 |
18 |
--- /dev/null |
19 |
+++ b/file-stabilization-bugs.py |
20 |
@@ -0,0 +1,103 @@ |
21 |
+#!/usr/bin/env python |
22 |
+# Copyright 2013 Gentoo Foundation |
23 |
+# Distributed under the terms of the GNU General Public License v2 |
24 |
+ |
25 |
+import glob |
26 |
+import itertools |
27 |
+import optparse |
28 |
+import os |
29 |
+import pickle |
30 |
+import re |
31 |
+import shutil |
32 |
+import subprocess |
33 |
+import sys |
34 |
+import urllib |
35 |
+import xmlrpclib |
36 |
+ |
37 |
+from bugz.bugzilla import BugzillaProxy |
38 |
+from common import login |
39 |
+import portage.versions |
40 |
+from portage.xml.metadata import MetaDataXML |
41 |
+ |
42 |
+def save_state(done_cpvs): |
43 |
+ with open('file-stabilization-bugs.state', 'w') as state_file: |
44 |
+ pickle.dump(done_cpvs, state_file) |
45 |
+ |
46 |
+if __name__ == "__main__": |
47 |
+ exit_code = 0 |
48 |
+ |
49 |
+ parser = optparse.OptionParser() |
50 |
+ parser.add_option("-i", "--input", dest="input_filename", default="stabilization-candidates.txt", help="Input filename [default=%default]") |
51 |
+ parser.add_option("--repo", dest="repo", help="Path to portage CVS repository") |
52 |
+ |
53 |
+ (options, args) = parser.parse_args() |
54 |
+ if not options.input_filename: |
55 |
+ parser.error("--input option is required") |
56 |
+ if not options.repo: |
57 |
+ parser.error("--repo option is required") |
58 |
+ if args: |
59 |
+ parser.error("unrecognized command-line args") |
60 |
+ |
61 |
+ done_cpvs = [] |
62 |
+ if os.path.exists('file-stabilization-bugs.state'): |
63 |
+ with open('file-stabilization-bugs.state', 'r') as state_file: |
64 |
+ done_cpvs = pickle.load(state_file) |
65 |
+ |
66 |
+ url = 'https://bugs.gentoo.org/xmlrpc.cgi' |
67 |
+ print 'You will be prompted for your Gentoo Bugzilla username and password (%s).' % url |
68 |
+ bugzilla = BugzillaProxy(url) |
69 |
+ login(bugzilla) |
70 |
+ |
71 |
+ with open(options.input_filename, "r") as input_file: |
72 |
+ for line in input_file: |
73 |
+ line = line.strip() |
74 |
+ |
75 |
+ # Skip empty/whitespace/comment lines. |
76 |
+ if not line or line.startswith("#"): |
77 |
+ continue |
78 |
+ |
79 |
+ cpv = line |
80 |
+ if cpv in done_cpvs: |
81 |
+ print 'Skipping %s because it\'s marked as done' % cpv |
82 |
+ continue |
83 |
+ |
84 |
+ cp = portage.versions.pkgsplit(cpv)[0] |
85 |
+ |
86 |
+ cvs_path = os.path.join(options.repo, cp) |
87 |
+ metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml') |
88 |
+ maintainer_split = metadata.format_maintainer_string().split(' ', 1) |
89 |
+ maintainer = maintainer_split[0] |
90 |
+ if len(maintainer_split) > 1: |
91 |
+ other_maintainers = maintainer_split[1].split(',') |
92 |
+ else: |
93 |
+ other_maintainers = [] |
94 |
+ |
95 |
+ description = ('Is it OK to stabilize =%s ?\n\n' % cpv + |
96 |
+ 'If so, please CC all arches which have stable keywords\n\n' + |
97 |
+ 'for older versions of this package and add STABLEREQ keyword\n\n' + |
98 |
+ 'to the bug.') |
99 |
+ url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp) |
100 |
+ params = {} |
101 |
+ params['product'] = 'Gentoo Linux' |
102 |
+ params['version'] = 'unspecified' |
103 |
+ params['component'] = 'Keywording and Stabilization' |
104 |
+ params['summary'] = 'Please stabilize =%s' % cpv |
105 |
+ params['description'] = description |
106 |
+ params['url'] = url |
107 |
+ params['assigned_to'] = maintainer |
108 |
+ params['cc'] = other_maintainers |
109 |
+ params['severity'] = 'enhancement' |
110 |
+ try: |
111 |
+ bug_id = bugzilla.Bug.create(params)['id'] |
112 |
+ print 'Submitted bug #%d for %s. ;-)' % (bug_id, cpv) |
113 |
+ done_cpvs += cpv |
114 |
+ save_state(done_cpvs) |
115 |
+ except xmlrpclib.Fault, f: |
116 |
+ exit_code = 1 |
117 |
+ print f |
118 |
+ print 'Failed to submit bug for %s. :-(' % cpv |
119 |
+ |
120 |
+ if exit_code == 0 and os.path.exists('file-stabilization-bugs.state'): |
121 |
+ os.remove('file-stabilization-bugs.state') |
122 |
+ |
123 |
+ sys.exit(exit_code) |
124 |
|
125 |
diff --git a/stabilization-candidates.py b/stabilization-candidates.py |
126 |
index 20dae63..615e3b6 100755 |
127 |
--- a/stabilization-candidates.py |
128 |
+++ b/stabilization-candidates.py |
129 |
@@ -24,8 +24,8 @@ if __name__ == "__main__": |
130 |
parser.add_option("--days", dest="days", type=int, default=30, help="Number of days in the tree after stabilization is possible.") |
131 |
parser.add_option("--repo", dest="repo", help="Path to portage CVS repository") |
132 |
parser.add_option("--category", dest="category", help="Portage category filter (default is all categories)") |
133 |
- parser.add_option("--file-bugs", dest="file_bugs", action="store_true", default=False, help="File stabilization bugs for detected candidates. Otherwise (default) the candidates are just displayed.") |
134 |
parser.add_option("--exclude", dest="exclude", default=".*(kde-base|sci|lisp|perl-core|virtual|gnome|ruby|x11|mono|dotnet|games|xfce).*", help="Regular expression for excluded packages.") |
135 |
+ parser.add_option("-o", "--output", dest="output_filename", default="stabilization-candidates.txt", help="Output filename for generated stabilization candidates list.") |
136 |
|
137 |
(options, args) = parser.parse_args() |
138 |
if not options.arch: |
139 |
@@ -46,8 +46,33 @@ if __name__ == "__main__": |
140 |
if options.category and not cp.startswith(options.category + "/"): |
141 |
continue |
142 |
|
143 |
- if options.exclude and re.match(options.exclude, cp): |
144 |
+ cvs_path = os.path.join(options.repo, cp) |
145 |
+ try: |
146 |
+ metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml') |
147 |
+ except IOError: |
148 |
continue |
149 |
+ maintainer_split = metadata.format_maintainer_string().split(' ', 1) |
150 |
+ maintainer = maintainer_split[0] |
151 |
+ if len(maintainer_split) > 1: |
152 |
+ other_maintainers = maintainer_split[1].split(',') |
153 |
+ else: |
154 |
+ other_maintainers = [] |
155 |
+ |
156 |
+ if options.exclude: |
157 |
+ if re.match(options.exclude, cp): |
158 |
+ continue |
159 |
+ |
160 |
+ if re.match(options.exclude, maintainer): |
161 |
+ continue |
162 |
+ |
163 |
+ skip = False |
164 |
+ for m in other_maintainers: |
165 |
+ if re.match(options.exclude, m): |
166 |
+ skip = True |
167 |
+ break |
168 |
+ if skip: |
169 |
+ continue |
170 |
+ |
171 |
|
172 |
best_stable = portage.versions.best(portage.portdb.match(cp)) |
173 |
if not best_stable: |
174 |
@@ -129,7 +154,6 @@ if __name__ == "__main__": |
175 |
print 'version has bugs' |
176 |
continue |
177 |
|
178 |
- cvs_path = os.path.join(options.repo, cp) |
179 |
ebuild_name = portage.versions.catsplit(best_candidate)[1] + ".ebuild" |
180 |
ebuild_path = os.path.join(cvs_path, ebuild_name) |
181 |
manifest_path = os.path.join(cvs_path, 'Manifest') |
182 |
@@ -155,35 +179,7 @@ if __name__ == "__main__": |
183 |
f.write(manifest_contents) |
184 |
f.close() |
185 |
|
186 |
- metadata = MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/usr/portage/metadata/herds.xml') |
187 |
- maintainer_split = metadata.format_maintainer_string().split(' ', 1) |
188 |
- maintainer = maintainer_split[0] |
189 |
- if len(maintainer_split) > 1: |
190 |
- other_maintainers = maintainer_split[1].split(',') |
191 |
- else: |
192 |
- other_maintainers = [] |
193 |
- url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp) |
194 |
- |
195 |
- if options.file_bugs: |
196 |
- description = ('Is it OK to stabilize =%s ?\n\n' % best_candidate + |
197 |
- 'If so, please CC all arches which have stable keywords\n\n' + |
198 |
- 'for older versions of this package and add STABLEREQ keyword\n\n' + |
199 |
- 'to the bug.') |
200 |
- params = {} |
201 |
- params['product'] = 'Gentoo Linux' |
202 |
- params['version'] = 'unspecified' |
203 |
- params['component'] = 'Keywording and Stabilization' |
204 |
- params['summary'] = 'Please stabilize =%s' % best_candidate |
205 |
- params['description'] = description |
206 |
- params['url'] = url |
207 |
- params['assigned_to'] = maintainer |
208 |
- params['cc'] = other_maintainers |
209 |
- params['severity'] = 'enhancement' |
210 |
- try: |
211 |
- bug_id = bugzilla.Bug.create(params)['id'] |
212 |
- print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate) |
213 |
- except xmlrpclib.Fault, f: |
214 |
- print f |
215 |
- print 'Failed to submit bug for %s. :-(' % best_candidate |
216 |
- else: |
217 |
- print (best_candidate, maintainer, other_maintainers) |
218 |
+ with open(options.output_filename, 'a') as f: |
219 |
+ f.write('# %s %s\n' % (maintainer, ', '.join(other_maintainers))) |
220 |
+ f.write('%s\n' % best_candidate) |
221 |
+ print (best_candidate, maintainer, other_maintainers) |