Skip to contentSkip to conversation

yocto-check-layer: add skip layer support

PATCH In review [email protected] 2 participants 2 messages Dec 12, 2022 – Dec 17, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 yocto-check-layer: add skip layer support

From: Mingli Yu <[email protected]>

We can define the layers need to check in a file and skip the yocto compliance check if the layer is't defined in the file.

---
 scripts/yocto-check-layer | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
scripts/yocto-check-layer +30 -0
index 67cc71950f..e75f89f224 100755
@@ -47,6 +47,28 @@ def dump_layer_debug(layer):
     if collections:
         logger.debug("%s collections: %s" % (layer["name"], ", ".join(collections)))
 
+def skip_layer(layer, config=""):
+    """
+    The config define a file used to define the layers we need to check.
+    And the content looks like as below for example:
+    RECIPE_LIST_LAYERS = 'openembedded-layer chromium-browser-layer clang-layer'
+    The return value True indicates we need to skip the layer
+    """
+    if config and os.path.exists(config):
+        logger.debug("Reading RECIPE_LIST_LAYERS from %s" % os.path.realpath(config))
+        layerlists = []
+        collections = layer.get("collections", {})
+        if collections:
+            collections = " ".join(collections)
+            logger.debug("layername: %s, collections: %s" % (layer["name"], collections))
+            with open(config, 'r') as f:
+                for line in f:
+                    if line.startswith("RECIPE_LIST_LAYERS"):
+                        layerlists = line.replace("'", '').replace('"', '').split()[2:]
+            if layerlists:
+                return not (collections in layerlists)
+    return False
+
 def main():
     parser = argparse.ArgumentParser(
             description="Yocto Project layer checking tool",
@@ -57,6 +79,8 @@ def main():
             help='File to output log (optional)', action='store')
     parser.add_argument('--dependency', nargs="+",
             help='Layers to process for dependencies', action='store')
+    parser.add_argument("--recipe-list-layers",
+            help='Read RECIPE_LIST_LAYERS from the file, the RECIPE_LIST_LAYERS must be in one line (optional)', action='store')
     parser.add_argument('--no-auto-dependency', help='Disable automatic testing of dependencies',
             action='store_true')
     parser.add_argument('--machines', nargs="+",
@@ -185,6 +209,12 @@ def main():
         logger.info("Setting up for %s(%s), %s" % (layer['name'], layer['type'],
             layer['path']))
 
+        if args.recipe_list_layers and skip_layer(layer, args.recipe_list_layers):
+
+            results[layer['name']] = None
+            results_status[layer['name']] = 'SKIPPED (Unsupported by RECIPE_LIST_LAYERS)'
+            layers_tested = layers_tested + 1
+            continue
         missing_dependencies = not add_layer_dependencies(bblayersconf, layer, dep_layers, logger)
         if not missing_dependencies:
             for additional_layer in additional_layers:
Signature · 1 line
2.25.1
#1 lore raw
Quoted 9 lines · Mingli

From: Mingli Yu <[email protected]>

We can define the layers need to check in a file and skip the yocto compliance check if the layer is't defined in the file.

---
 scripts/yocto-check-layer | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

I'm afraid I don't really like this idea. What use case are you solving? Ideally we want people to be obtaining compatible status for their layers so making it easier to hide or skip layers isn't one of our objectives.

It also isn't clear from just looking at the patch if this could be used to bypass some of the layer dependency checks and some of the requirements of yocto compatible status too. We ideally want people to be able to reproduce the test status for a given layer without any special configuration file.

So unless someone can explain why this is absolutely necessary, I don't really want to merge anything like it.

Cheers,

Richard