This commit should probably be merged into the trunk.
authorFabian Groffen <grobian@gentoo.org>
Wed, 30 Jan 2008 18:13:29 +0000 (18:13 -0000)
committerFabian Groffen <grobian@gentoo.org>
Wed, 30 Jan 2008 18:13:29 +0000 (18:13 -0000)
Fix a bug in preserve libs backtracing.

Issue: copy2 raised an error because the destination path didn't exist

Cause: os.path.join was used with absolute paths on the 2nd arguments,
which results in not a join, but the 2nd argument only.

Result: the os.path.exists/makedirs was only called based on the
existing installation (x), causing no directory ever to be made in the
image dir.  Because x is absolute the join always returned x, hence when
preserve libs was run for a lib in a dir not yet existing in the image
it bailed out.

I caught this issue on FreeBSD when upgrading binutils from
18.whatever.2 to 18.whatever.3, when preserve libs tried to preserve
libopcodes.18.whatever.2.so which is in a directory 18.whatever.2,
whereas only 18.whatever.3 existed.

svn path=/main/branches/prefix/; revision=9228

pym/portage/dbapi/vartree.py

index 61522f786fb9b486223e2d7cfcdca6d09d6686f8..750193d2d6137980331885549af61f7a1401d06b 100644 (file)
@@ -1599,7 +1599,7 @@ class dblink(object):
                import shutil
                for x in preserve_paths:
                        print "injecting %s into %s" % (x, srcroot)
-                       mydir = os.path.join(srcroot, os.path.dirname(x))
+                       mydir = os.path.join(srcroot, os.path.dirname(x).lstrip(os.sep))
                        if not os.path.exists(mydir):
                                os.makedirs(mydir)
 
@@ -1613,7 +1613,8 @@ class dblink(object):
                                        linktarget = os.path.join(os.path.dirname(x), linktarget)
                                preserve_paths.append(linktarget)
                        else:
-                               shutil.copy2(os.path.join(destroot, x), os.path.join(srcroot, x.lstrip(os.sep)))
+                               shutil.copy2(os.path.join(destroot, x.lstrip(os.sep)),
+                                       os.path.join(srcroot, x.lstrip(os.sep)))
 
                # keep track of the libs we preserved
                self.vartree.dbapi.plib_registry.register(self.mycpv, self.settings["SLOT"], counter, preserve_paths)