For bug #184679, handle ENOTDIR by finding the non-directory parent and testing that...
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Jul 2007 00:33:04 +0000 (00:33 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Jul 2007 00:33:04 +0000 (00:33 -0000)
svn path=/main/trunk/; revision=7220

pym/portage/dbapi/vartree.py

index d9107370547d196dde6eb65e4f07fd305999955c..93adc30a84b057b16cde4aa8f2cea8acbc760795 100644 (file)
@@ -1440,7 +1440,8 @@ class dblink(object):
                        stopmerge = False
                        i=0
                        collisions = []
-
+                       destroot = normalize_path(destroot).rstrip(os.path.sep) + \
+                               os.path.sep
                        print green("*")+" checking "+str(len(mycontents))+" files for package collisions"
                        for f in mycontents:
                                nocheck = False
@@ -1460,10 +1461,34 @@ class dblink(object):
                                try:
                                        dest_lstat = os.lstat(dest_path)
                                except EnvironmentError, e:
-                                       if e.errno != errno.ENOENT:
+                                       if e.errno == errno.ENOENT:
+                                               del e
+                                               continue
+                                       elif e.errno == errno.ENOTDIR:
+                                               del e
+                                               # A non-directory is in a location where this package
+                                               # expects to have a directory.
+                                               dest_lstat = None
+                                               parent_path = dest_path
+                                               while len(parent_path) > len(destroot):
+                                                       parent_path = os.path.dirname(parent_path)
+                                                       try:
+                                                               dest_lstat = os.lstat(parent_path)
+                                                               break
+                                                       except EnvironmentError, e:
+                                                               if e.errno != errno.ENOTDIR:
+                                                                       raise
+                                                               del e
+                                               if not dest_lstat:
+                                                       raise AssertionError(
+                                                               "unable to find non-directory " + \
+                                                               "parent for '%s'" % parent_path)
+                                               dest_path = parent_path
+                                               f = os.path.sep + dest_path[len(destroot):]
+                                               if f in collisions:
+                                                       continue
+                                       else:
                                                raise
-                                       del e
-                                       continue
                                if f[0] != "/":
                                        f="/"+f
                                isowned = False