For bug #182964, replace os.rename() with portage.movefile() in cases where the paren...
authorZac Medico <zmedico@gentoo.org>
Sun, 24 Jun 2007 00:32:05 +0000 (00:32 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 24 Jun 2007 00:32:05 +0000 (00:32 -0000)
svn path=/main/trunk/; revision=6983

pym/portage/__init__.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/vartree.py

index 17dc3089b1d488f0907571b424814040a6ee54d6..2818ae9dd4269f4696326fa06e877bb641fdcce1 100644 (file)
@@ -4011,6 +4011,12 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
 
 expandcache={}
 
+def _movefile(src, dest, **kwargs):
+       """Calls movefile and raises a PortageException if an error occurs."""
+       if movefile(src, dest, **kwargs) is None:
+               raise portage.exception.PortageException(
+                       "mv '%s' '%s'" % (src, dest))
+
 def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
        """moves a file from src to dest, preserving all permissions and attributes; mtime will
        be preserved even when moving across filesystems.  Returns true on success and false on
index 3242cc158f2c25bf28f2ae000e10d4ba35ecdd63..1930bc71d3b7a5df8cfd5589804838f49ab76a59 100644 (file)
@@ -10,7 +10,7 @@ from portage.util import normalize_path, writemsg, writemsg_stdout
 from portage.versions import best, catpkgsplit, catsplit
 from portage.update import update_dbentries
 
-from portage import listdir, dep_expand
+from portage import dep_expand, listdir, _movefile
 
 import portage.xpak, portage.getbinpkg
 
@@ -206,7 +206,7 @@ class binarytree(object):
                                        if e.errno != errno.EEXIST:
                                                raise
                                        del e
-                               os.rename(tbz2path, new_path)
+                               _movefile(tbz2path, new_path, mysettings=self.settings)
                                self._remove_symlink(mycpv)
                                if new_path.split(os.path.sep)[-2] == "All":
                                        self._create_symlink(mynewcpv)
@@ -299,7 +299,8 @@ class binarytree(object):
                                if e.errno != errno.EEXIST:
                                        raise
                                del e
-                       os.rename(src_path, os.path.join(self.pkgdir, "All", myfile))
+                       dest_path = os.path.join(self.pkgdir, "All", myfile)
+                       _movefile(src_path, dest_path, mysettings=self.settings)
                        self._create_symlink(cpv)
                self._pkg_paths[cpv] = os.path.join("All", myfile)
 
@@ -317,7 +318,8 @@ class binarytree(object):
                        if e.errno != errno.EEXIST:
                                raise
                        del e
-               os.rename(os.path.join(self.pkgdir, "All", myfile), dest_path)
+               src_path = os.path.join(self.pkgdir, "All", myfile)
+               _movefile(src_path, dest_path, mysettings=self.settings)
                self._pkg_paths[cpv] = mypath
 
        def populate(self, getbinpkgs=0, getbinpkgsonly=0):
@@ -681,7 +683,7 @@ class binarytree(object):
                        pkgindex_lock = lockfile(self._pkgindex_file,
                                wantnewlockfile=1)
                        if filename is not None:
-                               os.rename(filename, self.getname(cpv))
+                               _movefile(filename, self.getname(cpv), mysettings=self.settings)
                        if self._all_directory and \
                                self.getname(cpv).split(os.path.sep)[-2] == "All":
                                self._create_symlink(cpv)
index ef6becc72ed8fb01702ced4dd415fdf96adf6e54..d27f320d62aecd1980ec2662991325a35827b3ab 100644 (file)
@@ -22,7 +22,7 @@ from portage.versions import pkgsplit, catpkgsplit, catsplit, best, pkgcmp
 
 from portage import listdir, dep_expand, config, flatten, key_expand, \
        doebuild_environment, doebuild, env_update, \
-       abssymlink, movefile, bsd_chflags
+       abssymlink, movefile, _movefile, bsd_chflags
 
 import os, sys, stat, errno, commands, copy, time
 from itertools import izip
@@ -301,7 +301,7 @@ class vardbapi(dbapi):
                        if os.path.exists(newpath):
                                #dest already exists; keep this puppy where it is.
                                continue
-                       os.rename(origpath, newpath)
+                       _movefile(origpath, newpath, mysettings=self.settings)
 
                        # We need to rename the ebuild now.
                        old_pf = catsplit(mycpv)[1]
@@ -1758,7 +1758,7 @@ class dblink(object):
                # We hold both directory locks.
                self.dbdir = self.dbpkgdir
                self.delete()
-               movefile(self.dbtmpdir, self.dbpkgdir, mysettings=self.settings)
+               _movefile(self.dbtmpdir, self.dbpkgdir, mysettings=self.settings)
                contents = self.getcontents()
 
                #write out our collection of md5sums