From 49569cf85f6e3eba4096c11743ec0a289e53982c Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 4 Sep 2019 09:49:35 +0100 Subject: element.py: Expect absolute paths in overlap whitelists This allows use of variables such as %{prefix} and matches the documentation. Backport of: 1ae1796854055f4b9e3202d9629e059b327f3a8d --- buildstream/element.py | 5 +++-- tests/frontend/overlaps/c-whitelisted.bst | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/buildstream/element.py b/buildstream/element.py index 703f062da..257d5f335 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -2362,7 +2362,7 @@ class Element(Plugin): if include_file and not exclude_file: yield filename.lstrip(os.sep) - def __file_is_whitelisted(self, pattern): + def __file_is_whitelisted(self, path): # Considered storing the whitelist regex for re-use, but public data # can be altered mid-build. # Public data is not guaranteed to stay the same for the duration of @@ -2374,7 +2374,8 @@ class Element(Plugin): whitelist_expressions = [utils._glob2re(self.__variables.subst(exp.strip())) for exp in whitelist] expression = ('^(?:' + '|'.join(whitelist_expressions) + ')$') self.__whitelist_regex = re.compile(expression) - return self.__whitelist_regex.match(pattern) + return (self.__whitelist_regex.match(os.path.join(os.sep, path)) or + self.__whitelist_regex.match(os.path.join(path))) # __extract(): # diff --git a/tests/frontend/overlaps/c-whitelisted.bst b/tests/frontend/overlaps/c-whitelisted.bst index c71ef3128..47154b277 100644 --- a/tests/frontend/overlaps/c-whitelisted.bst +++ b/tests/frontend/overlaps/c-whitelisted.bst @@ -8,4 +8,4 @@ sources: public: bst: overlap-whitelist: - - "file*" + - "/file*" -- cgit v1.2.1