1 |
commit: c33a3166cd55a0245663cbb1472ef04fda4c44f8 |
2 |
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 25 13:31:07 2015 +0000 |
4 |
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jun 26 22:14:40 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=c33a3166 |
7 |
|
8 |
scripts/gen_archlist: better names for get_best_deps variables |
9 |
|
10 |
scripts/gen_archlist.py | 81 ++++++++++++++++++++++++++++--------------------- |
11 |
1 file changed, 46 insertions(+), 35 deletions(-) |
12 |
|
13 |
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py |
14 |
index 066b31e..b362a5d 100755 |
15 |
--- a/scripts/gen_archlist.py |
16 |
+++ b/scripts/gen_archlist.py |
17 |
@@ -169,50 +169,59 @@ def get_best_deps(cpv, kws, release=None): |
18 |
Returns a list of the best deps of a cpv, optionally matching a release, |
19 |
and with max of the specified keywords |
20 |
""" |
21 |
+ # Take raw dependency strings and convert it to a list of atoms |
22 |
atoms = portage.portdb.aux_get(cpv, ['DEPEND', 'RDEPEND', 'PDEPEND']) |
23 |
atoms = ' '.join(atoms).split() # consolidate atoms |
24 |
atoms = list(set(atoms)) # de-duplicate |
25 |
+ |
26 |
deps = set() |
27 |
- tmp = [] |
28 |
+ |
29 |
for atom in atoms: |
30 |
- if atom.find('/') is -1: |
31 |
- # It's not a dep atom |
32 |
+ if not portage.isvalidatom(atom): |
33 |
continue |
34 |
- ret = match_wanted_atoms(atom, release) |
35 |
- if not ret: |
36 |
+ |
37 |
+ cpvs = match_wanted_atoms(atom, release) |
38 |
+ if not cpvs: |
39 |
if DEBUG: |
40 |
debug('We encountered an irrelevant atom: %s' % atom) |
41 |
continue |
42 |
- best_kws = ['', []] |
43 |
- for i in ret: |
44 |
+ |
45 |
+ best_cpv_kws = ['', []] |
46 |
+ for candidate_cpv in cpvs: |
47 |
if STABLE: |
48 |
# Check that this version has unstable keywords |
49 |
- ukws = make_unstable(kws) |
50 |
- cur_ukws = make_unstable(get_kws(i, arches=kws | ukws)) |
51 |
- if cur_ukws.intersection(ukws) != ukws: |
52 |
- best_kws = 'none' |
53 |
+ unstable_kws = make_unstable(kws) |
54 |
+ cur_unstable_kws = make_unstable( |
55 |
+ get_kws(candidate_cpv, arches=kws | unstable_kws) |
56 |
+ ) |
57 |
+ if cur_unstable_kws.intersection(unstable_kws) != unstable_kws: |
58 |
+ best_cpv_kws[0] = 'none' |
59 |
if DEBUG: |
60 |
- debug('Insufficient unstable keywords in: %s' % i) |
61 |
+ debug('Insufficient unstable keywords in: %s' % |
62 |
+ candidate_cpv) |
63 |
continue |
64 |
- cur_match_kws = get_kws(i, arches=kws) |
65 |
- if cur_match_kws == kws: |
66 |
- # This dep already has all keywords |
67 |
- best_kws = 'alreadythere' |
68 |
+ |
69 |
+ candidate_kws = get_kws(candidate_cpv, arches=kws) |
70 |
+ if candidate_kws == kws: |
71 |
+ # This dep already has all requested keywords |
72 |
+ best_cpv_kws[0] = 'alreadythere' |
73 |
break |
74 |
+ |
75 |
# Select the version which needs least new keywords |
76 |
- if len(cur_match_kws) > len(best_kws[1]): |
77 |
- best_kws = [i, cur_match_kws] |
78 |
- elif not best_kws[0]: |
79 |
+ if len(candidate_kws) > len(best_cpv_kws[1]): |
80 |
+ best_cpv_kws = [candidate_cpv, candidate_kws] |
81 |
+ elif not best_cpv_kws[0]: |
82 |
# This means that none of the versions have any of the stable |
83 |
# keywords that *we checked* (i.e. kws). |
84 |
- best_kws = [i, []] |
85 |
- if best_kws == 'alreadythere': |
86 |
+ best_cpv_kws = [candidate_cpv, []] |
87 |
+ |
88 |
+ if best_cpv_kws[0] == 'alreadythere': |
89 |
if DEBUG: |
90 |
nothing_to_be_done(atom, type='dep') |
91 |
continue |
92 |
- elif best_kws == 'none': |
93 |
+ elif best_cpv_kws[0] == 'none': |
94 |
continue |
95 |
- elif not best_kws[0]: |
96 |
+ elif not best_cpv_kws[0]: |
97 |
# We get this when the if STABLE: block above rejects everything. |
98 |
# This means that this atom does not have any versions with |
99 |
# unstable keywords matching the unstable keywords of the cpv |
100 |
@@ -220,8 +229,8 @@ def get_best_deps(cpv, kws, release=None): |
101 |
# This mostly happens because an || or use dep exists. However, we |
102 |
# make such deps strict while parsing |
103 |
# XXX: We arbitrarily select the most recent version for this case |
104 |
- deps.add(ret[0]) |
105 |
- elif not best_kws[1]: |
106 |
+ deps.add(cpvs[0]) |
107 |
+ elif not best_cpv_kws[1]: |
108 |
# This means that none of the versions have any of the stable |
109 |
# keywords that *we checked* (i.e. kws). Hence, we do another pass; |
110 |
# this time checking *all* keywords. |
111 |
@@ -229,20 +238,22 @@ def get_best_deps(cpv, kws, release=None): |
112 |
# XXX: We duplicate some of the things from the for loop above |
113 |
# We don't need to duplicate anything that caused a 'continue' or |
114 |
# a 'break' above |
115 |
- ret = match_wanted_atoms(atom, release) |
116 |
- best_kws = ['', []] |
117 |
- for i in ret: |
118 |
- cur_kws = get_kws(i) |
119 |
- if len(cur_kws) > len(best_kws[1]): |
120 |
- best_kws = [i, cur_kws] |
121 |
- elif not best_kws[0]: |
122 |
+ cpvs = match_wanted_atoms(atom, release) |
123 |
+ best_cpv_kws = ['', []] |
124 |
+ for candidate_cpv in cpvs: |
125 |
+ cur_kws = get_kws(candidate_cpv) |
126 |
+ if len(cur_kws) > len(best_cpv_kws[1]): |
127 |
+ best_cpv_kws = [candidate_cpv, cur_kws] |
128 |
+ elif not best_cpv_kws[0]: |
129 |
# This means that none of the versions have any of |
130 |
# the stable keywords *at all*. No choice but to |
131 |
# arbitrarily select the latest version in that case. |
132 |
- best_kws = [i, []] |
133 |
- deps.add(best_kws[0]) |
134 |
+ best_cpv_kws = [candidate_cpv, []] |
135 |
+ |
136 |
+ deps.add(best_cpv_kws[0]) |
137 |
else: |
138 |
- deps.add(best_kws[0]) |
139 |
+ deps.add(best_cpv_kws[0]) |
140 |
+ |
141 |
return list(deps) |