Bug 8160

Summary: bitbake-layers: unable to determine layer when BBFILES points to a subdirectory
Product: [Build System, Metadata & Runtime] BitBake Reporter: Paul Eggleton <bluelightning>
Component: bitbakeAssignee: Paul Eggleton <bluelightning>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: liezhi.yang, patrick.ohly, poky.bs.watcher, poky.watcher
Version: 1.8   
Target Milestone: 1.9 M3   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: Regression (Used to work)
Verified: Documentation change: No (bug/feature does not impact docs)

Description Paul Eggleton 2015-08-14 10:12:16 UTC
In http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=4a09c91ce4a0b040a71a49d741d10fc850e887fa we added an additional check in get_file_layer() on whether the layer directory matched BBFILE_PATTERN. Unfortunately that isn't correct - BBFILE_PATTERN isn't meant to match against the layer directory, and if you try that with layers like meta-intel that put all of their recipes in a subdirectory, you'll find it doesn't work - e.g. add meta-intel to bblayers.conf and then run "bitbake-layers show-recipes efilinux" - you'll see ? as the layer.

BBFILE_PATTERN is intended to match against entries added to BBFILES. We could change the function to map back to BBFILES and then use that to match the file. However that will only work for recipes and not classes or conf files, and we are using the get_file_layer() with the latter, so we may have to have the function fall back to the old method if that doesn't work.
Comment 1 Paul Eggleton 2015-08-14 10:18:16 UTC
Additionally the get_file_layer() function in lib/bb/utils.py (which is the same function rewritten to be usable from the metadata) will need a similar fix for the same issue. If practical it would be nice if we could have just one function.
Comment 2 Patrick Ohly 2015-08-14 10:23:07 UTC
4a09c91ce4a0b040a71a49d741d10fc850e887fa did not add the BBFILE_PATTERN match, that goes back further.

What 4a09c91ce4a0b040a71a49d741d10fc850e887fa adds is the (IMHO) awkward re.match(layerdir, filename) which isn't really a regular expression match because layerdir is a path name. A better way to write that check would be filename.startswith(layerdir), although that's also based on an assumption ("a layer must contain its recipe files").

Technically, a layer may also add files to BBPATH which are elsewhere.
Comment 3 Paul Eggleton 2015-08-14 10:35:25 UTC
You're right, the regex.match on layerdir + /test was before that and would have contributed to this.

We do need to map through BBFILES yes or this will continue to have issues, but that's not the whole picture as I mentioned as that won't work with classes or conf files that are found through BBPATH.