From 480af923fa2c0379a3d288d834bb5c5cba1bdb3f Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Tue, 16 Dec 2008 18:31:32 +0000 Subject: [PATCH] Merged from trunk -r12248:12253 | 12251 | Bug #250902 - Inside dblink._find_libs_to_preserve(), | | zmedico | prevent symlinks from being erroneously preserved by | | | themselves when the old instance installed symlinks that the | | | new instance does not install. | | 12252 | Bug #250902 - Inside dblink._find_unused_preserved_libs(), | | zmedico | show a warning instead of raising a KeyError if the | | | preserved libs registry contains a symlink that points to a | | | lib which is not preserved. | | 12253 | Inside display_preserved_libs(), filter out any consumers | | zmedico | that belong to the same package as the provider. | svn path=/main/branches/prefix/; revision=12256 --- pym/_emerge/__init__.py | 8 +++++++- pym/portage/dbapi/vartree.py | 26 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 815643d0a..718c68aa2 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -11542,10 +11542,16 @@ def display_preserved_libs(vardbapi): else: search_for_owners = set() for cpv in plibdata: + pkg_dblink = vardbapi._dblink(cpv) for f in plibdata[cpv]: if f in consumer_map: continue - consumers = list(linkmap.findConsumers(f)) + consumers = [] + for c in linkmap.findConsumers(f): + # Filter out any consumers that belong + # to the same package as the provider. + if not pkg_dblink.isowner(c, pkg_dblink.myroot): + consumers.append(c) consumers.sort() consumer_map[f] = consumers search_for_owners.update(consumers[:MAX_DISPLAY+1]) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 715e4a75d..5dccef3cf 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -3112,7 +3112,22 @@ class dblink(object): preserve_paths = set() for preserve_node in preserve_nodes: - preserve_paths.update(preserve_node.alt_paths) + # Make sure that at least one of the paths is not a symlink. + # This prevents symlinks from being erroneously preserved by + # themselves when the old instance installed symlinks that + # the new instance does not install. + have_lib = 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): + have_lib = True + break + except OSError: + continue + + if have_lib: + preserve_paths.update(preserve_node.alt_paths) return preserve_paths @@ -3251,7 +3266,14 @@ class dblink(object): unlink_list.update(node.alt_paths) unlink_list = sorted(unlink_list) for obj in unlink_list: - cpv = path_cpv_map[obj] + cpv = path_cpv_map.get(obj) + if cpv is None: + # This means that a symlink is in the preserved libs + # registry, but the actual lib it points to is not. + self._display_merge("!!! symlink to lib is preserved, " + \ + "but not the lib itself:\n!!! '%s'\n" % (obj,), + level=logging.ERROR, noiselevel=-1) + continue removed = cpv_lib_map.get(cpv) if removed is None: removed = set() -- 2.26.2