From 8d2522f15de684808a850bb946c284c3a0bfcb2c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 24 Sep 2007 23:25:57 +0000 Subject: Bugs #168772 and #193695 - During unmerge, only ignore specific exceptions raised from unlink() and rmdir() calls. svn path=/main/trunk/; revision=7804 --- pym/portage/dbapi/vartree.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'pym') diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 5ff8e1e33..71ccdf183 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1184,6 +1184,7 @@ class dblink(object): #process symlinks second-to-last, directories last. mydirs = [] + ignored_unlink_errnos = (errno.ENOENT, errno.EISDIR) modprotect = os.path.join(self.vartree.root, "lib/modules/") def show_unmerge(zing, desc, file_type, file_name): writemsg_stdout("%s %s %s %s\n" % \ @@ -1240,7 +1241,9 @@ class dblink(object): os.chmod(obj, 0) os.unlink(obj) except EnvironmentError, e: - pass + if e.errno not in ignored_unlink_errnos: + raise + del e show_unmerge("<<<", "", file_type, obj) continue @@ -1269,6 +1272,9 @@ class dblink(object): os.unlink(obj) show_unmerge("<<<", "", file_type, obj) except (OSError, IOError),e: + if e.errno not in ignored_unlink_errnos: + raise + del e show_unmerge("!!!", "", file_type, obj) elif pkgfiles[objkey][0] == "obj": if statobj is None or not stat.S_ISREG(statobj.st_mode): @@ -1294,7 +1300,9 @@ class dblink(object): os.chmod(obj, 0) os.unlink(obj) except (OSError, IOError), e: - pass + if e.errno not in ignored_unlink_errnos: + raise + del e show_unmerge("<<<", "", file_type, obj) elif pkgfiles[objkey][0] == "fif": if not stat.S_ISFIFO(lstatobj[stat.ST_MODE]): @@ -1311,8 +1319,14 @@ class dblink(object): try: os.rmdir(obj) show_unmerge("<<<", "", "dir", obj) - except EnvironmentError: - show_unmerge("---", "!empty", "dir", obj) + except EnvironmentError, e: + if e.errno not in (errno.ENOENT, + errno.EEXIST, errno.ENOTEMPTY, + errno.ENOTDIR): + raise + if e.errno != errno.ENOENT: + show_unmerge("---", "!empty", "dir", obj) + del e #remove self from vartree database so that our own virtual gets zapped if we're the last node self.vartree.zap(self.mycpv) -- cgit v1.2.3-1-g7c22