summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-24 00:39:02 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-24 00:39:02 +0000
commitd57bf2d1fcd5b2b935266c90ac903ef0da2ff294 (patch)
tree454d049f45bd39ed214731be1ed9efd990595d17 /pym
parentd991c870472a1de90ee56aa0b31cc5d2d390e562 (diff)
downloadportage-d57bf2d1fcd5b2b935266c90ac903ef0da2ff294.tar.gz
portage-d57bf2d1fcd5b2b935266c90ac903ef0da2ff294.tar.bz2
portage-d57bf2d1fcd5b2b935266c90ac903ef0da2ff294.zip
For bug #182964, replace os.rename() with portage.movefile() in cases where the parent directory might change. (trunk r6983)
svn path=/main/branches/2.1.2/; revision=6984
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/pym/portage.py b/pym/portage.py
index d2f2cb027..afc285eb5 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -3906,6 +3906,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
@@ -5264,7 +5270,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]
@@ -6489,7 +6495,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)
@@ -6587,7 +6593,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)
@@ -6605,7 +6612,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):
@@ -7684,7 +7692,7 @@ class dblink:
# 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