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 787EC1382C5 for ; Thu, 15 Mar 2018 21:02:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1B4F6E0924; Thu, 15 Mar 2018 21:02:53 +0000 (UTC) Received: from mail-ua0-x241.google.com (mail-ua0-x241.google.com [IPv6:2607:f8b0:400c:c08::241]) (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 D5FA7E0922 for ; Thu, 15 Mar 2018 21:02:52 +0000 (UTC) Received: by mail-ua0-x241.google.com with SMTP id n24so5274125ual.12 for ; Thu, 15 Mar 2018 14:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptkitty-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=po8TRdouwjrA56aI/mfvov3IesvipPaWfjqfv2EEn6I=; b=KQ6O0Z8uPqtDAwWOwVh5vst1KIe+PdbQ0P0+3fSx6o6bw0H1YruWHD1kzZnyRggIyX AzkKeve0R0358r2phagxGL750JTjET+mBdGa97QiWI2SWpKWp4zOQc9z7AHxO5Wk0dxO FsNHsnSV++/FkJKiimR/N2BBBSXW4HmT/8d9McpuMx8ybU4+dY0km7UQkFbrDfzu+qU3 wdJX7JmY1CnU8C4uTbFh9wNwa0Ep5J3R7QozcRJtLLSzaxLgiaQqr18//7yY2beqOsjh sb+7J1JJ6aadYd+h1fIWMMzl/lPlnaUAQbX1kAibB21QefNFq65cpEPyikyFDUK4MAl4 QSSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=po8TRdouwjrA56aI/mfvov3IesvipPaWfjqfv2EEn6I=; b=pWj2MGAqoBqBTV4yVrjHX/3kv+yZiz2tQUprJN9XyRqQGVqJBltzRGgAtCS2TPeQkc vM2n5jFc17xZTMUBH+FHNpTWmdqxc5q1fDRifrjE4xXkwapzE7dre9zzeSGr+qKFrQ1K 3wN7LQ4h5NQCsZHgJx2rsjHubiX26eMgGaYxjorlTivctSaMUIX5GlAArPPW/M8btmVh edmspr4wEJQBU/cj0cAcCY/W8wED4QBpyujcB++eqfIG8KFe4itFICf5tq4Vn2swcuoa ozlGlE60pQibur3mwi9LVFsW3HY7YquRkBt+mzEPdL48dA5b4KxypASMZsSVS410UGho 769g== X-Gm-Message-State: AElRT7Gvw85/oHSNv1ZLPmGDbIWoQVMDMSf437X3pbtkKLbjkKVIdc6r NM6Tg6RvPBWYb9mKBvjO6M6qfAmGxzSmY2u7Z7eEjxAr X-Google-Smtp-Source: AG47ELsZ534eYmw6bpfE7n3in48hSANHAEmZOTQ/75hxU8aIDIT5uMueB29vaTUMlahPBKRg4YILXl0iVVmG8wQwlIQ= X-Received: by 10.176.1.39 with SMTP id 36mr3412187uak.27.1521147771506; Thu, 15 Mar 2018 14:02:51 -0700 (PDT) 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 Sender: antarus@scriptkitty.com Received: by 10.176.85.93 with HTTP; Thu, 15 Mar 2018 14:02:50 -0700 (PDT) X-Originating-IP: [2620:0:1003:512:b149:b6a3:fe9c:dac0] In-Reply-To: <20180315192212.13454-4-mgorny@gentoo.org> References: <20180315192212.13454-1-mgorny@gentoo.org> <20180315192212.13454-4-mgorny@gentoo.org> From: Alec Warner Date: Thu, 15 Mar 2018 17:02:50 -0400 X-Google-Sender-Auth: W3ZejjkzRCr4ZgOZCrzlTOSrPrA Message-ID: Subject: Re: [gentoo-portage-dev] [PATCH 3/3] portage.dbapi.vartree: Support exclusions in INSTALL_MASK To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= Content-Type: multipart/alternative; boundary="001a113d165892a475056779d069" X-Archives-Salt: a126620f-1db7-4473-a6ff-1ee26878cc3c X-Archives-Hash: b905781624590e0d00e0a5ac34f7ee17 --001a113d165892a475056779d069 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 15, 2018 at 3:22 PM, Micha=C5=82 G=C3=B3rny = 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 =3D False > for pattern in self.settings.install_mask: > + # if pattern starts with -, possibly exclude this > path > + pat_res =3D not pattern.startswith('-') > + if not pat_res: > + pattern =3D pattern[1:] > Maybe consider: pattern =3D pattern[1:] if pattern.startswith('-') else pattern I'm not super keen on this pattern in python, but it seems doable here. > # absolute path pattern > if pattern.startswith('/'): > # match either exact path or one of paren= t > dirs > # the latter is done via matching pattern= /* > if (fnmatch.fnmatch(relative_path, > pattern[1:]) > or > fnmatch.fnmatch(relative_path, pattern[1:] + '/*')): > - ret =3D True > - break > + ret =3D pat_res > # filename > else: > if fnmatch.fnmatch(os.path.basename(relat= ive_path), > pattern): > - ret =3D True > - break > + ret =3D pat_res > return ret > > def treewalk(self, srcroot, destroot, inforoot, myebuild, > cleanup=3D0, > -- > 2.16.2 > > > --001a113d165892a475056779d069 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Thu, Mar 15, 2018 at 3:22 PM, Micha=C5=82 G=C3=B3rny <mgorny@gentoo= .org> 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.
---
=C2=A0pym/portage/dbapi/vartree.py | 10 ++++++----
=C2=A01 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):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 def _is_install_masked(self, relative_path): =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ret =3D False
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for pattern in self= .settings.install_mask:
+=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0# if pattern starts with -, possibly exclude this path
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0pat_res =3D not pattern.startswith('-')
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if not pat_res:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pattern =3D pattern[1:]

Maybe consider:

pattern =3D pattern[1:] if pattern.startswith('-') e= lse pattern

I'm not super keen on this pattern in p= ython, but it seems doable here.
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 # absolute path pattern
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 if pattern.startswith('/'):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # match either exact path or one of = parent dirs
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # the latter is done via matching pa= ttern/*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (fnmatch.fnmatch(relative_pa= th, pattern[1:])
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 or fnmatch.fnmatch(relative_path, pattern[1:] + '/= *')):
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D T= rue
-=C2=A0 =C2=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0 =C2=A0 =C2=A0ret =3D p= at_res
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return ret

=C2=A0 =C2=A0 =C2=A0 =C2=A0 def treewalk(self, srcroot, destroot, inforoot,= myebuild, cleanup=3D0,
--
2.16.2



--001a113d165892a475056779d069--