Gentoo Archives: gentoo-commits

From: Magnus Granberg <zorry@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/tinderbox-cluster:master commit in: tbc/pym/, tbc/pym/repoman/
Date: Thu, 30 Jul 2015 11:37:55
Message-Id: 1438256217.801894358cc5569b03844bcd043931d441fb8508.zorry@gentoo
1 commit: 801894358cc5569b03844bcd043931d441fb8508
2 Author: Magnus Granberg <zorry <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jul 30 11:36:57 2015 +0000
4 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org>
5 CommitDate: Thu Jul 30 11:36:57 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=80189435
7
8 add repoman full scan and split repoman/main to more functions
9
10 tbc/pym/package.py | 9 +-
11 tbc/pym/qachecks.py | 79 ++++++------
12 tbc/pym/repoman/main.py | 278 +++++++++++++++++++++----------------------
13 tbc/pym/repoman/utilities.py | 4 +-
14 4 files changed, 191 insertions(+), 179 deletions(-)
15
16 diff --git a/tbc/pym/package.py b/tbc/pym/package.py
17 index ba58e2e..0a19f15 100644
18 --- a/tbc/pym/package.py
19 +++ b/tbc/pym/package.py
20 @@ -8,7 +8,7 @@ from portage.xml.metadata import MetaDataXML
21 from tbc.flags import tbc_use_flags
22 from tbc.text import get_ebuild_cvs_revision, get_log_text_dict
23 from tbc.flags import tbc_use_flags
24 -from tbc.qachecks import digestcheck, check_repoman
25 +from tbc.qachecks import digestcheck, check_repoman, repoman_full
26 from tbc.sqlquerys import add_logs, get_package_info, get_config_info, \
27 add_new_build_job, add_new_ebuild_sql, get_ebuild_id_list, add_old_ebuild, \
28 get_package_metadata_sql, update_package_metadata, update_manifest_sql, \
29 @@ -282,6 +282,10 @@ class tbc_package(object):
30 manifest_checksum_tree = self.get_manifest_checksum_tree(pkgdir, cp, repo, mytree)
31 if manifest_checksum_tree is None:
32 return
33 +
34 + # Check cp with repoman repoman full
35 + repoman_full(self._session, pkgdir, self._config_id)
36 +
37 package_id = add_new_package_sql(self._session, cp, repo)
38
39 package_metadataDict = self.get_package_metadataDict(pkgdir, package_id)
40 @@ -336,6 +340,9 @@ class tbc_package(object):
41 log_msg = "U %s:%s" % (cp, repo)
42 add_logs(self._session, log_msg, "info", self._config_id)
43
44 + # Check cp with repoman repoman full
45 + repoman_full(self._session, pkgdir, self._config_id)
46 +
47 # Get the ebuild list for cp
48 old_ebuild_id_list = []
49 ebuild_list_tree = self._myportdb.cp_list(cp, use_cache=1, mytree=mytree)
50
51 diff --git a/tbc/pym/qachecks.py b/tbc/pym/qachecks.py
52 index 8c522c6..2e25d86 100644
53 --- a/tbc/pym/qachecks.py
54 +++ b/tbc/pym/qachecks.py
55 @@ -15,6 +15,8 @@ from portage.exception import DigestException, FileNotFound, ParseError, Permiss
56 from _emerge.Package import Package
57 from _emerge.RootConfig import RootConfig
58 from tbc.repoman.checks.ebuilds.checks import run_checks
59 +from tbc.repoman.main import repoman_main
60 +from tbc.sqlquerys import get_configmetadata_info, get_config_info, get_setup_info
61 import portage
62
63 # Copy of portage.digestcheck() but without the writemsg() stuff
64 @@ -142,38 +144,47 @@ def check_file_in_manifest(pkgdir, mysettings, portdb, cpv, build_use_flags_list
65 return
66
67 def check_repoman(mysettings, myportdb, cpv, repo):
68 - # We run repoman run_checks on the ebuild
69 - ebuild_version_tree = portage.versions.cpv_getversion(cpv)
70 - element = portage.versions.cpv_getkey(cpv).split('/')
71 - categories = element[0]
72 - package = element[1]
73 - pkgdir = myportdb.getRepositoryPath(repo) + "/" + categories + "/" + package
74 - full_path = pkgdir + "/" + package + "-" + ebuild_version_tree + ".ebuild"
75 - root = '/'
76 - trees = {
77 - root : {'porttree' : portage.portagetree(root, settings=mysettings)}
78 - }
79 - root_config = RootConfig(mysettings, trees[root], None)
80 - allvars = set(x for x in portage.auxdbkeys if not x.startswith("UNUSED_"))
81 - allvars.update(Package.metadata_keys)
82 - allvars = sorted(allvars)
83 - myaux = dict(zip(allvars, myportdb.aux_get(cpv, allvars, myrepo=repo)))
84 - pkg = Package(cpv=cpv, metadata=myaux, root_config=root_config, type_name='ebuild')
85 - fails = []
86 + # We run repoman run_checks on the ebuild
87 + ebuild_version_tree = portage.versions.cpv_getversion(cpv)
88 + element = portage.versions.cpv_getkey(cpv).split('/')
89 + categories = element[0]
90 + package = element[1]
91 + pkgdir = myportdb.getRepositoryPath(repo) + "/" + categories + "/" + package
92 + full_path = pkgdir + "/" + package + "-" + ebuild_version_tree + ".ebuild"
93 + root = '/'
94 + trees = {
95 + root : {'porttree' : portage.portagetree(root, settings=mysettings)}
96 + }
97 + root_config = RootConfig(mysettings, trees[root], None)
98 + allvars = set(x for x in portage.auxdbkeys if not x.startswith("UNUSED_"))
99 + allvars.update(Package.metadata_keys)
100 + allvars = sorted(allvars)
101 + myaux = dict(zip(allvars, myportdb.aux_get(cpv, allvars, myrepo=repo)))
102 + pkg = Package(cpv=cpv, metadata=myaux, root_config=root_config, type_name='ebuild')
103 + fails = []
104 + try:
105 + # All ebuilds should have utf_8 encoding.
106 + f = codecs.open(_unicode_encode(full_path,
107 + encoding = _encodings['fs'], errors = 'strict'),
108 + mode = 'r', encoding = _encodings['repo.content'])
109 try:
110 - # All ebuilds should have utf_8 encoding.
111 - f = codecs.open(_unicode_encode(full_path,
112 - encoding = _encodings['fs'], errors = 'strict'),
113 - mode = 'r', encoding = _encodings['repo.content'])
114 - try:
115 - for check_name, e in run_checks(f, pkg):
116 - fails.append(check_name + ": " + e + "\n")
117 - finally:
118 - f.close()
119 - except UnicodeDecodeError:
120 - # A file.UTF8 failure will have already been recorded above.
121 - pass
122 - # fails will have a list with repoman errors
123 - if fails == []:
124 - return False
125 - return fails
126 \ No newline at end of file
127 + for check_name, e in run_checks(f, pkg):
128 + fails.append(check_name + ": " + e + "\n")
129 + finally:
130 + f.close()
131 + except UnicodeDecodeError:
132 + # A file.UTF8 failure will have already been recorded above.
133 + pass
134 + # fails will have a list with repoman errors
135 + if fails == []:
136 + return False
137 + return fails
138 +
139 +def repoman_full(session, pkgdir, config_id):
140 + ConfigsMetaData = get_configmetadata_info(session, config_id)
141 + ConfigInfo = get_config_info(session, config_id)
142 + SetupInfo = get_setup_info(session, config_id)
143 + config_root = ConfigsMetaData.RepoPath + '/' + ConfigInfo.Hostname + "/" + SetupInfo.Setup
144 + argscmd = []
145 + argscmd.append('full')
146 + repoman_main(argscmd, config_root=config_root, pkgdir=pkgdir)
147
148 diff --git a/tbc/pym/repoman/main.py b/tbc/pym/repoman/main.py
149 index 2196009..5bdee0e 100755
150 --- a/tbc/pym/repoman/main.py
151 +++ b/tbc/pym/repoman/main.py
152 @@ -1,5 +1,4 @@
153 -#!/usr/bin/python -bO
154 -# Copyright 1999-2014 Gentoo Foundation
155 +# Copyright 1999-2015 Gentoo Foundation
156 # Distributed under the terms of the GNU General Public License v2
157
158 from __future__ import print_function, unicode_literals
159 @@ -165,113 +164,16 @@ def need_signature(filename):
160 return False
161 raise
162
163 -def repoman_main(argv):
164 - # Repoman sets it's own ACCEPT_KEYWORDS and we don't want it to
165 - # behave incrementally.
166 - repoman_incrementals = tuple(
167 - x for x in portage.const.INCREMENTALS if x != 'ACCEPT_KEYWORDS')
168 - config_root = os.environ.get("PORTAGE_CONFIGROOT")
169 - repoman_settings = portage.config(config_root=config_root, local_config=False)
170 -
171 - if repoman_settings.get("NOCOLOR", "").lower() in ("yes", "true") or \
172 - repoman_settings.get('TERM') == 'dumb' or \
173 - not sys.stdout.isatty():
174 - nocolor()
175 -
176 - options, arguments = parse_args(
177 - argv, qahelp, repoman_settings.get("REPOMAN_DEFAULT_OPTS", ""))
178 -
179 - if options.version:
180 - print("Portage", portage.VERSION)
181 - sys.exit(0)
182 -
183 - if options.experimental_inherit == 'y':
184 - # This is experimental, so it's non-fatal.
185 - qawarnings.add("inherit.missing")
186 - checks_init(experimental_inherit=True)
187 -
188 - # Set this to False when an extraordinary issue (generally
189 - # something other than a QA issue) makes it impossible to
190 - # commit (like if Manifest generation fails).
191 - can_force = True
192 -
193 - portdir, portdir_overlay, mydir = utilities.FindPortdir(repoman_settings)
194 - if portdir is None:
195 - sys.exit(1)
196 -
197 - myreporoot = os.path.basename(portdir_overlay)
198 - myreporoot += mydir[len(portdir_overlay):]
199 - ##################
200 -
201 - vcs_settings = VCSSettings(options, repoman_settings)
202 -
203 - ##################
204 -
205 - repo_settings = RepoSettings(
206 - config_root, portdir, portdir_overlay,
207 - repoman_settings, vcs_settings, options, qawarnings)
208 -
209 - repoman_settings = repo_settings.repoman_settings
210 -
211 - portdb = repo_settings.portdb
212 - ##################
213 -
214 - if options.echangelog is None and repo_settings.repo_config.update_changelog:
215 - options.echangelog = 'y'
216 -
217 - if vcs_settings.vcs is None:
218 - options.echangelog = 'n'
219 -
220 - # The --echangelog option causes automatic ChangeLog generation,
221 - # which invalidates changelog.ebuildadded and changelog.missing
222 - # checks.
223 - # Note: Some don't use ChangeLogs in distributed SCMs.
224 - # It will be generated on server side from scm log,
225 - # before package moves to the rsync server.
226 - # This is needed because they try to avoid merge collisions.
227 - # Gentoo's Council decided to always use the ChangeLog file.
228 - # TODO: shouldn't this just be switched on the repo, iso the VCS?
229 - is_echangelog_enabled = options.echangelog in ('y', 'force')
230 - vcs_settings.vcs_is_cvs_or_svn = vcs_settings.vcs in ('cvs', 'svn')
231 - check_changelog = not is_echangelog_enabled and vcs_settings.vcs_is_cvs_or_svn
232 +def repoman_scan(repoman_settings, repo_settings, vcs_settings, options, repolevel):
233
234 - if 'digest' in repoman_settings.features and options.digest != 'n':
235 - options.digest = 'y'
236 -
237 - logging.debug("vcs: %s" % (vcs_settings.vcs,))
238 - logging.debug("repo config: %s" % (repo_settings.repo_config,))
239 - logging.debug("options: %s" % (options,))
240 -
241 - # It's confusing if these warnings are displayed without the user
242 - # being told which profile they come from, so disable them.
243 - env = os.environ.copy()
244 - env['FEATURES'] = env.get('FEATURES', '') + ' -unknown-features-warn'
245 -
246 - categories = []
247 - for path in repo_settings.repo_config.eclass_db.porttrees:
248 - categories.extend(portage.util.grabfile(
249 - os.path.join(path, 'profiles', 'categories')))
250 - repoman_settings.categories = frozenset(
251 - portage.util.stack_lists([categories], incremental=1))
252 - categories = repoman_settings.categories
253 -
254 - portdb.settings = repoman_settings
255 - # We really only need to cache the metadata that's necessary for visibility
256 - # filtering. Anything else can be discarded to reduce memory consumption.
257 - portdb._aux_cache_keys.clear()
258 - portdb._aux_cache_keys.update(
259 - ["EAPI", "IUSE", "KEYWORDS", "repository", "SLOT"])
260 -
261 - reposplit = myreporoot.split(os.path.sep)
262 - repolevel = len(reposplit)
263 -
264 - ###################
265 -
266 - if options.mode == 'commit':
267 - repochecks.commit_check(repolevel, reposplit)
268 - repochecks.conflict_check(vcs_settings, options)
269 + if options.mode == "manifest":
270 + pass
271 + elif options.pretend:
272 + print(green("\nRepoMan does a once-over of the neighborhood..."))
273 + else:
274 + print(green("\nRepoMan scours the neighborhood..."))
275
276 - ###################
277 + qatracker = QATracker()
278
279 # Make startdir relative to the canonical repodir, so that we can pass
280 # it to digestgen and it won't have to be canonicalized again.
281 @@ -281,7 +183,9 @@ def repoman_main(argv):
282 startdir = normalize_path(mydir)
283 startdir = os.path.join(
284 repo_settings.repodir, *startdir.split(os.sep)[-2 - repolevel + 3:])
285 - ###################
286 +
287 + have_pmasked = False
288 + have_dev_keywords = False
289
290 # get lists of valid keywords, licenses, and use
291 new_data = repo_metadata(repo_settings.portdb, repoman_settings)
292 @@ -305,28 +209,12 @@ def repoman_main(argv):
293
294 ####################
295
296 - dev_keywords = dev_keywords(profiles)
297 -
298 - qatracker = QATracker()
299 -
300 -
301 - if options.mode == "manifest":
302 - pass
303 - elif options.pretend:
304 - print(green("\nRepoMan does a once-over of the neighborhood..."))
305 - else:
306 - print(green("\nRepoMan scours the neighborhood..."))
307 -
308 - #####################
309 -
310 - changed = Changes(options)
311 - changed.scan(vcs_settings)
312 -
313 - ######################
314 + dev_keyword = dev_keywords(profiles)
315
316 - have_pmasked = False
317 - have_dev_keywords = False
318 - dofail = 0
319 + # Disable the "ebuild.notadded" check when not in commit mode and
320 + # running `svn status` in every package dir will be too expensive.
321 + check_ebuild_notadded = not \
322 + (vcs_settings.vcs == "svn" and repolevel < 3 and options.mode != "commit")
323
324 # NOTE: match-all caches are not shared due to potential
325 # differences between profiles in _get_implicit_iuse.
326 @@ -339,19 +227,6 @@ def repoman_main(argv):
327 include_arches = set()
328 include_arches.update(*[x.split() for x in options.include_arches])
329
330 - # Disable the "ebuild.notadded" check when not in commit mode and
331 - # running `svn status` in every package dir will be too expensive.
332 -
333 - check_ebuild_notadded = not \
334 - (vcs_settings.vcs == "svn" and repolevel < 3 and options.mode != "commit")
335 -
336 - effective_scanlist = scanlist
337 - if options.if_modified == "y":
338 - effective_scanlist = sorted(vcs_files_to_cps(
339 - chain(changed.changed, changed.new, changed.removed),
340 - repolevel, reposplit, categories))
341 -
342 - ######################
343 # initialize our checks classes here before the big xpkg loop
344 manifester = Manifests(options, qatracker, repoman_settings)
345 is_ebuild = IsEbuild(repoman_settings, repo_settings, portdb, qatracker)
346 @@ -814,7 +689,7 @@ def repoman_main(argv):
347
348 if not have_dev_keywords:
349 have_dev_keywords = \
350 - bool(dev_keywords.intersection(keywords))
351 + bool(dev_keyword.intersection(keywords))
352
353 if prof.status == "dev":
354 suffix = suffix + "indev"
355 @@ -890,6 +765,123 @@ def repoman_main(argv):
356 "metadata.warning",
357 "%s/metadata.xml: unused local USE-description: '%s'"
358 % (xpkg, myflag))
359 + return qatracker
360 +
361 +def repoman_main(argv, config_root=None, pkgdir=None):
362 + # Repoman sets it's own ACCEPT_KEYWORDS and we don't want it to
363 + # behave incrementally.
364 + repoman_incrementals = tuple(
365 + x for x in portage.const.INCREMENTALS if x != 'ACCEPT_KEYWORDS')
366 + if config_root is None:
367 + config_root = os.environ.get("PORTAGE_CONFIGROOT")
368 + repoman_settings = portage.config(config_root=config_root, local_config=False)
369 +
370 + if repoman_settings.get("NOCOLOR", "").lower() in ("yes", "true") or \
371 + repoman_settings.get('TERM') == 'dumb' or \
372 + not sys.stdout.isatty():
373 + nocolor()
374 +
375 + options, arguments = parse_args(
376 + argv, qahelp, repoman_settings.get("REPOMAN_DEFAULT_OPTS", ""))
377 +
378 + if options.version:
379 + print("Portage", portage.VERSION)
380 + sys.exit(0)
381 +
382 + if options.experimental_inherit == 'y':
383 + # This is experimental, so it's non-fatal.
384 + qawarnings.add("inherit.missing")
385 + checks_init(experimental_inherit=True)
386 +
387 + # Set this to False when an extraordinary issue (generally
388 + # something other than a QA issue) makes it impossible to
389 + # commit (like if Manifest generation fails).
390 + can_force = True
391 +
392 + portdir, portdir_overlay, mydir = utilities.FindPortdir(repoman_settings, pkgdir)
393 + if portdir is None:
394 + sys.exit(1)
395 +
396 + myreporoot = os.path.basename(portdir_overlay)
397 + myreporoot += mydir[len(portdir_overlay):]
398 + ##################
399 +
400 + vcs_settings = VCSSettings(options, repoman_settings)
401 +
402 + ##################
403 +
404 + repo_settings = RepoSettings(
405 + config_root, portdir, portdir_overlay,
406 + repoman_settings, vcs_settings, options, qawarnings)
407 +
408 + repoman_settings = repo_settings.repoman_settings
409 +
410 + portdb = repo_settings.portdb
411 + ##################
412 +
413 + if options.echangelog is None and repo_settings.repo_config.update_changelog:
414 + options.echangelog = 'y'
415 +
416 + if vcs_settings.vcs is None:
417 + options.echangelog = 'n'
418 +
419 + # The --echangelog option causes automatic ChangeLog generation,
420 + # which invalidates changelog.ebuildadded and changelog.missing
421 + # checks.
422 + # Note: Some don't use ChangeLogs in distributed SCMs.
423 + # It will be generated on server side from scm log,
424 + # before package moves to the rsync server.
425 + # This is needed because they try to avoid merge collisions.
426 + # Gentoo's Council decided to always use the ChangeLog file.
427 + # TODO: shouldn't this just be switched on the repo, iso the VCS?
428 + is_echangelog_enabled = options.echangelog in ('y', 'force')
429 + vcs_settings.vcs_is_cvs_or_svn = vcs_settings.vcs in ('cvs', 'svn')
430 + check_changelog = not is_echangelog_enabled and vcs_settings.vcs_is_cvs_or_svn
431 +
432 + if 'digest' in repoman_settings.features and options.digest != 'n':
433 + options.digest = 'y'
434 +
435 + logging.debug("vcs: %s" % (vcs_settings.vcs,))
436 + logging.debug("repo config: %s" % (repo_settings.repo_config,))
437 + logging.debug("options: %s" % (options,))
438 +
439 + # It's confusing if these warnings are displayed without the user
440 + # being told which profile they come from, so disable them.
441 + env = os.environ.copy()
442 + env['FEATURES'] = env.get('FEATURES', '') + ' -unknown-features-warn'
443 +
444 + categories = []
445 + for path in repo_settings.repo_config.eclass_db.porttrees:
446 + categories.extend(portage.util.grabfile(
447 + os.path.join(path, 'profiles', 'categories')))
448 + repoman_settings.categories = frozenset(
449 + portage.util.stack_lists([categories], incremental=1))
450 + categories = repoman_settings.categories
451 +
452 + portdb.settings = repoman_settings
453 + # We really only need to cache the metadata that's necessary for visibility
454 + # filtering. Anything else can be discarded to reduce memory consumption.
455 + portdb._aux_cache_keys.clear()
456 + portdb._aux_cache_keys.update(
457 + ["EAPI", "IUSE", "KEYWORDS", "repository", "SLOT"])
458 +
459 + reposplit = myreporoot.split(os.path.sep)
460 + repolevel = len(reposplit)
461 +
462 + if options.mode == 'commit':
463 + repochecks.commit_check(repolevel, reposplit)
464 + repochecks.conflict_check(vcs_settings, options)
465 +
466 + changed = Changes(options)
467 + changed.scan(vcs_settings)
468 +
469 + effective_scanlist = scanlist
470 + if options.if_modified == "y":
471 + effective_scanlist = sorted(vcs_files_to_cps(
472 + chain(changed.changed, changed.new, changed.removed),
473 + repolevel, reposplit, categories))
474 +
475 + qatracker = repoman_scan(repoman_settings, repo_settings, vcs_settings, options, repolevel)
476
477 if options.if_modified == "y" and len(effective_scanlist) < 1:
478 logging.warn("--if-modified is enabled, but no modified packages were found!")
479
480 diff --git a/tbc/pym/repoman/utilities.py b/tbc/pym/repoman/utilities.py
481 index 5e43851..b1871db 100644
482 --- a/tbc/pym/repoman/utilities.py
483 +++ b/tbc/pym/repoman/utilities.py
484 @@ -240,7 +240,7 @@ def get_commit_message_with_stdin():
485 return commitmessage
486
487
488 -def FindPortdir(settings):
489 +def FindPortdir(settings, pkdir):
490 """ Try to figure out what repo we are in and whether we are in a regular
491 tree or an overlay.
492
493 @@ -276,6 +276,8 @@ def FindPortdir(settings):
494 # the current working directory (from the shell).
495 location = pwd
496
497 + if not pkdir is None:
498 + location = pkgdir
499 location = normalize_path(location)
500
501 path_ids = {}