1 |
From: Michał Górny <mgorny@g.o> |
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 |
Bug: https://bugs.gentoo.org/651214 |
9 |
--- |
10 |
pym/portage/util/install_mask.py | 10 ++++++---- |
11 |
1 file changed, 6 insertions(+), 4 deletions(-) |
12 |
|
13 |
diff --git a/pym/portage/util/install_mask.py b/pym/portage/util/install_mask.py |
14 |
index 64fe0b21a..92989d71d 100644 |
15 |
--- a/pym/portage/util/install_mask.py |
16 |
+++ b/pym/portage/util/install_mask.py |
17 |
@@ -29,19 +29,21 @@ class InstallMask(object): |
18 |
""" |
19 |
ret = False |
20 |
for pattern in self._install_mask: |
21 |
+ # if pattern starts with -, possibly exclude this path |
22 |
+ is_inclusive = not pattern.startswith('-') |
23 |
+ if not is_inclusive: |
24 |
+ pattern = pattern[1:] |
25 |
# absolute path pattern |
26 |
if pattern.startswith('/'): |
27 |
# match either exact path or one of parent dirs |
28 |
# the latter is done via matching pattern/* |
29 |
if (fnmatch.fnmatch(path, pattern[1:]) |
30 |
or fnmatch.fnmatch(path, pattern[1:] + '/*')): |
31 |
- ret = True |
32 |
- break |
33 |
+ ret = is_inclusive |
34 |
# filename |
35 |
else: |
36 |
if fnmatch.fnmatch(os.path.basename(path), pattern): |
37 |
- ret = True |
38 |
- break |
39 |
+ ret = is_inclusive |
40 |
return ret |
41 |
|
42 |
|
43 |
-- |
44 |
2.13.6 |