cooker.py: 2 fixes for BBFILE_PATTERN
cover cooker.py: 2 fixes for BBFILE_PATTERN
The following changes since commit ceaca281cafa662aa2385b95641bce309dce843d:
fetch2/__init__: Disable pseudo in runfetchcmd() (2018-01-07 12:21:41 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib rbt/cooker
http://git.pokylinux.org/cgit.cgi//log/?h=rbt/cooker
Robert Yang (2):
cooker.py: the var cre maybe undefined cooker.py: fix for BBFILE_PATTERN matches bbappend
lib/bb/cooker.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 cooker.py: the var cre maybe undefined
The cre is not defined when re.compile(regex) raise errors, move the code where use it to the try block to fix the problem.
--- lib/bb/cooker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/cooker.py +1 -1
@@ -1173,11 +1173,11 @@ class BBCooker: else: try: cre = re.compile(regex) + self.bbfile_config_priorities.append((c, regex, cre, collection_priorities[c])) except re.error: parselog.error("BBFILE_PATTERN_%s \"%s\" is not a valid regular expression", c, regex) errors = True continue - self.bbfile_config_priorities.append((c, regex, cre, collection_priorities[c])) if errors: # We've already printed the actual error(s) raise CollectionError("Errors during parsing layer configuration")
Signature · 1 line
2.7.4
Re: [PATCH 1/2] cooker.py: the var cre maybe undefined
Sorry, I just found that a better fix should be:
commit 6f2ee522a2a63cbb18d4b52cda9ee88bdfe80784
Author: Robert Yang <[email protected]> Date: Wed Jan 17 14:26:30 2018 +0800
cooker.py: skip when BBFILE_PATTERN
There is nothing to do when BBFILE_PATTERN is empty.
lib/bb/cooker.py +1 -0
@@ -1170,6 +1170,7 @@ class BBCooker: elif regex == "": parselog.debug(1, "BBFILE_PATTERN_%s is empty" % c) errors = False + continue else: try: cre = re.compile(regex)
Updated in the repo:
git://git.pokylinux.org/poky-contrib rbt/cooker
http://git.pokylinux.org/cgit.cgi//log/?h=rbt/cooker
Robert Yang (2):
cooker.py: the var cre maybe undefined cooker.py: fix for BBFILE_PATTERN matches bbappend
// Robert
Quoted 26 lines · Robert Yang
The cre is not defined when
re.compile(regex)raise errors, move the code where use it to the try block to fix the problem.Signed-off-by Robert Yang <[email protected]>--- lib/bb/cooker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/bb/cooker.py +1
-1@@ -1173,11 +1173,11 @@ class BBCooker: else: try: cre = re.compile(regex) + self.bbfile_config_priorities.append((c, regex, cre, collection_priorities[c])) except re.error: parselog.error("BBFILE_PATTERN_%s \"%s\" is not a valid regular expression", c, regex) errors = True continue - self.bbfile_config_priorities.append((c, regex, cre, collection_priorities[c])) if errors: # We've already printed the actual error(s) raise CollectionError("Errors during parsing layer configuration")
PATCH 2/2 cooker.py: fix for BBFILE_PATTERN matches bbappend
In reply to Robert YangThe old code couldn't handle nestled layers correctly, e.g.:
parent_layer/sub_layer/foo.bb
Note there are two layers, parent_layer and sub_layer. And in parent_layer/conf/layer.conf:BBFILE_PATTERN_parent_layer = ""^${LAYERDIR}/"
This setting is incorrect since it also matches parent_layer/sub_layer/foo.bb, so it warns that no files matched sub_layer, this is the expected behavior, but it doesn't warn when there is a parent_layer/sub_layer/bar.bbappend, this was incorrect since the bbappend is also matched by BBFILE_PATTERN_parent_layer, it should warn and let the user fix the problem. Check the bbappend in already "matched set" before return it as matched by "unmatched set" can fix the problem.
--- lib/bb/cooker.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
lib/bb/cooker.py +7 -3
@@ -1807,21 +1807,25 @@ class CookerCollectFiles(object): realfn, cls, mc = bb.cache.virtualfn2realfn(p) priorities[p] = self.calc_bbfile_priority(realfn, matched) - # Don't show the warning if the BBFILE_PATTERN did match .bbappend files unmatched = set() for _, _, regex, pri in self.bbfile_config_priorities: if not regex in matched: unmatched.add(regex) - def findmatch(regex): + # Don't show the warning if the BBFILE_PATTERN did match .bbappend files + def find_bbappend_match(regex): for b in self.bbappends: (bbfile, append) = b if regex.match(append): + # If the bbappend is matched by already "matched set", return False + for matched_regex in matched: + if matched_regex.match(append): + return False return True return False for unmatch in unmatched.copy(): - if findmatch(unmatch): + if find_bbappend_match(unmatch): unmatched.remove(unmatch) for collection, pattern, regex, _ in self.bbfile_config_priorities:
Signature · 1 line
2.7.4