From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1AB0E138334 for ; Sat, 14 Jul 2018 23:58:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5C721E0830; Sat, 14 Jul 2018 23:58:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 30C07E0830 for ; Sat, 14 Jul 2018 23:58:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2868B335C9A for ; Sat, 14 Jul 2018 23:58:40 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A057D300 for ; Sat, 14 Jul 2018 23:58:38 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1531612469.3a25c3fa13d7c62ba8c00d6c7a75eb907d34b568.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: 3a25c3fa13d7c62ba8c00d6c7a75eb907d34b568 X-VCS-Branch: master Date: Sat, 14 Jul 2018 23:58:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 3d03b08e-1951-4f74-b2ef-be6aebdf1b66 X-Archives-Hash: 7bbe28d11431609a7a56ebac2bb8e236 commit: 3a25c3fa13d7c62ba8c00d6c7a75eb907d34b568 Author: Zac Medico gentoo org> AuthorDate: Fri Jul 13 03:58:04 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Jul 14 23:54:29 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3a25c3fa _unmerge_dirs: revisit parents of removed symlinks (bug 640058) When removal of a symlink is triggered by removal of the directory that it points to, revisit the parent directories of the symlink. Bug: https://bugs.gentoo.org/640058 Reviewed-by: Brian Dolbec gentoo.org> pym/portage/dbapi/vartree.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 1a86940f1..a104306eb 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -2753,9 +2753,13 @@ class dblink(object): real_root = self.settings['ROOT'] dirs = sorted(dirs) - dirs.reverse() + revisit = {} - for obj, inode_key in dirs: + while True: + try: + obj, inode_key = dirs.pop() + except IndexError: + break # Treat any directory named "info" as a candidate here, # since it might have been in INFOPATH previously even # though it may not be there now. @@ -2818,6 +2822,7 @@ class dblink(object): raise if e.errno != errno.ENOENT: show_unmerge("---", unmerge_desc["!empty"], "dir", obj) + revisit[obj] = inode_key # Since we didn't remove this directory, record the directory # itself for use in syncfs calls, if we have removed another @@ -2838,6 +2843,7 @@ class dblink(object): # no need to protect symlinks that point to it. unmerge_syms = protected_symlinks.pop(inode_key, None) if unmerge_syms is not None: + parents = [] for relative_path in unmerge_syms: obj = os.path.join(real_root, relative_path.lstrip(os.sep)) @@ -2849,6 +2855,21 @@ class dblink(object): raise del e show_unmerge("!!!", "", "sym", obj) + else: + parents.append(os.path.dirname(obj)) + + if parents: + # Revisit parents recursively (bug 640058). + recursive_parents = [] + for parent in set(parents): + while parent in revisit: + recursive_parents.append(parent) + parent = os.path.dirname(parent) + if parent == '/': + break + + for parent in sorted(set(recursive_parents)): + dirs.append((parent, revisit.pop(parent))) def isowner(self, filename, destroot=None): """