diff mbox series

[RFC,wrynose,2/5] yocto-check-layer: don't skip entries when dropping invalid layers

Message ID 20261124171356.951415-3-jose.quaresma@oss.qualcomm.com
State New
Headers show
Series yocto-check-layer runtime improvements | expand

Commit Message

Jose Quaresma Nov. 24, 2026, 5:13 p.m. UTC
From: Vinicius Pedrosa <vinicius.eduardo.pedrosa@gmail.com>

The "Detected layers" loop removes invalid entries from the list it's
iterating over. When two invalid layers are adjacent, removing the
first skips the second, leaving it in the list.

A skipped entry without conf/layer.conf makes the dependency pass fail
with KeyError: 'collections'. A skipped BSP+DISTRO entry isn't
reported. If no other layer is left to test, the script exits 0.

Move the filtering into validate_layers(), which builds a new list
containing only valid layers. Keep validation at its original position
and update dep_layers when it previously shared the same list, without
changing the existing dependency handling.

Signed-off-by: Vinicius Pedrosa <vinicius.eduardo.pedrosa@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 6050ce9f129ad20ad395c35380855bafb79c530f)
Signed-off-by: Jose Quaresma <jose.quaresma@oss.qualcomm.com>
---
 scripts/yocto-check-layer | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/scripts/yocto-check-layer b/scripts/yocto-check-layer
index 8c8b4dbcad..ca4ada0f35 100755
--- a/scripts/yocto-check-layer
+++ b/scripts/yocto-check-layer
@@ -48,6 +48,22 @@  def dump_layer_debug(layer):
     if collections:
         logger.debug("%s collections: %s" % (layer["name"], ", ".join(collections)))
 
+def validate_layers(layers):
+    valid_layers = []
+    for layer in layers:
+        if layer['type'] == LayerType.ERROR_BSP_DISTRO:
+            logger.error("%s: Can't be DISTRO and BSP type at the same time."\
+                     " Both conf/distro and conf/machine folders were found."\
+                     % layer['name'])
+        elif layer['type'] == LayerType.ERROR_NO_LAYER_CONF:
+            logger.info("%s: Doesn't have conf/layer.conf file, so ignoring"\
+                     % layer['name'])
+        else:
+            logger.info("%s: %s, %s" % (layer['name'], layer['type'],
+                layer['path']))
+            valid_layers.append(layer)
+    return valid_layers
+
 def main():
     parser = argparse.ArgumentParser(
             description="Yocto Project layer checking tool",
@@ -125,19 +141,10 @@  def main():
         return 1
 
     logger.info("Detected layers:")
-    for layer in layers:
-        if layer['type'] == LayerType.ERROR_BSP_DISTRO:
-            logger.error("%s: Can't be DISTRO and BSP type at the same time."\
-                     " Both conf/distro and conf/machine folders were found."\
-                     % layer['name'])
-            layers.remove(layer)
-        elif layer['type'] == LayerType.ERROR_NO_LAYER_CONF:
-            logger.info("%s: Doesn't have conf/layer.conf file, so ignoring"\
-                     % layer['name'])
-            layers.remove(layer)
-        else:
-            logger.info("%s: %s, %s" % (layer['name'], layer['type'],
-                layer['path']))
+    layers = validate_layers(layers)
+    # Keep dep_layers in sync when it previously shared the layers list.
+    if not args.dependency:
+        dep_layers = layers
     if not layers:
         return 1