summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-11-23 16:00:24 +0100
committerJürg Billeter <j@bitron.ch>2019-02-18 19:45:36 +0100
commit54be3bb65220e841685694c414e80e46a244ec7f (patch)
treed7cecaafb8f1d6a9d0f6f06ad1b41670fefeb595
parent86466e7ed6bef1a3373f1d2091023adc1b549d35 (diff)
downloadbuildstream-valentindavid/absolute-whitelist.tar.gz
element.py: Expect absolute paths in overlap whitelistsvalentindavid/absolute-whitelist
This allows use of variables such as %{prefix} and matches the documentation. This is a breaking change. Fixes #721
-rw-r--r--NEWS3
-rw-r--r--buildstream/element.py4
-rw-r--r--tests/frontend/overlaps/a-whitelisted.bst2
-rw-r--r--tests/frontend/overlaps/b-whitelisted.bst4
-rw-r--r--tests/frontend/overlaps/c-whitelisted.bst2
5 files changed, 9 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 752434cfe..fe3fda2c3 100644
--- a/NEWS
+++ b/NEWS
@@ -138,6 +138,9 @@ buildstream 1.3.1
o BREAKING CHANGE: Symlinks are no longer resolved during staging and absolute
symlinks are now preserved instead of being converted to relative symlinks.
+ o BREAKING CHANGE: Overlap whitelists now require absolute paths. This allows
+ use of variables such as %{prefix} and matches the documentation.
+
=================
buildstream 1.1.5
diff --git a/buildstream/element.py b/buildstream/element.py
index 8fc491204..a1b3de879 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -2609,7 +2609,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
@@ -2621,7 +2621,7 @@ 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))
# __extract():
#
diff --git a/tests/frontend/overlaps/a-whitelisted.bst b/tests/frontend/overlaps/a-whitelisted.bst
index d995b4161..e3b677ec8 100644
--- a/tests/frontend/overlaps/a-whitelisted.bst
+++ b/tests/frontend/overlaps/a-whitelisted.bst
@@ -10,4 +10,4 @@ sources:
public:
bst:
overlap-whitelist:
- - "file*"
+ - "/file*"
diff --git a/tests/frontend/overlaps/b-whitelisted.bst b/tests/frontend/overlaps/b-whitelisted.bst
index 3dfe931e1..f09736669 100644
--- a/tests/frontend/overlaps/b-whitelisted.bst
+++ b/tests/frontend/overlaps/b-whitelisted.bst
@@ -8,9 +8,9 @@ sources:
- kind: local
path: "b"
variables:
- FILE: file
+ FILE: /file
public:
bst:
overlap-whitelist:
- - file2
+ - /file2
- "%{FILE}3"
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*"