summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-12-25 01:13:15 +0000
committerZac Medico <zmedico@gentoo.org>2008-12-25 01:13:15 +0000
commit08802d747eb76d52d15c8b5867eccf685d4464a0 (patch)
tree7caae93ebed666c90b15735992b3c2caf32bb636
parentSimplify the code from bug #218854. Also, ensure that the set of visible pack... (diff)
downloadportage-multirepo-08802d747eb76d52d15c8b5867eccf685d4464a0.tar.gz
portage-multirepo-08802d747eb76d52d15c8b5867eccf685d4464a0.tar.bz2
portage-multirepo-08802d747eb76d52d15c8b5867eccf685d4464a0.zip
Bug #252243 - Fix binarytree.prevent_collision() so that it won't create a circular
symlink if there happens to be a symlink in $PKGDIR/All for some reason. (trunk r12280) svn path=/main/branches/2.1.6/; revision=12311
-rw-r--r--pym/portage/dbapi/bintree.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 04f598a1..c71567f8 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -322,7 +322,21 @@ class binarytree(object):
myfile = mypkg + ".tbz2"
mypath = os.path.join("All", myfile)
dest_path = os.path.join(self.pkgdir, mypath)
- if os.path.exists(dest_path):
+
+ try:
+ st = os.lstat(dest_path)
+ except OSError:
+ st = None
+ else:
+ if stat.S_ISLNK(st.st_mode):
+ st = None
+ try:
+ os.unlink(dest_path)
+ except OSError:
+ if os.path.exist(dest_path):
+ raise
+
+ if st is not None:
# For invalid packages, other_cat could be None.
other_cat = portage.xpak.tbz2(dest_path).getfile("CATEGORY")
if other_cat:
@@ -330,11 +344,7 @@ class binarytree(object):
other_cpv = other_cat + "/" + mypkg
self._move_from_all(other_cpv)
self.inject(other_cpv)
- """The file may or may not exist. Move it if necessary and update
- internal state for future calls to getname()."""
self._move_to_all(cpv)
- if os.path.exists(full_path):
- self.inject(cpv)
def _ensure_dir(self, path):
"""
@@ -361,6 +371,7 @@ class binarytree(object):
for future getname() calls."""
mycat, mypkg = catsplit(cpv)
myfile = mypkg + ".tbz2"
+ self._pkg_paths[cpv] = os.path.join("All", myfile)
src_path = os.path.join(self.pkgdir, mycat, myfile)
try:
mystat = os.lstat(src_path)
@@ -371,7 +382,7 @@ class binarytree(object):
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)
+ self.inject(cpv)
def _move_from_all(self, cpv):
"""Move a package from ${PKGDIR}/All/${PF}.tbz2 to