From fabc613fbacc9dddbc765a30d6e49431b8726ba9 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 25 Sep 2007 15:33:33 +0000 Subject: [PATCH] Bug #193695 - Add FreeBSD chflags support for rmdir() calls during unmerge. svn path=/main/trunk/; revision=7807 --- pym/portage/dbapi/vartree.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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, -- 2.26.2