diff options
author | James Le Cuirot <chewi@gentoo.org> | 2024-09-19 17:24:56 +0100 |
---|---|---|
committer | James Le Cuirot <chewi@gentoo.org> | 2024-09-19 17:24:56 +0100 |
commit | e5ea1157ba37252e1f0d9e5d82043490b5b77f3c (patch) | |
tree | 81dbde0a5a76f5b83f9519bab649f25da63c478b | |
parent | WIP Auto resolve cyclic USE conflicts by trying the first suggestion (diff) | |
download | portage-e5ea1157ba37252e1f0d9e5d82043490b5b77f3c.tar.gz portage-e5ea1157ba37252e1f0d9e5d82043490b5b77f3c.tar.bz2 portage-e5ea1157ba37252e1f0d9e5d82043490b5b77f3c.zip |
WIP Poor attempt at making it handle more than one conflictuse-conflict-auto-resolve
The order is wrong and some of the rebuilds randomly disappear.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
-rw-r--r-- | lib/_emerge/depgraph.py | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py index df01280e3..c2f59b101 100644 --- a/lib/_emerge/depgraph.py +++ b/lib/_emerge/depgraph.py @@ -9224,6 +9224,7 @@ class depgraph: complete = "complete" in self._dynamic_config.myparams ignore_world = self._dynamic_config.myparams.get("ignore_world", False) asap_nodes = [] + changed_pkgs = {} def get_nodes(**kwargs): """ @@ -9929,26 +9930,34 @@ class depgraph: self._dynamic_config._skip_restart = True raise self._unknown_internal_error() else: - handler = circular_dependency_handler(self, mygraph) - if handler.solutions and len(handler.cycles) == 2: - pkg = list(handler.solutions.keys())[0] - parent, solution = list(handler.solutions[pkg])[0] - solution = list(solution)[0] - enabled = list(parent.use.enabled) - if solution[1]: - enabled.append(solution[0]) + uniq_selected_nodes = set() + while True: + handler = circular_dependency_handler(self, mygraph) + if handler.solutions: + pkg = list(handler.solutions.keys())[0] + parent, solution = list(handler.solutions[pkg])[0] + solution = list(solution)[0] + changed_pkg = changed_pkgs.get(parent, parent) + enabled = list(changed_pkg.use.enabled) + if solution[1]: + enabled.append(solution[0]) + else: + enabled.remove(solution[0]) + changed_pkgs[parent] = changed_pkg.with_use(enabled) + uniq_selected_nodes.update((pkg, parent)) + mygraph.remove_edge(pkg, parent) + ignored_uninstall_tasks = set( + uninst_task + for uninst_task in ignored_uninstall_tasks + if uninst_task.cp != pkg.cp or uninst_task.slot != pkg.slot + ) + elif uniq_selected_nodes: + break else: - enabled.remove(solution[0]) - selected_nodes = [parent.with_use(enabled), pkg, parent] - ignored_uninstall_tasks = set( - uninst_task - for uninst_task in ignored_uninstall_tasks - if uninst_task.cp != pkg.cp or uninst_task.slot != pkg.slot - ) - else: - self._dynamic_config._circular_deps_for_display = mygraph - self._dynamic_config._need_restart = True - raise self._unknown_internal_error() + self._dynamic_config._circular_deps_for_display = mygraph + self._dynamic_config._need_restart = True + raise self._unknown_internal_error() + selected_nodes = list(changed_pkgs.values()) + list(uniq_selected_nodes) # At this point, we've succeeded in selecting one or more nodes, so # reset state variables for leaf node selection. |