Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH 3/3] portage.dbapi.vartree: Support exclusions in INSTALL_MASK
Date: Thu, 15 Mar 2018 21:02:55
Message-Id: CAAr7Pr__jVz0baqYNe-RGmJs38YA_EAisgWua-Mz3VvkoF7H3g@mail.gmail.com
In Reply to: [gentoo-portage-dev] [PATCH 3/3] portage.dbapi.vartree: Support exclusions in INSTALL_MASK by "Michał Górny"
1 On Thu, Mar 15, 2018 at 3:22 PM, Michał Górny <mgorny@g.o> wrote:
2
3 > Allow INSTALL_MASK patterns to start with '-' to indicate that
4 > a specific match is to be excluded from being masked. In this case,
5 > the last matching pattern determines whether the file is actually
6 > filtered out or kept.
7 > ---
8 > pym/portage/dbapi/vartree.py | 10 ++++++----
9 > 1 file changed, 6 insertions(+), 4 deletions(-)
10 >
11 > diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
12 > index 21904edca..16c246b11 100644
13 > --- a/pym/portage/dbapi/vartree.py
14 > +++ b/pym/portage/dbapi/vartree.py
15 > @@ -3692,19 +3692,21 @@ class dblink(object):
16 > def _is_install_masked(self, relative_path):
17 > ret = False
18 > for pattern in self.settings.install_mask:
19 >
20 + # if pattern starts with -, possibly exclude this
21 > path
22 > + pat_res = not pattern.startswith('-')
23 > + if not pat_res:
24 > + pattern = pattern[1:]
25 >
26
27 Maybe consider:
28
29 pattern = pattern[1:] if pattern.startswith('-') else pattern
30
31 I'm not super keen on this pattern in python, but it seems doable here.
32
33
34 > # absolute path pattern
35 > if pattern.startswith('/'):
36 > # match either exact path or one of parent
37 > dirs
38 > # the latter is done via matching pattern/*
39 > if (fnmatch.fnmatch(relative_path,
40 > pattern[1:])
41 > or
42 > fnmatch.fnmatch(relative_path, pattern[1:] + '/*')):
43 > - ret = True
44 > - break
45 > + ret = pat_res
46 > # filename
47 > else:
48 > if fnmatch.fnmatch(os.path.basename(relative_path),
49 > pattern):
50 > - ret = True
51 > - break
52 > + ret = pat_res
53 > return ret
54 >
55 > def treewalk(self, srcroot, destroot, inforoot, myebuild,
56 > cleanup=0,
57 > --
58 > 2.16.2
59 >
60 >
61 >

Replies