public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/tests/resolver/, /
@ 2023-11-06 15:58 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2023-11-06 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     c56ca69564452198039e17b3a07f24f5b87a6852
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Nov  6 15:03:10 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=c56ca695

emerge: fix _show_ignored_binaries_respect_use with incomplete depgraph

I've gone for the simpler solution of just using an empty tuple where the
merge list is empty to preserve prior behaviour with what we do (or do not)
display wrt skipped binaries.

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

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

diff --git a/NEWS b/NEWS
index 4a33559a33..89d9335275 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ Bug fixes:
 
 * Avoid crash with incomplete depgraph for binpkg-respect-use notice (bug #916614).
 
+* Avoid crash with blockers in depgraph for binpkg-respect-use notice (bug #916336).
+
 portage-3.0.54 (2023-10-25)
 --------------
 

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index d1fed0d652..e4305c18c9 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -1234,11 +1234,13 @@ class depgraph:
     def _show_ignored_binaries_respect_use(self, respect_use):
         seen = {}
         messages = []
+
         merging = {
             (pkg.root, pkg.cpv)
-            for pkg in self._dynamic_config._displayed_list
+            for pkg in self._dynamic_config._displayed_list or ()
             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.root, pkg.cpv) not in merging:

diff --git a/lib/portage/tests/resolver/test_useflags.py b/lib/portage/tests/resolver/test_useflags.py
index ee9f4f2763..86684f7f28 100644
--- a/lib/portage/tests/resolver/test_useflags.py
+++ b/lib/portage/tests/resolver/test_useflags.py
@@ -229,3 +229,92 @@ class UseFlagsTestCase(TestCase):
                         )
                 finally:
                     playground.cleanup()
+
+    def testNoMergeBinpkgRespectUse(self):
+        """
+        Testcase for bug #916614 where an incomplete depgraph may be fed into
+        _show_ignored_binaries_respect_use.
+
+        We use a mix of +/-abi_x86_32 to trigger the binpkg-respect-use notice
+        and depend on a non-existent package in one of the available ebuilds we
+        queue to reinstall to trigger an aborted calculation.
+        """
+        ebuilds = {
+            "dev-libs/A-2": {
+                "EAPI": "7",
+                "IUSE": "abi_x86_32",
+            },
+            "dev-libs/B-1": {
+                "IUSE": "abi_x86_32",
+                "RDEPEND": "=dev-libs/A-1",
+            },
+        }
+
+        installed = {
+            "dev-libs/B-1": {
+                "IUSE": "abi_x86_32",
+                "USE": "abi_x86_32",
+            },
+            "dev-libs/A-1": {
+                "IUSE": "abi_x86_32",
+                "USE": "abi_x86_32",
+            },
+        }
+
+        binpkgs = {
+            "dev-libs/A-2": {
+                "IUSE": "abi_x86_32",
+                "USE": "abi_x86_32",
+            },
+            "dev-libs/B-1": {
+                "IUSE": "abi_x86_32",
+                "USE": "",
+                "BUILD_ID": "2",
+                "BUILD_TIME": "2",
+            },
+        }
+
+        user_config = {
+            "make.conf": (
+                'FEATURES="binpkg-multi-instance"',
+                'USE="abi_x86_32 abi_x86_32"',
+            ),
+        }
+
+        world = ("dev-libs/A",)
+
+        test_cases = (
+            ResolverPlaygroundTestCase(
+                ["@installed"],
+                options={
+                    "--verbose": "y",
+                    "--emptytree": True,
+                    "--usepkg": True,
+                },
+                success=False,
+                mergelist=["[binary]dev-libs/A-2", "dev-libs/B-1"],
+                slot_collision_solutions=[],
+            ),
+        )
+
+        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()


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/tests/resolver/, /
@ 2023-11-06 15:58 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2023-11-06 15:58 UTC (permalink / raw
  To: gentoo-commits

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()


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-06 15:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-06 15:58 [gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/tests/resolver/, / Sam James
  -- strict thread matches above, loose matches on Subject: below --
2023-11-06 15:58 Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox