merge: handle symlink replacing dir
authorZac Medico <zmedico@gentoo.org>
Sat, 23 Jul 2011 18:46:41 +0000 (11:46 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 23 Jul 2011 18:46:41 +0000 (11:46 -0700)
Previously, these symlinks would trigger a file collision message and
would then be silently dropped in cases when the file collsion did not
cause emerge to bail out due to FEATURES=protect-owned or
collision-protect.

Now, if emerge doesn't bail out due to a file collision, it will
trigger an eerror message and merge the symlink with a .backup.XXXX
extension appended to the file name, similar to handling of regular
files in commit 740f71301ed3daf44c0e77df5d5de39fe1438fb1. This will
fix bug 326685.

pym/portage/dbapi/vartree.py

index d61f7390ec4a357b0848d0b0d2b8db35788fe697..c7034155876433fd5a58ace82cc713987e6723d3 100644 (file)
@@ -3824,12 +3824,20 @@ class dblink(object):
                                myrealto = normalize_path(os.path.join(destroot, myabsto))
                                if mydmode!=None:
                                        #destination exists
-                                       if not stat.S_ISLNK(mydmode):
-                                               if stat.S_ISDIR(mydmode):
-                                                       # directory in the way: we can't merge a symlink over a directory
-                                                       # we won't merge this, continue with next file...
-                                                       continue
+                                       if stat.S_ISDIR(mydmode):
+                                               # we can't merge a symlink over a directory
+                                               newdest = self._new_backup_path(mydest)
+                                               msg = []
+                                               msg.append("")
+                                               msg.append(_("Installation of a symlink is blocked by a directory:"))
+                                               msg.append("  '%s'" % mydest)
+                                               msg.append(_("This symlink will be merged with a different name:"))
+                                               msg.append("  '%s'" % newdest)
+                                               msg.append("")
+                                               self._eerror("preinst", msg)
+                                               mydest = newdest
 
+                                       elif not stat.S_ISLNK(mydmode):
                                                if os.path.exists(mysrc) and stat.S_ISDIR(os.stat(mysrc)[stat.ST_MODE]):
                                                        # Kill file blocking installation of symlink to dir #71787
                                                        pass