diff mbox series

yocto-check-layer: add skip layer support

Message ID 20221212085612.3204827-1-mingli.yu@eng.windriver.com
State New
Headers show
Series yocto-check-layer: add skip layer support | expand

Commit Message

mingli.yu@eng.windriver.com Dec. 12, 2022, 8:56 a.m. UTC
From: Mingli Yu <mingli.yu@windriver.com>

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.

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 scripts/yocto-check-layer | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

Richard Purdie Dec. 17, 2022, 11:22 a.m. UTC | #1
On Mon, 2022-12-12 at 16:56 +0800, Yu, Mingli wrote:
> From: Mingli Yu <mingli.yu@windriver.com>
> 
> 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.
> 
> Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> ---
>  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
diff mbox series

Patch

diff --git a/scripts/yocto-check-layer b/scripts/yocto-check-layer
index 67cc71950f..e75f89f224 100755
--- a/scripts/yocto-check-layer
+++ b/scripts/yocto-check-layer
@@ -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: