From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QnrfY-0007m5-8S for garchives@archives.gentoo.org; Mon, 01 Aug 2011 12:32:28 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 27E6D21C11C; Mon, 1 Aug 2011 12:32:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id DC6C421C11C for ; Mon, 1 Aug 2011 12:32:18 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 556F31B401F for ; Mon, 1 Aug 2011 12:32:18 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 6BDA43C004 for ; Mon, 1 Aug 2011 12:32:17 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <40f45506b5971073c8a60f172c3171eaf9cad3a6.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dbapi/vartree.py X-VCS-Directories: pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 40f45506b5971073c8a60f172c3171eaf9cad3a6 Date: Mon, 1 Aug 2011 12:32:17 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 2d3852a51baf4cd99a7137d78988f5a8 commit: 40f45506b5971073c8a60f172c3171eaf9cad3a6 Author: Zac Medico gentoo org> AuthorDate: Mon Aug 1 12:32:00 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Aug 1 12:32:00 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D40f45506 unmerge: unmerge symlinks broken by rmdir This prevents some more false alarms from commit 4bb08136f073024c5d31dceb1618b6f4e7246369. --- pym/portage/dbapi/vartree.py | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 6317af7..58584d7 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1909,7 +1909,7 @@ class dblink(object): =20 cfgfiledict =3D grabdict(self.vartree.dbapi._conf_mem_file) stale_confmem =3D [] - protected_symlinks =3D [] + protected_symlinks =3D {} =20 unmerge_orphans =3D "unmerge-orphans" in self.settings.features calc_prelink =3D "prelink-checksums" in self.settings.features @@ -2054,7 +2054,9 @@ class dblink(object): break =20 if symlink_orphan: - protected_symlinks.append(relative_path) + protected_symlinks.setdefault( + (statobj.st_dev, statobj.st_ino), + []).append(relative_path) =20 if is_owned: show_unmerge("---", unmerge_desc["replaced"], file_type, obj) @@ -2098,7 +2100,7 @@ class dblink(object): if lstatobj is None or not stat.S_ISDIR(lstatobj.st_mode): show_unmerge("---", unmerge_desc["!dir"], file_type, obj) continue - mydirs.add(obj) + mydirs.add((obj, (lstatobj.st_dev, lstatobj.st_ino))) elif pkgfiles[objkey][0] =3D=3D "sym": if not islink: show_unmerge("---", unmerge_desc["!sym"], file_type, obj) @@ -2144,7 +2146,9 @@ class dblink(object): break =20 if not all_owned: - protected_symlinks.append(relative_path) + protected_symlinks.setdefault( + (statobj.st_dev, statobj.st_ino), + []).append(relative_path) show_unmerge("---", unmerge_desc["!empty"], file_type, obj) continue @@ -2199,7 +2203,7 @@ class dblink(object): mydirs =3D sorted(mydirs) mydirs.reverse() =20 - for obj in mydirs: + for obj, inode_key in mydirs: try: if bsd_chflags: lstatobj =3D os.lstat(obj) @@ -2224,6 +2228,22 @@ class dblink(object): if e.errno !=3D errno.ENOENT: show_unmerge("---", unmerge_desc["!empty"], "dir", obj) del e + else: + # When a directory is successfully removed, there's + # no need to protect symlinks that point to it. + unmerge_syms =3D protected_symlinks.pop(inode_key, None) + if unmerge_syms is not None: + for relative_path in unmerge_syms: + obj =3D os.path.join(real_root, + relative_path.lstrip(os.sep)) + try: + unlink(obj, os.lstat(obj)) + show_unmerge("<<<", "", "sym", obj) + except (OSError, IOError) as e: + if e.errno not in ignored_unlink_errnos: + raise + del e + show_unmerge("!!!", "", "sym", obj) =20 if protected_symlinks: msg =3D "One or more symlinks to directories have been " + \ @@ -2231,8 +2251,10 @@ class dblink(object): "via these symlinks remain accessible:" lines =3D textwrap.wrap(msg, 72) lines.append("") - protected_symlinks.reverse() - for f in protected_symlinks: + flat_list =3D set() + flat_list.update(*protected_symlinks.values()) + flat_list =3D sorted(flat_list, reverse=3DTrue) + for f in flat_list: lines.append("\t%s" % (os.path.join(real_root, f.lstrip(os.sep)))) lines.append("")