Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/
Date: Mon, 28 Nov 2022 15:33:01
Message-Id: 1669595861.0c42cc962e1926ecbdc83d903a2804f9e037f2a9.zmedico@gentoo
1 commit: 0c42cc962e1926ecbdc83d903a2804f9e037f2a9
2 Author: Pin-yen Lin <treapking <AT> chromium <DOT> org>
3 AuthorDate: Fri Nov 25 03:36:26 2022 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 28 00:37:41 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0c42cc96
7
8 Move and rename check_reverse_dependencies
9
10 Move the function outside the original scope and rename the function to
11 _slot_operator_check_reverse_dependencies to accommodate the coding
12 style.
13
14 Signed-off-by: Pin-yen Lin <treapking <AT> chromium.org>
15 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
16
17 lib/_emerge/depgraph.py | 226 ++++++++++++++++++++++++------------------------
18 1 file changed, 113 insertions(+), 113 deletions(-)
19
20 diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
21 index e556d6616..bb0824324 100644
22 --- a/lib/_emerge/depgraph.py
23 +++ b/lib/_emerge/depgraph.py
24 @@ -2240,6 +2240,111 @@ class depgraph:
25
26 return None
27
28 + def _slot_operator_check_reverse_dependencies(
29 + self, existing_pkg, candidate_pkg, replacement_parent=None
30 + ):
31 + """
32 + Check if candidate_pkg satisfies all of existing_pkg's non-
33 + slot operator parents.
34 + """
35 + debug = "--debug" in self._frozen_config.myopts
36 + built_slot_operator_parents = set()
37 + for parent, atom in self._dynamic_config._parent_atoms.get(existing_pkg, []):
38 + if atom.soname or atom.slot_operator_built:
39 + built_slot_operator_parents.add(parent)
40 +
41 + for parent, atom in self._dynamic_config._parent_atoms.get(existing_pkg, []):
42 + if isinstance(parent, Package):
43 + if parent in built_slot_operator_parents:
44 + if hasattr(atom, "_orig_atom"):
45 + # If atom is the result of virtual expansion, then
46 + # derefrence it to _orig_atom so that it will be correctly
47 + # handled as a built slot operator dependency when
48 + # appropriate (see bug 764764).
49 + atom = atom._orig_atom
50 + # This parent may need to be rebuilt, therefore
51 + # discard its soname and built slot operator
52 + # dependency components which are not necessarily
53 + # relevant.
54 + if atom.soname:
55 + continue
56 + elif atom.package and atom.slot_operator_built:
57 + # This discards the slot/subslot component.
58 + atom = atom.with_slot("=")
59 +
60 + if replacement_parent is not None and (
61 + replacement_parent.slot_atom == parent.slot_atom
62 + or replacement_parent.cpv == parent.cpv
63 + ):
64 + # This parent is irrelevant because we intend to
65 + # replace it with replacement_parent.
66 + continue
67 +
68 + if any(
69 + pkg is not parent
70 + and (pkg.slot_atom == parent.slot_atom or pkg.cpv == parent.cpv)
71 + for pkg in self._dynamic_config._package_tracker.match(
72 + parent.root, Atom(parent.cp)
73 + )
74 + ):
75 + # This parent may need to be eliminated due to a
76 + # slot conflict, so its dependencies aren't
77 + # necessarily relevant.
78 + continue
79 +
80 + if not self._too_deep(
81 + parent.depth
82 + ) and not self._frozen_config.excluded_pkgs.findAtomForPackage(
83 + parent, modified_use=self._pkg_use_enabled(parent)
84 + ):
85 + # Check for common reasons that the parent's
86 + # dependency might be irrelevant.
87 + if self._upgrade_available(parent):
88 + # This parent could be replaced by
89 + # an upgrade (bug 584626).
90 + continue
91 + if parent.installed and self._in_blocker_conflict(parent):
92 + # This parent could be uninstalled in order
93 + # to solve a blocker conflict (bug 612772).
94 + continue
95 + if self._dynamic_config.digraph.has_edge(parent, existing_pkg):
96 + # There is a direct circular dependency between
97 + # parent and existing_pkg. This type of
98 + # relationship tends to prevent updates
99 + # of packages (bug 612874). Since candidate_pkg
100 + # is available, we risk a missed update if we
101 + # don't try to eliminate this parent from the
102 + # graph. Therefore, we give candidate_pkg a
103 + # chance, and assume that it will be masked
104 + # by backtracking if necessary.
105 + continue
106 +
107 + atom_set = InternalPackageSet(initial_atoms=(atom,), allow_repo=True)
108 + if not atom_set.findAtomForPackage(
109 + candidate_pkg, modified_use=self._pkg_use_enabled(candidate_pkg)
110 + ):
111 + if debug:
112 + parent_atoms = []
113 + for (
114 + other_parent,
115 + other_atom,
116 + ) in self._dynamic_config._parent_atoms.get(existing_pkg, []):
117 + if other_parent is parent:
118 + parent_atoms.append(other_atom)
119 + msg = (
120 + "",
121 + "",
122 + "_slot_operator_check_reverse_dependencies:",
123 + " candidate package does not match atom '%s': %s"
124 + % (atom, candidate_pkg),
125 + " parent: %s" % parent,
126 + " parent atoms: %s" % " ".join(parent_atoms),
127 + "",
128 + )
129 + writemsg_level("\n".join(msg), noiselevel=-1, level=logging.DEBUG)
130 + return False
131 + return True
132 +
133 def _slot_operator_update_probe(
134 self, dep, new_child_slot=False, slot_conflict=False, autounmask_level=None
135 ):
136 @@ -2274,116 +2379,6 @@ class depgraph:
137 want_downgrade = None
138 want_downgrade_parent = None
139
140 - def check_reverse_dependencies(
141 - existing_pkg, candidate_pkg, replacement_parent=None
142 - ):
143 - """
144 - Check if candidate_pkg satisfies all of existing_pkg's non-
145 - slot operator parents.
146 - """
147 - built_slot_operator_parents = set()
148 - for parent, atom in self._dynamic_config._parent_atoms.get(
149 - existing_pkg, []
150 - ):
151 - if atom.soname or atom.slot_operator_built:
152 - built_slot_operator_parents.add(parent)
153 -
154 - for parent, atom in self._dynamic_config._parent_atoms.get(
155 - existing_pkg, []
156 - ):
157 - if isinstance(parent, Package):
158 - if parent in built_slot_operator_parents:
159 - if hasattr(atom, "_orig_atom"):
160 - # If atom is the result of virtual expansion, then
161 - # derefrence it to _orig_atom so that it will be correctly
162 - # handled as a built slot operator dependency when
163 - # appropriate (see bug 764764).
164 - atom = atom._orig_atom
165 - # This parent may need to be rebuilt, therefore
166 - # discard its soname and built slot operator
167 - # dependency components which are not necessarily
168 - # relevant.
169 - if atom.soname:
170 - continue
171 - elif atom.package and atom.slot_operator_built:
172 - # This discards the slot/subslot component.
173 - atom = atom.with_slot("=")
174 -
175 - if replacement_parent is not None and (
176 - replacement_parent.slot_atom == parent.slot_atom
177 - or replacement_parent.cpv == parent.cpv
178 - ):
179 - # This parent is irrelevant because we intend to
180 - # replace it with replacement_parent.
181 - continue
182 -
183 - if any(
184 - pkg is not parent
185 - and (pkg.slot_atom == parent.slot_atom or pkg.cpv == parent.cpv)
186 - for pkg in self._dynamic_config._package_tracker.match(
187 - parent.root, Atom(parent.cp)
188 - )
189 - ):
190 - # This parent may need to be eliminated due to a
191 - # slot conflict, so its dependencies aren't
192 - # necessarily relevant.
193 - continue
194 -
195 - if not self._too_deep(
196 - parent.depth
197 - ) and not self._frozen_config.excluded_pkgs.findAtomForPackage(
198 - parent, modified_use=self._pkg_use_enabled(parent)
199 - ):
200 - # Check for common reasons that the parent's
201 - # dependency might be irrelevant.
202 - if self._upgrade_available(parent):
203 - # This parent could be replaced by
204 - # an upgrade (bug 584626).
205 - continue
206 - if parent.installed and self._in_blocker_conflict(parent):
207 - # This parent could be uninstalled in order
208 - # to solve a blocker conflict (bug 612772).
209 - continue
210 - if self._dynamic_config.digraph.has_edge(parent, existing_pkg):
211 - # There is a direct circular dependency between
212 - # parent and existing_pkg. This type of
213 - # relationship tends to prevent updates
214 - # of packages (bug 612874). Since candidate_pkg
215 - # is available, we risk a missed update if we
216 - # don't try to eliminate this parent from the
217 - # graph. Therefore, we give candidate_pkg a
218 - # chance, and assume that it will be masked
219 - # by backtracking if necessary.
220 - continue
221 -
222 - atom_set = InternalPackageSet(initial_atoms=(atom,), allow_repo=True)
223 - if not atom_set.findAtomForPackage(
224 - candidate_pkg, modified_use=self._pkg_use_enabled(candidate_pkg)
225 - ):
226 - if debug:
227 - parent_atoms = []
228 - for (
229 - other_parent,
230 - other_atom,
231 - ) in self._dynamic_config._parent_atoms.get(existing_pkg, []):
232 - if other_parent is parent:
233 - parent_atoms.append(other_atom)
234 - msg = (
235 - "",
236 - "",
237 - "check_reverse_dependencies:",
238 - " candidate package does not match atom '%s': %s"
239 - % (atom, candidate_pkg),
240 - " parent: %s" % parent,
241 - " parent atoms: %s" % " ".join(parent_atoms),
242 - "",
243 - )
244 - writemsg_level(
245 - "\n".join(msg), noiselevel=-1, level=logging.DEBUG
246 - )
247 - return False
248 - return True
249 -
250 for replacement_parent in self._iter_similar_available(
251 dep.parent, dep.parent.slot_atom, autounmask_level=autounmask_level
252 ):
253 @@ -2397,7 +2392,9 @@ class depgraph:
254 if not want_downgrade_parent:
255 continue
256
257 - if not check_reverse_dependencies(dep.parent, replacement_parent):
258 + if not self._slot_operator_check_reverse_dependencies(
259 + dep.parent, replacement_parent
260 + ):
261 continue
262
263 selected_atoms = None
264 @@ -2510,8 +2507,11 @@ class depgraph:
265 if atom_not_selected:
266 break
267
268 - if not insignificant and check_reverse_dependencies(
269 - dep.child, pkg, replacement_parent=replacement_parent
270 + if (
271 + not insignificant
272 + and self._slot_operator_check_reverse_dependencies(
273 + dep.child, pkg, replacement_parent=replacement_parent
274 + )
275 ):
276
277 candidate_pkg_atoms.append((pkg, unevaluated_atom or atom))