commit:     2df30c0b5ecb22f2f0b2f8090f4106434985ac08
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 18 11:21:55 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Wed Sep 18 17:03:02 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=2df30c0b

WIP Auto resolve cyclic USE conflicts by trying the first suggestion

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 lib/_emerge/depgraph.py                     | 16 ++++++++++++++--
 lib/_emerge/resolver/circular_dependency.py |  2 +-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 2acd8f2e13..512afe12ce 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9897,8 +9897,20 @@ class depgraph:
                     except KeyError:
                         pass
                     else:
-                        uninst_task = node
-                        ignored_uninstall_tasks.add(node)
+                        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]
+                            enabled = list(parent.use.enabled)
+                            if solution[1]:
+                                enabled.append(solution[0])
+                            else:
+                                enabled.remove(solution[0])
+                            selected_nodes = [parent.with_use(enabled), pkg, 
parent]
+                        else:
+                            uninst_task = node
+                            ignored_uninstall_tasks.add(node)
                         break
 
                 if uninst_task is not None:

diff --git a/lib/_emerge/resolver/circular_dependency.py 
b/lib/_emerge/resolver/circular_dependency.py
index 6c21423083..09b1afebfb 100644
--- a/lib/_emerge/resolver/circular_dependency.py
+++ b/lib/_emerge/resolver/circular_dependency.py
@@ -293,7 +293,7 @@ class circular_dependency_handler:
                         " (This change might require USE changes on parent 
packages.)"
                     )
                 suggestions.append(msg)
-                final_solutions.setdefault(pkg, set()).add(solution)
+                final_solutions.setdefault(pkg, set()).add((parent, solution))
 
         return final_solutions, suggestions
 

Reply via email to