Gentoo Archives: gentoo-commits

From: Gilles Dartiguelongue <eva@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
Date: Fri, 26 Jun 2015 22:32:16
Message-Id: 1435236379.813f7fbce53580a4e7302f9d4ce6f40e5410d965.eva@gentoo
1 commit: 813f7fbce53580a4e7302f9d4ce6f40e5410d965
2 Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jun 24 13:17:47 2015 +0000
4 Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 25 12:46:19 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=813f7fbc
7
8 scripts/gen_archlist: rewrite max_kws logic
9
10 Not sure if everything is still the same but it got more comments and
11 looks easier to read.
12
13 scripts/gen_archlist.py | 53 +++++++++++++++++++++++++++++--------------------
14 1 file changed, 32 insertions(+), 21 deletions(-)
15
16 diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
17 index 9b60f03..15d5b02 100755
18 --- a/scripts/gen_archlist.py
19 +++ b/scripts/gen_archlist.py
20 @@ -248,8 +248,9 @@ def get_best_deps(cpv, kws, release=None):
21
22
23 def max_kws(cpv, release=None):
24 - """
25 - Given a cpv, find the intersection of "most keywords it can have" and
26 + """Build `cpv` maximum expected keyword coverage.
27 +
28 + Find the intersection of "most keywords it can have" and
29 "keywords it has", and returns a sorted list
30
31 If STABLE; makes sure it has unstable keywords right now
32 @@ -257,21 +258,29 @@ def max_kws(cpv, release=None):
33 Returns [] if current cpv has best keywords
34 Returns None if no cpv has keywords
35 """
36 - current_kws = get_kws(cpv, arches=ALL_ARCHES)
37 - maximum_kws = [] # Maximum keywords that a cpv has
38 - missing_kws = []
39 - for atom in match_wanted_atoms('<='+cpv, release):
40 + current_kws = set(get_kws(cpv, arches=ALL_ARCHES))
41 + maximum_kws = set() # Maximum keywords that a cpv has
42 + missing_kws = set()
43 +
44 + # Build best keyword coverage for `cpv`
45 + for atom in match_wanted_atoms('<=' + cpv, release):
46 kws = get_kws(atom)
47 - if len(kws) > len(maximum_kws):
48 - maximum_kws = kws
49 - for kw in kws:
50 - if kw not in missing_kws+current_kws:
51 - if STABLE and '~'+kw not in current_kws:
52 - continue
53 - missing_kws.append(kw)
54 - missing_kws.sort()
55 - if maximum_kws != []:
56 - return missing_kws
57 +
58 + # Consider stable keywords only
59 + if STABLE:
60 + kws = [kwd for kwd in kws if not kwd.startswith('~')]
61 +
62 + maximum_kws.update(set(kws))
63 +
64 + # Build list of keywords missing to achieve best coverage
65 + for kwd in maximum_kws:
66 + # Skip stable keywords with no corresponding unstable keyword in `cpv`
67 + if STABLE and '~' + kwd not in current_kws:
68 + continue
69 + missing_kws.add(kwd)
70 +
71 + if maximum_kws:
72 + return sorted(missing_kws)
73 else:
74 # No cpv has the keywords we need
75 return None
76 @@ -513,15 +522,17 @@ def main():
77 continue
78
79 kws_missing = max_kws(cpv, release=args.old_version)
80 - if kws_missing == []:
81 - # Current cpv has the max keywords => nothing to do
82 - nothing_to_be_done(cpv)
83 - continue
84 - elif kws_missing is None:
85 + if kws_missing is None:
86 debug('No versions with stable keywords for %s' % cpv)
87 # No cpv with stable keywords => select latest
88 arches = make_unstable(ARCHES)
89 kws_missing = [kw[1:] for kw in get_kws(cpv, arches)]
90 +
91 + elif not kws_missing:
92 + # Current cpv has the max keywords => nothing to do
93 + nothing_to_be_done(cpv)
94 + continue
95 +
96 ALL_CPV_KWS += fix_nesting(gen_cpv_kws(cpv, kws_missing, set()))
97 if args.check_dependencies:
98 ALL_CPV_KWS.append(LINE_SEP)