element.py: Expect absolute paths in overlap whitelists
This allows use of variables such as %{prefix} and matches the
documentation.
Backport of: 1ae1796854055f4b9e3202d9629e059b327f3a8d
diff --git a/buildstream/element.py b/buildstream/element.py
index 703f062..257d5f3 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -2362,7 +2362,7 @@
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 @@
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 c71ef31..47154b2 100644
--- a/tests/frontend/overlaps/c-whitelisted.bst
+++ b/tests/frontend/overlaps/c-whitelisted.bst
@@ -8,4 +8,4 @@
public:
bst:
overlap-whitelist:
- - "file*"
+ - "/file*"