commit:     8f9cff73321b3ee5957357448819b505932e0e5c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 06:40:13 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Mar 28 06:28:17 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8f9cff73

{,PKG_}INSTALL_MASK: Support exclusions (bug 651214)

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.

Bug: https://bugs.gentoo.org/651214

 pym/portage/util/install_mask.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/pym/portage/util/install_mask.py b/pym/portage/util/install_mask.py
index 506e63c1f..1667d883a 100644
--- a/pym/portage/util/install_mask.py
+++ b/pym/portage/util/install_mask.py
@@ -35,19 +35,21 @@ class InstallMask(object):
                """
                ret = False
                for pattern in self._install_mask:
+                       # if pattern starts with -, possibly exclude this path
+                       is_inclusive = not pattern.startswith('-')
+                       if not is_inclusive:
+                               pattern = pattern[1:]
                        # absolute path pattern
                        if pattern.startswith('/'):
                                # match either exact path or one of parent dirs
                                # the latter is done via matching pattern/*
                                if (fnmatch.fnmatch(path, pattern[1:])
                                                or fnmatch.fnmatch(path, 
pattern[1:] + '/*')):
-                                       ret = True
-                                       break
+                                       ret = is_inclusive
                        # filename
                        else:
                                if fnmatch.fnmatch(os.path.basename(path), 
pattern):
-                                       ret = True
-                                       break
+                                       ret = is_inclusive
                return ret
 
 

Reply via email to