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 A6D881382C5 for ; Thu, 15 Mar 2018 21:17:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D3A60E094B; Thu, 15 Mar 2018 21:17:09 +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 9D427E094A for ; Thu, 15 Mar 2018 21:17:09 +0000 (UTC) Received: from pomiot (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 07EAC335C73; Thu, 15 Mar 2018 21:17:06 +0000 (UTC) Message-ID: <1521148623.1184.0.camel@gentoo.org> Subject: Re: [gentoo-portage-dev] [PATCH 3/3] portage.dbapi.vartree: Support exclusions in INSTALL_MASK From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Date: Thu, 15 Mar 2018 22:17:03 +0100 In-Reply-To: References: <20180315192212.13454-1-mgorny@gentoo.org> <20180315192212.13454-4-mgorny@gentoo.org> Organization: Gentoo Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.24.6 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 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 8785f576-7d93-4263-9304-c54c4e3f42ee X-Archives-Hash: ed2a8e4831d6d130930c7bcc724af2b0 W dniu czw, 15.03.2018 o godzinie 17∶02 -0400, użytkownik Alec Warner napisał: > On Thu, Mar 15, 2018 at 3:22 PM, Michał Górny wrote: > > > 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:] > > > > Maybe consider: > > pattern = pattern[1:] if pattern.startswith('-') else pattern > > I'm not super keen on this pattern in python, but it seems doable here. I still need pat_res to know whether it's '+' or '-'. > > > > # 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 > > > > > > -- Best regards, Michał Górny