In binarytree.inject(), when a symlink is created for the current package
authorZac Medico <zmedico@gentoo.org>
Wed, 24 Jun 2009 06:47:57 +0000 (06:47 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 24 Jun 2009 06:47:57 +0000 (06:47 -0000)
and it overwrites another package, delete the corresponding metadata from
the Packages file. Thanks to Eitan Mosenkis <eitan@mosenkis.net> for
reporting.

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

pym/portage/dbapi/bintree.py

index b2984fafc052cae0028c87713eecd8346dca03ac..41da32d3929f97b603f51a732038963e3d71255b 100644 (file)
@@ -833,6 +833,7 @@ class binarytree(object):
                # process) and then updated it, all while holding a lock.
                from portage.locks import lockfile, unlockfile
                pkgindex_lock = None
+               created_symlink = False
                try:
                        pkgindex_lock = lockfile(self._pkgindex_file,
                                wantnewlockfile=1)
@@ -843,6 +844,7 @@ class binarytree(object):
                        if self._all_directory and \
                                self.getname(cpv).split(os.path.sep)[-2] == "All":
                                self._create_symlink(cpv)
+                               created_symlink = True
                        pkgindex = self._new_pkgindex()
                        try:
                                f = open(self._pkgindex_file)
@@ -874,8 +876,14 @@ class binarytree(object):
                                        # Handle path collisions in $PKGDIR/All
                                        # when CPV is not identical.
                                        del pkgindex.packages[i]
-                               elif cpv == d2.get("CPV") and path == d2.get("PATH", ""):
-                                       del pkgindex.packages[i]
+                               elif cpv == d2.get("CPV"):
+                                       if path == d2.get("PATH", ""):
+                                               del pkgindex.packages[i]
+                                       elif created_symlink and not d2.get("PATH", ""):
+                                               # Delete entry for the package that was just
+                                               # overwritten by a symlink to this package.
+                                               del pkgindex.packages[i]
+
                        pkgindex.packages.append(d)
 
                        self._update_pkgindex_header(pkgindex.header)