commit:     262b8c9213c6698be4a7e2ce88536568899e6c2a
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 30 05:30:04 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Nov  6 15:57:56 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=262b8c92

emerge: fix binpkg-respect-use notice with blockers

Items in _dynamic_config._displayed_list might be blockers, so filter those out.

Bug: https://bugs.gentoo.org/916336
Fixes: bb82666b48e18f448661a1a8bf6a39b773cc4b1c
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                                        |  2 +
 lib/_emerge/depgraph.py                     |  6 +-
 lib/portage/tests/resolver/test_useflags.py | 87 +++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index be551de33d..4a33559a33 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@ Bug fixes:
 * Convert portageq helper to a function to avoid breaking external callers
   (bug #916287, bug #916296).
 
+* Avoid crash with incomplete depgraph for binpkg-respect-use notice (bug 
#916614).
+
 portage-3.0.54 (2023-10-25)
 --------------
 

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 85845dc1e2..0717e0429f 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -1234,7 +1234,11 @@ class depgraph:
     def _show_ignored_binaries_respect_use(self, respect_use):
         seen = {}
         messages = []
-        merging = {pkg.cpv for pkg in self._dynamic_config._displayed_list}
+        merging = {
+            pkg.cpv
+            for pkg in self._dynamic_config._displayed_list
+            if isinstance(pkg, Package)
+        }
         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:

diff --git a/lib/portage/tests/resolver/test_useflags.py 
b/lib/portage/tests/resolver/test_useflags.py
index 0af1cb5585..ee9f4f2763 100644
--- a/lib/portage/tests/resolver/test_useflags.py
+++ b/lib/portage/tests/resolver/test_useflags.py
@@ -142,3 +142,90 @@ class UseFlagsTestCase(TestCase):
                         )
                 finally:
                     playground.cleanup()
+
+    def testBlockerBinpkgRespectUse(self):
+        """
+        Test for bug #916336 where we tried to check properties of a blocker
+        object which isn't a Package to be merged.
+        """
+
+        ebuilds = {
+            "dev-libs/A-1": {
+                "EAPI": "7",
+                "IUSE": "abi_x86_32",
+                "RDEPEND": "dev-libs/B",
+            },
+            "dev-libs/B-1": {
+                "EAPI": "7",
+                "IUSE": "abi_x86_32",
+            },
+            "dev-libs/A-2": {
+                "EAPI": "7",
+                "IUSE": "abi_x86_32",
+                "RDEPEND": "!<dev-libs/B-2",
+            },
+            "dev-libs/B-2": {
+                "EAPI": "7",
+                "IUSE": "abi_x86_32",
+            },
+        }
+        installed = {
+            "dev-libs/A-1": {
+                "IUSE": "abi_x86_32",
+                "USE": "abi_x86_32",
+            },
+            "dev-libs/B-1": {
+                "IUSE": "abi_x86_32",
+                "USE": "abi_x86_32",
+            },
+        }
+        binpkgs = ebuilds.copy()
+
+        user_config = {
+            "make.conf": (
+                'FEATURES="binpkg-multi-instance"',
+                'USE="abi_x86_32 abi_x86_32"',
+            ),
+        }
+
+        world = ("dev-libs/A",)
+
+        test_cases = (
+            ResolverPlaygroundTestCase(
+                ["dev-libs/A"],
+                options={
+                    "--verbose": "y",
+                    "--update": True,
+                    "--deep": True,
+                    "--complete-graph": True,
+                    "--usepkg": True,
+                    "--autounmask": "n",
+                    "--autounmask-backtrack": "n",
+                    "--autounmask-use": "n",
+                },
+                success=True,
+                mergelist=["dev-libs/A-2", "[uninstall]dev-libs/B-1", 
"!<dev-libs/B-2"],
+            ),
+        )
+
+        for binpkg_format in SUPPORTED_GENTOO_BINPKG_FORMATS:
+            with self.subTest(binpkg_format=binpkg_format):
+                print(colorize("HILITE", binpkg_format), end=" ... ")
+                sys.stdout.flush()
+                user_config["make.conf"] += 
(f'BINPKG_FORMAT="{binpkg_format}"',)
+                playground = ResolverPlayground(
+                    ebuilds=ebuilds,
+                    binpkgs=binpkgs,
+                    installed=installed,
+                    user_config=user_config,
+                    world=world,
+                )
+
+                try:
+                    for test_case in test_cases:
+                        playground.run_TestCase(test_case)
+                        self.assertEqual(
+                            test_case.test_success, True, test_case.fail_msg
+                        )
+                finally:
+                    playground.cleanup()

Reply via email to