Bug #250902 - Inside dblink._find_libs_to_preserve(), prevent symlinks from
authorZac Medico <zmedico@gentoo.org>
Sun, 14 Dec 2008 20:21:32 +0000 (20:21 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 14 Dec 2008 20:21:32 +0000 (20:21 -0000)
being erroneously preserved by themselves when the old instance installed
symlinks that the new instance does not install.

svn path=/main/trunk/; revision=12251

pym/portage/dbapi/vartree.py

index 4abc1e1263f2601467edb0da639ac86704db9351..d992a3292355e3ad8f9b5b64a6ac67cda2084e03 100644 (file)
@@ -2583,7 +2583,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