commit:     bb82666b48e18f448661a1a8bf6a39b773cc4b1c
Author:     Eli Schwartz <eschwartz93 <AT> gmail <DOT> com>
AuthorDate: Sun Oct 22 16:53:23 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 22 22:09:32 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=bb82666b

emerge: avoid spamming too much info about unused binpkgs

Specifically:

- the binhost might have multiple binpkgs for the same cpv, same USE
  flags, but with different build ids, in which case the same line is
  repeated twice

- many packages can be participating in the recursive deptree, but not
  get selected for actual merging, and may not even be installed at all;
  these were still reported as mismatched-USE although the packages
  themselves were not shown in show_merge_list

Both cases are useless noise. Prune them before printing a status
report.

Before:
```
Local copy of remote index is up-to-date and will be used.

Local copy of remote index is up-to-date and will be used.

These are the packages that would be merged, in order:

Calculating dependencies... done!
Dependency resolution took 17.29 s.

[binary     U  ] sys-apps/hwdata-0.374-1 [0.373]
[binary  r  U  ] dev-libs/libsodium-1.0.19-r1-1 [1.0.18_p20220618]
[binary     U  ] net-dns/libidn2-2.3.4-r1-1 [2.3.4]
[ebuild   R    ] dev-python/fs-2.4.16  PYTHON_TARGETS="(-python3_12%*)"
[ebuild     U  ] sys-apps/iproute2-6.5.0 [6.4.0]
[binary     U  ] media-video/ffmpeg-6.0-r9-2 [6.0-r6]
[ebuild  rR    ] app-editors/vim-9.0.1627

The following packages are causing rebuilds:

  (dev-libs/libsodium-1.0.19-r1-1:0/26::gentoo, binary scheduled for merge) 
causes rebuilds for:
    (app-editors/vim-9.0.1627:0/0::gentoo, ebuild scheduled for merge)

!!! The following binary packages have been ignored due to non matching USE:

    =app-shells/bash-5.1_p16-r6 -plugins
    =sys-apps/util-linux-2.38.1-r2 -caps split-usr
    =sys-apps/util-linux-2.38.1-r2 -caps split-usr
    =sys-process/procps-3.3.17-r2 split-usr
    =sys-process/procps-3.3.17-r2 split-usr -systemd
    =app-editors/vim-9.0.1627 -python
    =app-editors/vim-9.0.1627 -python
    =dev-lang/python-3.11.5 -lto -pgo
    =dev-lang/python-3.11.5 -lto -pgo
    =dev-lang/python-3.11.5 -lto -pgo
    =media-fonts/noto-20230831 X
    =net-misc/networkmanager-1.42.6-r2 bluetooth gtk-doc ppp
    =net-misc/networkmanager-1.42.6-r2 bluetooth gtk-doc ppp
    =net-misc/networkmanager-1.42.6-r2 bluetooth gtk-doc ppp
    =net-misc/networkmanager-1.42.6-r2 bluetooth gtk-doc ppp
    =sys-devel/gdb-13.2-r1 -lzma nls -source-highlight -xxhash -zstd
    =x11-base/xorg-server-21.1.8-r2 -xvfb
    =media-libs/libsdl2-2.28.3 gles2 pulseaudio wayland
    =media-libs/libsdl2-2.28.3 gles2 pipewire pulseaudio wayland
    =sys-devel/clang-16.0.6 abi_x86_32
    =sys-devel/clang-16.0.6 -xml
    =app-arch/zstd-1.5.5 split-usr
    =app-arch/zstd-1.5.5 split-usr
    =sys-apps/sandbox-2.38 -abi_x86_32
    =dev-python/certifi-3021.3.16-r3 -python_targets_python3_12
    =dev-python/certifi-3021.3.16-r3 -python_targets_python3_12
    =dev-libs/libffi-3.4.4-r1 abi_x86_32
    =sys-libs/ncurses-6.4_p20230401 abi_x86_32 -gpm split-usr
    =sys-libs/readline-8.1_p2-r1 split-usr
    =dev-db/sqlite-3.43.2 -icu
    =dev-libs/icu-73.2 abi_x86_32
    =sys-libs/gpm-1.20.7-r5 abi_x86_32 split-usr
    =app-crypt/pinentry-1.2.1-r3 keyring qt5 wayland
    =dev-libs/glib-2.76.4 sysprof
    =sys-apps/systemd-253.11 split-usr
    =dev-libs/libxml2-2.11.5 abi_x86_32
    =dev-libs/libxml2-2.11.5 -icu
    =media-libs/mesa-23.1.8 video_cards_intel video_cards_nouveau
    =media-libs/mesa-23.1.8 video_cards_intel video_cards_nouveau
    =media-libs/mesa-23.1.8 video_cards_intel video_cards_nouveau
    =media-libs/mesa-23.1.8 video_cards_intel video_cards_nouveau
    =media-libs/mesa-23.1.8 video_cards_intel video_cards_nouveau
    =x11-libs/libxkbcommon-1.5.0 wayland
    =x11-libs/libxkbcommon-1.5.0 wayland
    =x11-libs/libxkbcommon-1.5.0 wayland
    =sys-devel/llvm-16.0.6 abi_x86_32
    =sys-devel/llvm-16.0.6 -xml
    =x11-misc/xdg-utils-1.1.3_p20210805-r1 gnome
    =dev-libs/libpcre2-10.42-r1 split-usr
    =sys-auth/polkit-122-r1 kde
    =net-libs/nghttp2-1.57.0 -systemd -xml
    =sys-libs/glibc-2.37-r7 -multilib -stack-realign -systemd
    =app-crypt/gpgme-1.21.0 -qt5
    =sys-devel/clang-runtime-16.0.6 -abi_x86_32
    =media-sound/mpg123-1.31.3-r1 pulseaudio
    =dev-libs/libpcre-8.45-r2 split-usr
    =net-wireless/wpa_supplicant-2.10-r3 qt5
    =media-libs/gst-plugins-base-1.20.6 wayland
    =media-libs/gst-plugins-base-1.20.6 theora wayland
    =media-libs/gst-plugins-base-1.20.6 wayland
    =net-libs/libproxy-0.5.3 kde
    =gnome-base/gvfs-1.50.6 gnome-online-accounts keyring
    =gnome-base/gvfs-1.50.6 gnome-online-accounts keyring
    =sys-libs/libblockdev-2.28-r1 introspection
    =dev-libs/libdbusmenu-16.04.0-r2 gtk
    =dev-libs/libdbusmenu-16.04.0-r2 gtk
    =dev-python/css-parser-1.0.9 -python_targets_python3_12
    =dev-qt/qtbase-6.5.2-r2 nls wayland
    =dev-qt/qtwebengine-6.5.2-r1 pulseaudio qml screencast
    =dev-qt/qtwebengine-6.5.2-r1 pulseaudio qml screencast
    =dev-qt/qtwebchannel-6.5.2-r2 qml
    =app-arch/unzip-6.0_p27-r1 -natspec
    =app-text/liblangtag-0.6.4 introspection
    =app-text/liblangtag-0.6.4 introspection
    =sys-apps/groff-1.22.4 -X
    =virtual/tmpfiles-0-r5 -systemd
    =sys-apps/systemd-utils-253.11-r1 split-usr
    =virtual/libcrypt-2-r1 -abi_x86_32
    =virtual/udev-217-r7 -systemd
    =net-misc/openssh-9.4_p1-r1 -X
    =dev-libs/libusb-1.0.26 split-usr
    =media-video/pipewire-0.3.80 bluetooth sound-server
    =media-video/pipewire-0.3.80 bluetooth sound-server
    =x11-misc/mate-notification-daemon-1.26.0-r1 wayland
    =x11-misc/mate-notification-daemon-1.26.0-r1 wayland
    =x11-misc/mate-notification-daemon-1.26.0-r1 wayland
    =kde-plasma/plasma-workspace-5.27.8-r1 screencast
    =kde-plasma/plasma-workspace-5.27.8-r1 screencast
    =kde-plasma/plasma-workspace-5.27.8-r1 screencast
    =sys-devel/llvm-15.0.7-r3 abi_x86_32

NOTE: The --binpkg-respect-use=n option will prevent emerge
      from ignoring these binary packages if possible.
      Using --binpkg-respect-use=y will silence this warning.

Would you like to merge these packages? [Yes/No]
```

After:
```
Local copy of remote index is up-to-date and will be used.

Local copy of remote index is up-to-date and will be used.

These are the packages that would be merged, in order:

Calculating dependencies... done!
Dependency resolution took 17.25 s.

[binary     U  ] sys-apps/hwdata-0.374-1 [0.373]
[binary  r  U  ] dev-libs/libsodium-1.0.19-r1-1 [1.0.18_p20220618]
[binary     U  ] net-dns/libidn2-2.3.4-r1-1 [2.3.4]
[ebuild   R    ] dev-python/fs-2.4.16  PYTHON_TARGETS="(-python3_12%*)"
[ebuild     U  ] sys-apps/iproute2-6.5.0 [6.4.0]
[binary     U  ] media-video/ffmpeg-6.0-r9-2 [6.0-r6]
[ebuild  rR    ] app-editors/vim-9.0.1627

The following packages are causing rebuilds:

  (dev-libs/libsodium-1.0.19-r1-1:0/26::gentoo, binary scheduled for merge) 
causes rebuilds for:
    (app-editors/vim-9.0.1627:0/0::gentoo, ebuild scheduled for merge)

!!! The following binary packages have been ignored due to non matching USE:

    =sys-apps/iproute2-6.5.0 split-usr
    =app-editors/vim-9.0.1627 -python

NOTE: The --binpkg-respect-use=n option will prevent emerge
      from ignoring these binary packages if possible.
      Using --binpkg-respect-use=y will silence this warning.

Would you like to merge these packages? [Yes/No]
```

Signed-off-by: Eli Schwartz <eschwartz93 <AT> gmail.com>
Closes: https://github.com/gentoo/portage/pull/1148
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/_emerge/depgraph.py | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index deab51718b..85845dc1e2 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -1232,25 +1232,38 @@ class depgraph:
             
self._show_ignored_binaries_changed_deps(ignored_binaries["changed_deps"])
 
     def _show_ignored_binaries_respect_use(self, respect_use):
-        writemsg(
-            "\n!!! The following binary packages have been ignored "
-            + "due to non matching USE:\n\n",
-            noiselevel=-1,
-        )
-
+        seen = {}
+        messages = []
+        merging = {pkg.cpv for pkg in self._dynamic_config._displayed_list}
         for pkg, flags in respect_use.items():
+            # Don't include recursive deps which aren't in the merge list 
anyway.
+            if pkg.cpv not in merging:
+                continue
             flag_display = []
             for flag in sorted(flags):
                 if flag not in pkg.use.enabled:
                     flag = "-" + flag
                 flag_display.append(flag)
             flag_display = " ".join(flag_display)
-            # The user can paste this line into package.use
-            writemsg(f"    ={pkg.cpv} {flag_display}", noiselevel=-1)
-            if pkg.root_config.settings["ROOT"] != "/":
-                writemsg(f" # for {pkg.root}", noiselevel=-1)
-            writemsg("\n", noiselevel=-1)
+            # We don't want to list the same USE flags for multiple build IDs
+            if pkg.cpv not in seen or flag_display not in seen[pkg.cpv]:
+                seen.setdefault(pkg.cpv, set()).add(flag_display)
+                # The user can paste this line into package.use
+                messages.append(f"    ={pkg.cpv} {flag_display}")
+                if pkg.root_config.settings["ROOT"] != "/":
+                    messages.append(f" # for {pkg.root}")
+                messages.append("\n")
+
+        if not messages:
+            return
 
+        writemsg(
+            "\n!!! The following binary packages have been ignored "
+            + "due to non matching USE:\n\n",
+            noiselevel=-1,
+        )
+        for line in messages:
+            writemsg(line, noiselevel=-1)
         msg = [
             "",
             "NOTE: The --binpkg-respect-use=n option will prevent emerge",

Reply via email to