Handle a corner case inside dblink._add_preserve_libs_to_contents() in which
authorZac Medico <zmedico@gentoo.org>
Sun, 9 Nov 2008 16:58:36 +0000 (16:58 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 9 Nov 2008 16:58:36 +0000 (16:58 -0000)
a path to be preserved doesn't exist in the contents of the installed instance.

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

pym/portage/dbapi/vartree.py

index 89764f085aa7108f09bc81132af8607c0b8741f3..d2a123934b388647a417ed88e5ff9ee6083ecc9d 100644 (file)
@@ -2575,11 +2575,20 @@ class dblink(object):
                old_contents = self._installed_instance.getcontents()
                for f in list(preserve_paths):
                        f_abs = os.path.join(root, f.lstrip(os.sep))
-                       new_contents[f_abs] = old_contents[f_abs]
-                       if os.path.islink(f_abs):
-                               obj_type = "sym"
-                       else:
-                               obj_type = "obj"
+                       contents_entry = old_contents.get(f_abs)
+                       if contents_entry is None:
+                               # This will probably never happen, but it might if one of the
+                               # paths returned from findConsumers() refers to one of the libs
+                               # that should be preserved yet the path is not listed in the
+                               # contents. Such a path might belong to some other package, so
+                               # it shouldn't be preserved here.
+                               showMessage(("!!! File '%s' will not be preserved " + \
+                                       "due to missing contents entry\n") % (f_abs,),
+                                       level=logging.ERROR, noiselevel=-1)
+                               preserve_paths.remove(f)
+                               continue
+                       new_contents[f_abs] = contents_entry
+                       obj_type = contents_entry[0]
                        showMessage(">>> needed    %s %s\n" % (obj_type, f_abs))
                        # Add parent directories to contents if necessary.
                        parent_dir = os.path.dirname(f_abs)