summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-23 10:58:09 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-23 10:58:09 +0000
commitcfe5e7bc23c30dc40b90c1f61282d8f59430840a (patch)
tree79b41326afb062e1f3c5855917fc2a0dd40b5a13
parent0c93a2b77653ee55957e95b580d457459c4d5ab5 (diff)
downloadportage-cfe5e7bc23c30dc40b90c1f61282d8f59430840a.tar.gz
portage-cfe5e7bc23c30dc40b90c1f61282d8f59430840a.tar.bz2
portage-cfe5e7bc23c30dc40b90c1f61282d8f59430840a.zip
For bug #182964, replace os.rename() with shutil.move() in order to handle EXDEV errors that are triggered by layered filesystems.
svn path=/main/trunk/; revision=6967
-rw-r--r--pym/emerge/__init__.py7
-rw-r--r--pym/portage/dbapi/bintree.py10
-rw-r--r--pym/portage/dbapi/vartree.py8
-rw-r--r--pym/portage/dispatch_conf.py14
4 files changed, 21 insertions, 18 deletions
diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py
index 17ff8d58d..ac74f12d2 100644
--- a/pym/emerge/__init__.py
+++ b/pym/emerge/__init__.py
@@ -3754,14 +3754,17 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
icount=0
badcount=0
+ import shutil
for inforoot in regen_infodirs:
if inforoot=='':
continue
for filename in ("dir", "dir.gz", "dir.bz2"):
file_path = os.path.join(inforoot, filename)
+ if not os.path.exists(file_path):
+ continue
try:
- os.rename(file_path, file_path + ".old")
- except OSError, e:
+ shutil.move(file_path, file_path + ".old")
+ except EnvironmentError, e:
if e.errno != errno.ENOENT:
raise
del e
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 3242cc158..9e3ce0dd9 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -14,7 +14,7 @@ from portage import listdir, dep_expand
import portage.xpak, portage.getbinpkg
-import os, errno, stat
+import os, errno, shutil, stat
class bindbapi(fakedbapi):
def __init__(self, mybintree=None, settings=None):
@@ -206,7 +206,7 @@ class binarytree(object):
if e.errno != errno.EEXIST:
raise
del e
- os.rename(tbz2path, new_path)
+ shutil.move(tbz2path, new_path)
self._remove_symlink(mycpv)
if new_path.split(os.path.sep)[-2] == "All":
self._create_symlink(mynewcpv)
@@ -299,7 +299,7 @@ class binarytree(object):
if e.errno != errno.EEXIST:
raise
del e
- os.rename(src_path, os.path.join(self.pkgdir, "All", myfile))
+ shutil.move(src_path, os.path.join(self.pkgdir, "All", myfile))
self._create_symlink(cpv)
self._pkg_paths[cpv] = os.path.join("All", myfile)
@@ -317,7 +317,7 @@ class binarytree(object):
if e.errno != errno.EEXIST:
raise
del e
- os.rename(os.path.join(self.pkgdir, "All", myfile), dest_path)
+ shutil.move(os.path.join(self.pkgdir, "All", myfile), dest_path)
self._pkg_paths[cpv] = mypath
def populate(self, getbinpkgs=0, getbinpkgsonly=0):
@@ -681,7 +681,7 @@ class binarytree(object):
pkgindex_lock = lockfile(self._pkgindex_file,
wantnewlockfile=1)
if filename is not None:
- os.rename(filename, self.getname(cpv))
+ shutil.move(filename, self.getname(cpv))
if self._all_directory and \
self.getname(cpv).split(os.path.sep)[-2] == "All":
self._create_symlink(cpv)
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 641d4942b..c52fcb3b3 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -24,7 +24,7 @@ from portage import listdir, dep_expand, config, flatten, key_expand, \
doebuild_environment, doebuild, env_update, \
abssymlink, movefile, bsd_chflags
-import os, sys, stat, errno, commands, copy, time
+import commands, copy, errno, os, shutil, stat, sys
from itertools import izip
try:
@@ -301,14 +301,14 @@ class vardbapi(dbapi):
if os.path.exists(newpath):
#dest already exists; keep this puppy where it is.
continue
- os.rename(origpath, newpath)
+ shutil.move(origpath, newpath)
# We need to rename the ebuild now.
old_pf = catsplit(mycpv)[1]
new_pf = catsplit(mynewcpv)[1]
if new_pf != old_pf:
try:
- os.rename(os.path.join(newpath, old_pf + ".ebuild"),
+ shutil.move(os.path.join(newpath, old_pf + ".ebuild"),
os.path.join(newpath, new_pf + ".ebuild"))
except OSError, e:
if e.errno != errno.ENOENT:
@@ -1031,7 +1031,7 @@ class dblink(object):
if x[:-7] != self.pkg:
# Clean up after vardbapi.move_ent() breakage in
# portage versions before 2.1.2
- os.rename(os.path.join(self.dbdir, x), myebuildpath)
+ shutil.move(os.path.join(self.dbdir, x), myebuildpath)
write_atomic(os.path.join(self.dbdir, "PF"), self.pkg+"\n")
break
diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index 690772bf8..6df0146d5 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -7,7 +7,7 @@
# Library by Wayne Davison <gentoo@blorf.net>, derived from code
# written by Jeremy Wohl (http://igmus.org)
-from stat import *
+from stat import ST_GID, ST_MODE, ST_UID
import os, sys, commands, shutil
import portage
@@ -72,7 +72,7 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
os.system(RCS_GET + ' -r' + RCS_BRANCH + ' ' + archive)
has_branch = os.path.exists(archive)
if has_branch:
- os.rename(archive, archive + '.dist')
+ shutil.move(archive, archive + '.dist')
try:
shutil.copy2(newconf, archive)
@@ -87,7 +87,7 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
mystat = os.lstat(newconf)
os.chmod(mrgconf, mystat[ST_MODE])
os.chown(mrgconf, mystat[ST_UID], mystat[ST_GID])
- os.rename(archive, archive + '.dist.new')
+ shutil.move(archive, archive + '.dist.new')
return ret
@@ -112,10 +112,10 @@ def file_archive(archive, curconf, newconf, mrgconf):
suf += 1
while suf > 1:
- os.rename(archive + '.' + str(suf-1), archive + '.' + str(suf))
+ shutil.move(archive + '.' + str(suf-1), archive + '.' + str(suf))
suf -= 1
- os.rename(archive, archive + '.1')
+ shutil.move(archive, archive + '.1')
try:
shutil.copy2(curconf, archive)
@@ -145,7 +145,7 @@ def file_archive(archive, curconf, newconf, mrgconf):
def rcs_archive_post_process(archive):
"""Check in the archive file with the .dist.new suffix on the branch
and remove the one with the .dist suffix."""
- os.rename(archive + '.dist.new', archive)
+ shutil.move(archive + '.dist.new', archive)
if os.path.exists(archive + '.dist'):
# Commit the last-distributed version onto the branch.
os.system(RCS_LOCK + RCS_BRANCH + ' ' + archive)
@@ -158,4 +158,4 @@ def rcs_archive_post_process(archive):
def file_archive_post_process(archive):
"""Rename the archive file with the .dist.new suffix to a .dist suffix"""
- os.rename(archive + '.dist.new', archive + '.dist')
+ shutil.move(archive + '.dist.new', archive + '.dist')