Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/
Date: Fri, 30 May 2014 13:03:35
Message-Id: 1401211879.71f8e844940eba8ba73d833e9e786a7ea65f2bfd.dol-sen@gentoo
1 commit: 71f8e844940eba8ba73d833e9e786a7ea65f2bfd
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Tue May 27 17:31:19 2014 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Tue May 27 17:31:19 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=71f8e844
7
8 repoman/main.py: Create ebuild.py and Ebuild class
9
10 This moves all relavent data to a class for a common access point.
11 It also adds an untracked function.
12
13 ---
14 pym/repoman/ebuild.py | 30 ++++++++++++++++++
15 pym/repoman/main.py | 88 ++++++++++++++++++++++++---------------------------
16 2 files changed, 71 insertions(+), 47 deletions(-)
17
18 diff --git a/pym/repoman/ebuild.py b/pym/repoman/ebuild.py
19 new file mode 100644
20 index 0000000..fbe25a9
21 --- /dev/null
22 +++ b/pym/repoman/ebuild.py
23 @@ -0,0 +1,30 @@
24 +
25 +
26 +from portage import os
27 +
28 +
29 +class Ebuild(object):
30 + '''Class to run primary checks on ebuilds'''
31 +
32 + def __init__(self, repo_settings, repolevel, pkgdir, catdir, vcs_settings, x, y):
33 + self.vcs_settings = vcs_settings
34 + self.relative_path = os.path.join(x, y + ".ebuild")
35 + self.full_path = os.path.join(repo_settings.repodir, self.relative_path)
36 + self.ebuild_path = y + ".ebuild"
37 + if repolevel < 3:
38 + self.ebuild_path = os.path.join(pkgdir, self.ebuild_path)
39 + if repolevel < 2:
40 + self.ebuild_path = os.path.join(catdir, self.ebuild_path)
41 + self.ebuild_path = os.path.join(".", self.ebuild_path)
42 +
43 +
44 + def untracked(self, check_ebuild_notadded, y, eadded):
45 + do_check = self.vcs_settings.vcs in ("cvs", "svn", "bzr")
46 + really_notadded = check_ebuild_notadded and y not in eadded
47 +
48 + if do_check and really_notadded:
49 + # ebuild not added to vcs
50 + return True
51 + return False
52 +
53 +
54
55 diff --git a/pym/repoman/main.py b/pym/repoman/main.py
56 index 158323e..9e2ba76 100755
57 --- a/pym/repoman/main.py
58 +++ b/pym/repoman/main.py
59 @@ -67,6 +67,7 @@ from repoman.argparser import parse_args
60 from repoman.checks.ebuilds.checks import run_checks, checks_init
61 from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
62 from repoman.checks.herds.herdbase import make_herd_base
63 +from repoman.ebuild import Ebuild
64 from repoman.errors import err
65 from repoman.metadata import (metadata_xml_encoding, metadata_doctype_name,
66 metadata_dtd_uri, metadata_xml_declaration)
67 @@ -806,22 +807,16 @@ for x in effective_scanlist:
68 used_useflags = set()
69
70 for y in ebuildlist:
71 - relative_path = os.path.join(x, y + ".ebuild")
72 - full_path = os.path.join(repo_settings.repodir, relative_path)
73 - ebuild_path = y + ".ebuild"
74 - if repolevel < 3:
75 - ebuild_path = os.path.join(pkgdir, ebuild_path)
76 - if repolevel < 2:
77 - ebuild_path = os.path.join(catdir, ebuild_path)
78 - ebuild_path = os.path.join(".", ebuild_path)
79 +##################
80 + ebuild = Ebuild(repo_settings, repolevel, pkgdir, catdir, vcs_settings, x, y)
81 +##################
82 +
83 if check_changelog and not changelog_modified \
84 - and ebuild_path in changed.new_ebuilds:
85 + and ebuild.ebuild_path in changed.new_ebuilds:
86 stats['changelog.ebuildadded'] += 1
87 - fails['changelog.ebuildadded'].append(relative_path)
88 + fails['changelog.ebuildadded'].append(ebuild.relative_path)
89
90 - vcs_settings.vcs_is_cvs_or_svn_or_bzr = vcs_settings.vcs in ("cvs", "svn", "bzr")
91 - check_ebuild_really_notadded = check_ebuild_notadded and y not in eadded
92 - if vcs_settings.vcs_is_cvs_or_svn_or_bzr and check_ebuild_really_notadded:
93 + if ebuild.untracked(check_ebuild_notadded, y, eadded):
94 # ebuild not added to vcs
95 stats["ebuild.notadded"] += 1
96 fails["ebuild.notadded"].append(x + "/" + y + ".ebuild")
97 @@ -850,7 +845,7 @@ for x in effective_scanlist:
98 for k, msgs in pkg.invalid.items():
99 for msg in msgs:
100 stats[k] += 1
101 - fails[k].append("%s: %s" % (relative_path, msg))
102 + fails[k].append("%s: %s" % (ebuild.relative_path, msg))
103 continue
104
105 myaux = pkg._metadata
106 @@ -861,12 +856,12 @@ for x in effective_scanlist:
107 if repo_settings.repo_config.eapi_is_banned(eapi):
108 stats["repo.eapi.banned"] += 1
109 fails["repo.eapi.banned"].append(
110 - "%s: %s" % (relative_path, eapi))
111 + "%s: %s" % (ebuild.relative_path, eapi))
112
113 elif repo_settings.repo_config.eapi_is_deprecated(eapi):
114 stats["repo.eapi.deprecated"] += 1
115 fails["repo.eapi.deprecated"].append(
116 - "%s: %s" % (relative_path, eapi))
117 + "%s: %s" % (ebuild.relative_path, eapi))
118
119 for k, v in myaux.items():
120 if not isinstance(v, basestring):
121 @@ -877,18 +872,18 @@ for x in effective_scanlist:
122 fails["variable.invalidchar"].append(
123 "%s: %s variable contains non-ASCII "
124 "character at position %s" %
125 - (relative_path, k, m.start() + 1))
126 + (ebuild.relative_path, k, m.start() + 1))
127
128 if not src_uri_error:
129 #######################
130 thirdparty = ThirdPartyMirrors(repoman_settings)
131 - thirdparty.check(myaux, relative_path)
132 + thirdparty.check(myaux, ebuild.relative_path)
133 stats["SRC_URI.mirror"] = thirdparty.stats
134 fails["SRC_URI.mirror"] = thirdparty.fails
135 #######################
136 if myaux.get("PROVIDE"):
137 stats["virtual.oldstyle"] += 1
138 - fails["virtual.oldstyle"].append(relative_path)
139 + fails["virtual.oldstyle"].append(ebuild.relative_path)
140
141 for pos, missing_var in enumerate(missingvars):
142 if not myaux.get(missing_var):
143 @@ -906,20 +901,20 @@ for x in effective_scanlist:
144 if myaux.get(var):
145 myqakey = var + ".virtual"
146 stats[myqakey] += 1
147 - fails[myqakey].append(relative_path)
148 + fails[myqakey].append(ebuild.relative_path)
149
150 if myaux['DESCRIPTION'][-1:] in ['.']:
151 stats['DESCRIPTION.punctuation'] += 1
152 fails['DESCRIPTION.punctuation'].append(
153 "%s: DESCRIPTION ends with a '%s' character"
154 - % (relative_path, myaux['DESCRIPTION'][-1:]))
155 + % (ebuild.relative_path, myaux['DESCRIPTION'][-1:]))
156
157 # 14 is the length of DESCRIPTION=""
158 if len(myaux['DESCRIPTION']) > max_desc_len:
159 stats['DESCRIPTION.toolong'] += 1
160 fails['DESCRIPTION.toolong'].append(
161 "%s: DESCRIPTION is %d characters (max %d)" %
162 - (relative_path, len(myaux['DESCRIPTION']), max_desc_len))
163 + (ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len))
164
165 keywords = myaux["KEYWORDS"].split()
166 stable_keywords = []
167 @@ -928,7 +923,7 @@ for x in effective_scanlist:
168 not keyword.startswith("-"):
169 stable_keywords.append(keyword)
170 if stable_keywords:
171 - if ebuild_path in changed.new_ebuilds and catdir != "virtual":
172 + if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual":
173 stable_keywords.sort()
174 stats["KEYWORDS.stable"] += 1
175 fails["KEYWORDS.stable"].append(
176 @@ -947,7 +942,7 @@ for x in effective_scanlist:
177 stats["KEYWORDS.dropped"] += 1
178 fails["KEYWORDS.dropped"].append(
179 "%s: %s" %
180 - (relative_path, " ".join(sorted(dropped_keywords))))
181 + (ebuild.relative_path, " ".join(sorted(dropped_keywords))))
182
183 slot_keywords[pkg.slot].update(ebuild_archs)
184
185 @@ -984,7 +979,7 @@ for x in effective_scanlist:
186
187 if keywords and not has_global_mask(pkg):
188 stats["LIVEVCS.unmasked"] += 1
189 - fails["LIVEVCS.unmasked"].append(relative_path)
190 + fails["LIVEVCS.unmasked"].append(ebuild.relative_path)
191
192 if options.ignore_arches:
193 arches = [[
194 @@ -1054,7 +1049,7 @@ for x in effective_scanlist:
195 stats[mytype + '.suspect'] += 1
196 fails[mytype + '.suspect'].append(
197 "%s: 'test?' USE conditional in %s" %
198 - (relative_path, mytype))
199 + (ebuild.relative_path, mytype))
200
201 for atom in atoms:
202 if atom == "||":
203 @@ -1075,7 +1070,7 @@ for x in effective_scanlist:
204 atom.cp in suspect_virtual:
205 stats['virtual.suspect'] += 1
206 fails['virtual.suspect'].append(
207 - relative_path +
208 + ebuild.relative_path +
209 ": %s: consider using '%s' instead of '%s'" %
210 (mytype, suspect_virtual[atom.cp], atom))
211
212 @@ -1084,7 +1079,7 @@ for x in effective_scanlist:
213 not inherited_java_eclass and \
214 atom.cp == "virtual/jdk":
215 stats['java.eclassesnotused'] += 1
216 - fails['java.eclassesnotused'].append(relative_path)
217 + fails['java.eclassesnotused'].append(ebuild.relative_path)
218 elif buildtime and \
219 not is_blocker and \
220 not inherited_wxwidgets_eclass and \
221 @@ -1092,13 +1087,13 @@ for x in effective_scanlist:
222 stats['wxwidgets.eclassnotused'] += 1
223 fails['wxwidgets.eclassnotused'].append(
224 "%s: %ss on x11-libs/wxGTK without inheriting"
225 - " wxwidgets.eclass" % (relative_path, mytype))
226 + " wxwidgets.eclass" % (ebuild.relative_path, mytype))
227 elif runtime:
228 if not is_blocker and \
229 atom.cp in suspect_rdepend:
230 stats[mytype + '.suspect'] += 1
231 fails[mytype + '.suspect'].append(
232 - relative_path + ": '%s'" % atom)
233 + ebuild.relative_path + ": '%s'" % atom)
234
235 if atom.operator == "~" and \
236 portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
237 @@ -1107,7 +1102,7 @@ for x in effective_scanlist:
238 fails[qacat].append(
239 "%s: %s uses the ~ operator"
240 " with a non-zero revision: '%s'" %
241 - (relative_path, mytype, atom))
242 + (ebuild.relative_path, mytype, atom))
243
244 type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
245
246 @@ -1117,7 +1112,7 @@ for x in effective_scanlist:
247 else:
248 qacat = m + ".syntax"
249 stats[qacat] += 1
250 - fails[qacat].append("%s: %s: %s" % (relative_path, m, b))
251 + fails[qacat].append("%s: %s: %s" % (ebuild.relative_path, m, b))
252
253 badlicsyntax = len([z for z in type_list if z == "LICENSE"])
254 badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
255 @@ -1147,7 +1142,7 @@ for x in effective_scanlist:
256 fails['EAPI.incompatible'].append(
257 "%s: IUSE defaults"
258 " not supported with EAPI='%s': '%s'" %
259 - (relative_path, eapi, myflag))
260 + (ebuild.relative_path, eapi, myflag))
261
262 for mypos in range(len(myuse)):
263 stats["IUSE.invalid"] += 1
264 @@ -1163,7 +1158,7 @@ for x in effective_scanlist:
265 for myruby in ruby_intersection:
266 stats["IUSE.rubydeprecated"] += 1
267 fails["IUSE.rubydeprecated"].append(
268 - (relative_path + ": Deprecated ruby target: %s") % myruby)
269 + (ebuild.relative_path + ": Deprecated ruby target: %s") % myruby)
270
271 # license checks
272 if not badlicsyntax:
273 @@ -1180,7 +1175,7 @@ for x in effective_scanlist:
274 fails["LICENSE.invalid"].append(x + "/" + y + ".ebuild: %s" % lic)
275 elif lic in liclist_deprecated:
276 stats["LICENSE.deprecated"] += 1
277 - fails["LICENSE.deprecated"].append("%s: %s" % (relative_path, lic))
278 + fails["LICENSE.deprecated"].append("%s: %s" % (ebuild.relative_path, lic))
279
280 # keyword checks
281 myuse = myaux["KEYWORDS"].split()
282 @@ -1208,7 +1203,7 @@ for x in effective_scanlist:
283 except portage.exception.InvalidDependString as e:
284 stats["RESTRICT.syntax"] += 1
285 fails["RESTRICT.syntax"].append(
286 - "%s: RESTRICT: %s" % (relative_path, e))
287 + "%s: RESTRICT: %s" % (ebuild.relative_path, e))
288 del e
289 if myrestrict:
290 myrestrict = set(myrestrict)
291 @@ -1224,33 +1219,32 @@ for x in effective_scanlist:
292 stats['EAPI.incompatible'] += 1
293 fails['EAPI.incompatible'].append(
294 "%s: REQUIRED_USE"
295 - " not supported with EAPI='%s'" % (relative_path, eapi,))
296 + " not supported with EAPI='%s'" % (ebuild.relative_path, eapi,))
297 try:
298 portage.dep.check_required_use(
299 required_use, (), pkg.iuse.is_valid_flag, eapi=eapi)
300 except portage.exception.InvalidDependString as e:
301 stats["REQUIRED_USE.syntax"] += 1
302 fails["REQUIRED_USE.syntax"].append(
303 - "%s: REQUIRED_USE: %s" % (relative_path, e))
304 + "%s: REQUIRED_USE: %s" % (ebuild.relative_path, e))
305 del e
306
307 # Syntax Checks
308 - relative_path = os.path.join(x, y + ".ebuild")
309 - full_path = os.path.join(repo_settings.repodir, relative_path)
310 +
311 if not vcs_settings.vcs_preserves_mtime:
312 - if ebuild_path not in changed.new_ebuilds and \
313 - ebuild_path not in changed.ebuilds:
314 + if ebuild.ebuild_path not in changed.new_ebuilds and \
315 + ebuild.ebuild_path not in changed.ebuilds:
316 pkg.mtime = None
317 try:
318 # All ebuilds should have utf_8 encoding.
319 f = io.open(
320 _unicode_encode(
321 - full_path, encoding=_encodings['fs'], errors='strict'),
322 + ebuild.full_path, encoding=_encodings['fs'], errors='strict'),
323 mode='r', encoding=_encodings['repo.content'])
324 try:
325 for check_name, e in run_checks(f, pkg):
326 stats[check_name] += 1
327 - fails[check_name].append(relative_path + ': %s' % e)
328 + fails[check_name].append(ebuild.relative_path + ': %s' % e)
329 finally:
330 f.close()
331 except UnicodeDecodeError:
332 @@ -1410,13 +1404,13 @@ for x in effective_scanlist:
333 stats[mykey] += 1
334 fails[mykey].append(
335 "%s: %s: %s(%s) %s" % (
336 - relative_path, mytype, keyword, prof,
337 + ebuild.relative_path, mytype, keyword, prof,
338 repr(atoms)))
339 else:
340 stats[mykey] += 1
341 fails[mykey].append(
342 "%s: %s: %s(%s) %s" % (
343 - relative_path, mytype, keyword, prof,
344 + ebuild.relative_path, mytype, keyword, prof,
345 repr(atoms)))
346
347 if not baddepsyntax and unknown_pkgs:
348 @@ -1427,7 +1421,7 @@ for x in effective_scanlist:
349 stats["dependency.unknown"] += 1
350 fails["dependency.unknown"].append(
351 "%s: %s: %s" % (
352 - relative_path, mytype, ", ".join(sorted(atoms))))
353 + ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
354
355 # check if there are unused local USE-descriptions in metadata.xml
356 # (unless there are any invalids, to avoid noise)