Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Auto resolve cyclic USE conflicts by trying the first suggestion #1385

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chewi
Copy link
Member

@chewi chewi commented Sep 23, 2024

Hi Zac or anyone else who has a clue how the depgraph works. 😁

This is the result of several days of mostly staring and occasionally typing during our recent Hackathon at work. The idea is to automatically resolve cyclic USE conflicts like this or the infamous freetype vs harfbuzz one.

[nomerge       ] kde-plasma/plasma-meta-6.1.4-r1:6::gentoo  USE="bluetooth browser-integration crash-handler cups display-manager firewall kwallet networkmanager pulseaudio (qt5) sddm smart systemd wallpapers xwayland -accessibility -colord -crypt -discover (-elogind) -flatpak -grub -gtk -oxygen-theme -plymouth -rdp -sdk -thunderbolt -unsupported -wacom -webengine" 
[nomerge       ]  sys-fs/udisks-2.10.1-r1:2::gentoo  USE="acl daemon introspection systemd -debug (-elogind) -lvm -nls (-selinux)" 
[nomerge       ]   sys-auth/polkit-125::gentoo  USE="daemon duktape introspection kde pam systemd -examples -gtk (-selinux) -test" 
[ebuild     U  ]    dev-libs/gobject-introspection-1.80.1-r2::gentoo [1.78.1-r2::gentoo] USE="-doctool -gtk-doc -test" PYTHON_SINGLE_TARGET="python3_12 -python3_10 -python3_11 -python3_13" 1016 KiB
[ebuild     U  ]     dev-libs/glib-2.80.4:2::gentoo [2.78.6:2::gentoo] USE="dbus elf introspection%* (mime) static-libs xattr -debug -doc% (-selinux) -sysprof -systemtap -test -utils (-gtk-doc%)" ABI_X86="(64) -32 (-x32)" 5407 KiB

Total: 2 packages (2 upgrades), Size of downloads: 6422 KiB

 * Error: circular dependencies:

(dev-libs/gobject-introspection-1.80.1-r2:0/0::gentoo, ebuild scheduled for merge) depends on
 (dev-libs/glib-2.80.4:2/2::gentoo, ebuild scheduled for merge) (buildtime)
  (dev-libs/gobject-introspection-1.80.1-r2:0/0::gentoo, ebuild scheduled for merge) (buildtime)

It might be possible to break this cycle
by applying the following change:
- dev-libs/glib-2.80.4 (Change USE: -introspection)

Portage tells you what to do, so why doesn't it just do that for you? This would be a great help for Gentoo users, Gentoo developers who go out of their way to keep these situations away from users (there was a lot of excitement on IRC!), and also Flatcar Linux, which hits several conflicts at once when building its image.

The initial results after my first attempt looked very encouraging.

[ebuild     U  ] dev-libs/gobject-introspection-common-1.80.1::gentoo [1.78.1::gentoo] 1016 KiB
[ebuild     U  ] dev-util/gdbus-codegen-2.80.4::gentoo [2.78.6::gentoo] PYTHON_SINGLE_TARGET="python3_12 -python3_10 -python3_11 -python3_13%" 5407 KiB
[ebuild     U  ] dev-libs/glib-2.80.4:2::gentoo [2.78.6:2::gentoo] USE="dbus elf (mime) static-libs xattr -debug -doc% -introspection% (-selinux) -sysprof -systemtap -test -utils (-gtk-doc%)" ABI_X86="(64) -32 (-x32)" 0 KiB
[ebuild     U  ] dev-libs/gobject-introspection-1.80.1-r2::gentoo [1.78.1-r2::gentoo] USE="-doctool -gtk-doc -test" PYTHON_SINGLE_TARGET="python3_12 -python3_10 -python3_11 -python3_13" 0 KiB
[blocks b      ] <dev-libs/gobject-introspection-1.80.1 ("<dev-libs/gobject-introspection-1.80.1" is soft blocking dev-libs/glib-2.80.4, dev-libs/gobject-introspection-common-1.80.1)
[ebuild     U  ] dev-libs/glib-2.80.4:2::gentoo [2.78.6:2::gentoo] USE="dbus elf introspection%* (mime) static-libs xattr -debug -doc% (-selinux) -sysprof -systemtap -test -utils (-gtk-doc%)" ABI_X86="(64) -32 (-x32)" 0 KiB

Total: 5 packages (5 upgrades), Size of downloads: 6422 KiB
Conflict: 1 block (all satisfied)

I then found that it was only resolving the first conflict and ignoring the rest, with Flatcar's case resulting in an invalid list. A little more work got it resolving each conflict in turn, which made Flatcar's case look better, but then the ordering went a little wobbly.

Finally, I found that it wasn't adding any dependencies required by the temporary solution. While these could maybe be handled, there are unlikely to be any additional dependencies in practise as the solution is usually USE=+build or USE=-some-feature. I therefore kept it simple by only attempting automatic resolution when there are no additional dependencies.

I am aware that this is probably broken in other ways too. It's not taking account of wider blockers, although again, there probably aren't any in practise, and they are unlikely to be an issue for the short period while the conflict is resolved.

Perhaps this inspires you to come up with something solid? I and many others would be extremely grateful. Failing that, perhaps you can give me some pointers.

It only works when there is one conflicting cycle. It gets too
complicated when there is more than one.

Signed-off-by: James Le Cuirot <[email protected]>
The order is wrong and some of the rebuilds randomly disappear.

Signed-off-by: James Le Cuirot <[email protected]>
@chewi chewi requested a review from zmedico September 23, 2024 16:49
@chewi chewi self-assigned this Sep 23, 2024
@zmedico
Copy link
Member

zmedico commented Sep 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants