Fix the dblink _find_libs_to_preserve method to ignore a dropped
non-soname symlink. For example, pam-1.3.1-r1 drops the non-soname
symlink named libpam_misc.so, and we don't want this to trigger
unnecessary preservation of the corresponding library, since the
corresponding libpam_misc.so.0 soname symlink and the hardlink
that it references are still provided by pam-1.3.1-r1.

Bug: https://bugs.gentoo.org/692698
Signed-off-by: Zac Medico <zmed...@gentoo.org>
---
[PATCH v2] Prevent preservation of libnspr4.so hardlink reported
by Arfrever for dev-libs/nspr-4.21 to dev-libs/nspr-4.22 upgrade.

 lib/portage/dbapi/vartree.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index 4f069474b..fa1e1523c 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -3133,10 +3133,6 @@ class dblink(object):
                                                os = portage.os
 
                        f = f_abs[root_len:]
-                       if not unmerge and self.isowner(f):
-                               # We have an indentically named replacement 
file,
-                               # so we don't try to preserve the old copy.
-                               continue
                        try:
                                consumers = linkmap.findConsumers(f,
                                        
exclude_providers=(installed_instance.isowner,))
@@ -3184,16 +3180,27 @@ class dblink(object):
                        hardlinks = set()
                        soname_symlinks = set()
                        soname = 
linkmap.getSoname(next(iter(preserve_node.alt_paths)))
+                       have_replacement_soname_link = False
+                       have_replacement_hardlink = False
                        for f in preserve_node.alt_paths:
                                f_abs = os.path.join(root, f.lstrip(os.sep))
                                try:
                                        if 
stat.S_ISREG(os.lstat(f_abs).st_mode):
                                                hardlinks.add(f)
+                                               if not unmerge and 
self.isowner(f):
+                                                       
have_replacement_hardlink = True
+                                                       if os.path.basename(f) 
== soname:
+                                                               
have_replacement_soname_link = True
                                        elif os.path.basename(f) == soname:
                                                soname_symlinks.add(f)
+                                               if not unmerge and 
self.isowner(f):
+                                                       
have_replacement_soname_link = True
                                except OSError:
                                        pass
 
+                       if have_replacement_hardlink and 
have_replacement_soname_link:
+                               continue
+
                        if hardlinks:
                                preserve_paths.update(hardlinks)
                                preserve_paths.update(soname_symlinks)
-- 
2.21.0


Reply via email to