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 B908C1382C5 for ; Thu, 15 Mar 2018 19:22:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8CA28E0921; Thu, 15 Mar 2018 19:22:23 +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 5CC21E0922 for ; Thu, 15 Mar 2018 19:22:23 +0000 (UTC) Received: from localhost.localdomain (d202-252.icpnet.pl [109.173.202.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id BD1EB335C77; Thu, 15 Mar 2018 19:22:21 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-portage-dev] [PATCH 3/3] portage.dbapi.vartree: Support exclusions in INSTALL_MASK Date: Thu, 15 Mar 2018 20:22:11 +0100 Message-Id: <20180315192212.13454-4-mgorny@gentoo.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180315192212.13454-1-mgorny@gentoo.org> References: <20180315192212.13454-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 1f59cef0-bfa3-4ec5-b0f1-942150761d8d X-Archives-Hash: da2c057c9821c8d79b236409d7a3d303 Allow INSTALL_MASK patterns to start with '-' to indicate that a specific match is to be excluded from being masked. In this case, the last matching pattern determines whether the file is actually filtered out or kept. --- pym/portage/dbapi/vartree.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 21904edca..16c246b11 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -3692,19 +3692,21 @@ class dblink(object): def _is_install_masked(self, relative_path): ret = False for pattern in self.settings.install_mask: + # if pattern starts with -, possibly exclude this path + pat_res = not pattern.startswith('-') + if not pat_res: + pattern = pattern[1:] # absolute path pattern if pattern.startswith('/'): # match either exact path or one of parent dirs # the latter is done via matching pattern/* if (fnmatch.fnmatch(relative_path, pattern[1:]) or fnmatch.fnmatch(relative_path, pattern[1:] + '/*')): - ret = True - break + ret = pat_res # filename else: if fnmatch.fnmatch(os.path.basename(relative_path), pattern): - ret = True - break + ret = pat_res return ret def treewalk(self, srcroot, destroot, inforoot, myebuild, cleanup=0, -- 2.16.2