summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-09-25 15:33:33 +0000
committerZac Medico <zmedico@gentoo.org>2007-09-25 15:33:33 +0000
commitfabc613fbacc9dddbc765a30d6e49431b8726ba9 (patch)
treed2bde17dbcd35c270a62c322fc63da077c6b0c2c
parent3a453007c572d4048c8eea7475e6a4c35b6de281 (diff)
downloadportage-fabc613fbacc9dddbc765a30d6e49431b8726ba9.tar.gz
portage-fabc613fbacc9dddbc765a30d6e49431b8726ba9.tar.bz2
portage-fabc613fbacc9dddbc765a30d6e49431b8726ba9.zip
Bug #193695 - Add FreeBSD chflags support for rmdir()
calls during unmerge. svn path=/main/trunk/; revision=7807
-rw-r--r--pym/portage/dbapi/vartree.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index ddf8c8328..fda5a2278 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -1331,7 +1331,22 @@ class dblink(object):
for obj in mydirs:
try:
- os.rmdir(obj)
+ if bsd_chflags:
+ lstatobj = os.lstat(obj)
+ if lstatobj.st_flags != 0:
+ bsd_chflags.lchflags(obj, 0)
+ parent_name = os.path.dirname(obj)
+ # Use normal stat/chflags for the parent since we want to
+ # follow any symlinks to the real parent directory.
+ pflags = os.stat(parent_name).st_flags
+ if pflags != 0:
+ bsd_chflags.chflags(parent_name, 0)
+ try:
+ os.rmdir(obj)
+ finally:
+ if bsd_chflags and pflags != 0:
+ # Restore the parent flags we saved before unlinking
+ bsd_chflags.chflags(parent_name, pflags)
show_unmerge("<<<", "", "dir", obj)
except EnvironmentError, e:
if e.errno not in (errno.ENOENT,