Bug 12338

Summary: checklayer: undefined LayerError
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Patrick Ohly <patrick.ohly>
Component: Scripts and ToolsAssignee: Anuj Mittal <anuj.mittal>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: ross.burton
Version: unspecified   
Target Milestone: 2.5 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Patrick Ohly 2017-11-13 07:50:31 UTC
openembedded-core/scripts/lib/checklayer/__init__.py uses an undefined LayerError class, which fails when that code path is hit:

Traceback (most recent call last):
  File "/fast/work/intel-iot-refkit/openembedded-core/scripts/yocto-check-layer", line 203, in <module>
    ret =  main()
  File "/fast/work/intel-iot-refkit/openembedded-core/scripts/yocto-check-layer", line 100, in main
    dep_layers = detect_layers(args.dependency, args.no_auto)
  File "/fast/work/intel-iot-refkit/openembedded-core/scripts/lib/checklayer/__init__.py", line 134, in detect_layers
    layer = _detect_layer(root)
  File "/fast/work/intel-iot-refkit/openembedded-core/scripts/lib/checklayer/__init__.py", line 111, in _detect_layer
    layer['collections'] = _get_layer_collections(layer['path'])
  File "/fast/work/intel-iot-refkit/openembedded-core/scripts/lib/checklayer/__init__.py", line 46, in _get_layer_collections
    raise LayerError(exc)
NameError: name 'LayerError' is not defined

I happened to trigger this when adding meta-measured to refkit. meta-measured/conf/layer.conf uses BBPATH := "${BBPATH}:${LAYERDIR}" instead of the normal BBPATH .= ":${LAYERDIR}", and that causes:

Traceback (most recent call last):
  File "/fast/work/intel-iot-refkit/openembedded-core/scripts/lib/checklayer/__init__.py", line 44, in _get_layer_collections
    ldata = bb.parse.handle(lconf, ldata, include=True)
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/parse/__init__.py", line 117, in handle
    return h['handle'](fn, data, include)
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 165, in handle
    statements.eval(data)
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/parse/ast.py", line 36, in eval
    statement.eval(data)
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/parse/ast.py", line 58, in eval
    bb.parse.ConfHandler.include(self.filename, s, self.lineno, data, "include required")
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 83, in include
    include_single_file(parentfn, fn, lineno, data, error_out)
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 94, in include_single_file
    bbpath = "%s:%s" % (dname, data.getVar("BBPATH"))
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/data_smart.py", line 608, in getVar
    return self.getVarFlag(var, "_content", expand, noweakdefault, parsing)
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/data_smart.py", line 794, in getVarFlag
    value = self.expand(value, cachename)
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/data_smart.py", line 436, in expand
    return self.expandWithRefs(s, varname).value
  File "/fast/work/intel-iot-refkit/bitbake/lib/bb/data_smart.py", line 426, in expandWithRefs
    raise ExpansionError(varname, s, exc) from exc
bb.data_smart.ExpansionError: Failure expanding variable BBPATH, expression was ${BBPATH}:/fast/work/intel-iot-refkit/meta-measured which triggered exception Exception: variable BBPATH references itself!

Building with meta-measured is fine, it's just the compat check which fails?