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