From 28414495277e87898c9ac5314b88ebb747494dac Mon Sep 17 00:00:00 2001 From: Tim Orling Date: Fri, 23 Feb 2024 12:58:35 -0800 Subject: bitbake: layerindexlib: fix missing layer branch backtrace When a LayerBranch (a specific layer at a specific release) does not exist in the layerindex database ("Layerindex Metadata"), the dependency would throw a backtrace. Instead fail early and provide an error message. Since layerindexlib will also check the local layers, inform the user that a local checkout might resolve the situation. Recommend that they reach out to the layer maintainers and layer index admins to properly fix it for everyone. While we are here, remove some trailing whitespace. [YOCTO #15365] [YOCTO #13954] (Bitbake rev: 96cbe8f87209a927c157ebcf469f8b9d54fcf92e) Signed-off-by: Tim Orling Signed-off-by: Richard Purdie --- bitbake/lib/layerindexlib/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'bitbake/lib/layerindexlib/__init__.py') diff --git a/bitbake/lib/layerindexlib/__init__.py b/bitbake/lib/layerindexlib/__init__.py index ac03d89876..c3265ddaa1 100644 --- a/bitbake/lib/layerindexlib/__init__.py +++ b/bitbake/lib/layerindexlib/__init__.py @@ -178,9 +178,9 @@ class LayerIndex(): '''Load the layerindex. indexURI - An index to load. (Use multiple calls to load multiple indexes) - + reload - If reload is True, then any previously loaded indexes will be forgotten. - + load - List of elements to load. Default loads all items. Note: plugs may ignore this. @@ -383,7 +383,14 @@ layerBranches set. If not, they are effectively blank.''' # Get a list of dependencies and then recursively process them for layerdependency in layerbranch.index.layerDependencies_layerBranchId[layerbranch.id]: - deplayerbranch = layerdependency.dependency_layerBranch + try: + deplayerbranch = layerdependency.dependency_layerBranch + except AttributeError as e: + logger.error('LayerBranch does not exist for dependent layer {}:{}\n' \ + ' Cannot continue successfully.\n' \ + ' You might be able to resolve this by checking out the layer locally.\n' \ + ' Consider reaching out the to the layer maintainers or the layerindex admins' \ + .format(layerdependency.dependency.name, layerbranch.branch.name)) if ignores and deplayerbranch.layer.name in ignores: continue @@ -846,7 +853,7 @@ class LayerIndexObj(): continue for layerdependency in layerbranch.index.layerDependencies_layerBranchId[layerbranch.id]: - deplayerbranch = layerdependency.dependency_layerBranch + deplayerbranch = layerdependency.dependency_layerBranch or None if ignores and deplayerbranch.layer.name in ignores: continue -- cgit v1.2.3-54-g00ecf