public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/portage/tests/resolver/soname/, lib/_emerge/
@ 2023-12-20  8:16 Zac Medico
  0 siblings, 0 replies; only message in thread
From: Zac Medico @ 2023-12-20  8:16 UTC (permalink / raw
  To: gentoo-commits

commit:     70cbb9b693782eaa779cd7f9f5de6f72edc381d1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 19 05:25:40 2023 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Dec 19 06:27:26 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=70cbb9b6

depgraph: Use strip_libc_deps in _eliminate_rebuilds

The included test case will fail without strip_libc_deps
because the "injected" >=sys-libs/glibc-2.37 dependency
will be interpreted as a dependency change, triggering
unwanted reinstall of app-misc/A-1.

Bug: https://bugs.gentoo.org/915494
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/_emerge/depgraph.py                            | 33 ++++++++++++++--------
 .../tests/resolver/soname/test_skip_update.py      | 17 +++++++++--
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 4612ac2049..e92c6962ac 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -2966,6 +2966,23 @@ class depgraph:
                 return flags
         return None
 
+    def _installed_libc_deps(self, eroot):
+        """
+        Return find_libc_deps result for installed packages from the
+        given EROOT.
+        """
+        try:
+            return self._frozen_config._libc_deps_cache[eroot]
+        except (AttributeError, KeyError) as e:
+            if isinstance(e, AttributeError):
+                self._frozen_config._libc_deps_cache = {}
+
+            self._frozen_config._libc_deps_cache[eroot] = find_libc_deps(
+                self._frozen_config._trees_orig[eroot]["vartree"].dbapi,
+                False,
+            )
+        return self._frozen_config._libc_deps_cache[eroot]
+
     def _changed_deps(self, pkg):
         ebuild = None
         try:
@@ -2985,18 +3002,7 @@ class depgraph:
             else:
                 depvars = Package._runtime_keys
 
-            eroot = pkg.root_config.settings["EROOT"]
-            try:
-                libc_deps = self._frozen_config._libc_deps_cache[eroot]
-            except (AttributeError, KeyError) as e:
-                if isinstance(e, AttributeError):
-                    self._frozen_config._libc_deps_cache = {}
-
-                self._frozen_config._libc_deps_cache[eroot] = find_libc_deps(
-                    self._frozen_config._trees_orig[eroot]["vartree"].dbapi,
-                    False,
-                )
-            libc_deps = self._frozen_config._libc_deps_cache[eroot]
+            libc_deps = self._installed_libc_deps(pkg.root)
 
             # Use _raw_metadata, in order to avoid interaction
             # with --dynamic-deps.
@@ -3726,6 +3732,7 @@ class depgraph:
                     if pkg.requires != installed_instance.requires:
                         continue
 
+                libc_deps = self._installed_libc_deps(pkg.root)
                 depvars = Package._dep_keys
                 try:
                     installed_deps = []
@@ -3736,6 +3743,7 @@ class depgraph:
                             eapi=pkg.eapi,
                             token_class=Atom,
                         )
+                        strip_libc_deps(dep_struct, libc_deps)
                         installed_deps.append(dep_struct)
                 except InvalidDependString:
                     continue
@@ -3759,6 +3767,7 @@ class depgraph:
                             eapi=pkg.eapi,
                             token_class=Atom,
                         )
+                        strip_libc_deps(dep_struct, libc_deps)
                         new_deps.append(dep_struct)
 
                     if new_deps != installed_deps:

diff --git a/lib/portage/tests/resolver/soname/test_skip_update.py b/lib/portage/tests/resolver/soname/test_skip_update.py
index 407c16a548..dc48a66f9f 100644
--- a/lib/portage/tests/resolver/soname/test_skip_update.py
+++ b/lib/portage/tests/resolver/soname/test_skip_update.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2023 Gentoo Foundation
+# Copyright 2015-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import sys
@@ -29,7 +29,10 @@ class SonameSkipUpdateTestCase(TestCase):
     def testSonameSkipUpdate(self, backtrack=3):
         binpkgs = {
             "app-misc/A-1": {
-                "RDEPEND": "dev-libs/B",
+                # Simulate injected libc dep which should not trigger
+                # reinstall due to use of strip_libc_deps in
+                # depgraph._eliminate_rebuilds dep comparison.
+                "RDEPEND": "dev-libs/B >=sys-libs/glibc-2.37",
                 "DEPEND": "dev-libs/B",
                 "REQUIRES": "x86_32: libB.so.1",
             },
@@ -39,6 +42,10 @@ class SonameSkipUpdateTestCase(TestCase):
             "dev-libs/B-1": {
                 "PROVIDES": "x86_32: libB.so.1",
             },
+            "sys-libs/glibc-2.37-r7": {
+                "PROVIDES": "x86_32: libc.so.6",
+            },
+            "virtual/libc-1-r1": {"RDEPEND": "sys-libs/glibc"},
         }
 
         installed = {
@@ -50,6 +57,12 @@ class SonameSkipUpdateTestCase(TestCase):
             "dev-libs/B-1": {
                 "PROVIDES": "x86_32: libB.so.1",
             },
+            "sys-libs/glibc-2.37-r7": {
+                "PROVIDES": "x86_32: libc.so.6",
+            },
+            "virtual/libc-1-r1": {
+                "RDEPEND": "sys-libs/glibc",
+            },
         }
 
         world = ("app-misc/A",)


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-20  8:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-20  8:16 [gentoo-commits] proj/portage:master commit in: lib/portage/tests/resolver/soname/, lib/_emerge/ Zac Medico

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