From: Zac Medico Date: Tue, 25 Sep 2007 15:33:33 +0000 (-0000) Subject: Bug #193695 - Add FreeBSD chflags support for rmdir() X-Git-Tag: v2.2_pre1~779 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fabc613fbacc9dddbc765a30d6e49431b8726ba9;p=portage.git Bug #193695 - Add FreeBSD chflags support for rmdir() calls during unmerge. svn path=/main/trunk/; revision=7807 --- 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,