1 |
On 05/21/2016 11:56 PM, Michał Górny wrote: |
2 |
> Allow INSTALL_MASK patterns to start with '-' to indicate that |
3 |
> a specific match is to be excluded from being masked. In this case, |
4 |
> the last matching pattern determines whether the file is actually |
5 |
> filtered out or kept. |
6 |
> --- |
7 |
> pym/portage/dbapi/vartree.py | 10 ++++++---- |
8 |
> 1 file changed, 6 insertions(+), 4 deletions(-) |
9 |
> |
10 |
> diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py |
11 |
> index 8e5ac43..d02d850 100644 |
12 |
> --- a/pym/portage/dbapi/vartree.py |
13 |
> +++ b/pym/portage/dbapi/vartree.py |
14 |
> @@ -3690,19 +3690,21 @@ class dblink(object): |
15 |
> def _is_install_masked(self, relative_path): |
16 |
> ret = False |
17 |
> for pattern in self.settings.install_mask: |
18 |
> + # if pattern starts with -, possibly exclude this path |
19 |
> + pat_res = not pattern.startswith('-') |
20 |
> + if not pat_res: |
21 |
> + pattern = pattern[1:] |
22 |
> # absolute path pattern |
23 |
> if pattern.startswith('/'): |
24 |
> # match either exact path or one of parent dirs |
25 |
> # the latter is done via matching pattern/* |
26 |
> if (fnmatch.fnmatch(relative_path, pattern[1:]) |
27 |
> or fnmatch.fnmatch(relative_path, pattern[1:] + '/*')): |
28 |
> - ret = True |
29 |
> - break |
30 |
> + ret = pat_res |
31 |
> # filename |
32 |
> else: |
33 |
> if fnmatch.fnmatch(os.path.basename(relative_path), pattern): |
34 |
> - ret = True |
35 |
> - break |
36 |
> + ret = pat_res |
37 |
> return ret |
38 |
> |
39 |
> def treewalk(self, srcroot, destroot, inforoot, myebuild, cleanup=0, |
40 |
> |
41 |
|
42 |
In order to implement this with pre-compiled patterns, we can use a |
43 |
separate regular expression to represent all of the exclusions. |
44 |
-- |
45 |
Thanks, |
46 |
Zac |