diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-10-03 22:27:11 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-10-03 22:27:11 +0000 |
commit | 78b064f4c9835263c3732312cb43a19b2df93fb7 (patch) | |
tree | 00d4bc06e2ddcce925c2168bb01cb89202ff3d28 | |
parent | db7df127e50599518290e5f7e6e4fed2d8267483 (diff) | |
download | portage-2.2_rc43.tar.gz portage-2.2_rc43.tar.bz2 portage-2.2_rc43.zip |
Generate an eerror message in dblink.mergeme when a file has to be renamed inv2.2_rc43
order to merge a directory to the same path.
svn path=/main/trunk/; revision=14485
-rw-r--r-- | pym/portage/dbapi/vartree.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 1bf05f14e..c46bcdfec 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -3963,6 +3963,26 @@ class dblink(object): return os.EX_OK + def _new_backup_path(self, p): + """ + The works for any type path, such as a regular file, symlink, + or directory. The parent directory is assumed to exist. + The returned filename is of the form p + '.backup.' + x, where + x guarantees that the returned path does not exist yet. + """ + os = _os_merge + + x = -1 + while True: + x += 1 + backup_p = p + '.backup.' + str(x).rjust(4, '0') + try: + os.lstat(backup_p) + except OSError: + break + + return backup_p + def mergeme(self, srcroot, destroot, outfile, secondhand, stufftomerge, cfgfiledict, thismtime): """ @@ -4120,7 +4140,16 @@ class dblink(object): bsd_chflags.lchflags(mydest, dflags) else: # a non-directory and non-symlink-to-directory. Won't work for us. Move out of the way. - if movefile(mydest, mydest+".backup", + backup_dest = self._new_backup_path(mydest) + msg = [] + msg.append("") + msg.append("Installation of a directory is blocked by a file:") + msg.append(" '%s'" % mydest) + msg.append("This file will be renamed to a different name:") + msg.append(" '%s'" % backup_dest) + msg.append("") + self._eerror("preinst", msg) + if movefile(mydest, backup_dest, mysettings=self.settings, encoding=_encodings['merge']) is None: return 1 @@ -4164,7 +4193,7 @@ class dblink(object): if stat.S_ISDIR(mydmode): # install of destination is blocked by an existing directory with the same name - newdest = new_protect_filename(mydest, newmd5=mymd5) + newdest = self._new_backup_path(mydest) msg = [] msg.append("") msg.append("Installation of a regular file is blocked by a directory:") |