diff mbox series

[11/16] bitbake-layers: Update to match new layer format

Message ID 20261130152704.3471590-11-richard.purdie@linuxfoundation.org
State New
Headers show
Series [01/16] bitbake/base: Implement RECIPE_HOSTTOOLS | expand

Commit Message

Richard Purdie Nov. 30, 2026, 3:26 p.m. UTC
Update to match the new layer format, updating the template, using
layername as the command parameter instead of layerid (which remains
an alias) and droping the priority options.

The selftest is updated to match.

AI-Generated: Uses Claude Opus 5.5
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/bblayers/create.py              | 11 +++++------
 meta/lib/bblayers/templates/layer.conf   | 17 ++++++-----------
 meta/lib/oeqa/selftest/cases/bblayers.py | 17 +++--------------
 3 files changed, 14 insertions(+), 31 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/bblayers/create.py b/meta/lib/bblayers/create.py
index b38c4b5e38a..5128611b707 100644
--- a/meta/lib/bblayers/create.py
+++ b/meta/lib/bblayers/create.py
@@ -37,11 +37,11 @@  class CreatePlugin(LayerPlugin):
         conf = os.path.join(layerdir, 'conf')
         bb.utils.mkdirhier(conf)
 
-        layername = os.path.basename(os.path.normpath(args.layerdir))
-        layerid = args.layerid if args.layerid is not None else layername
+        layerdirname = os.path.basename(os.path.normpath(args.layerdir))
+        layername = args.layername if args.layername is not None else layerdirname
 
         # Create the README from templates/README
-        readme_template =  read_template('README').format(layername=layername)
+        readme_template =  read_template('README').format(layername=layerdirname)
         readme = os.path.join(layerdir, 'README')
         with open(readme, 'w') as fd:
             fd.write(readme_template)
@@ -58,7 +58,7 @@  class CreatePlugin(LayerPlugin):
 
         # Create the layer.conf from templates/layer.conf
         layerconf_template = read_template('layer.conf').format(
-                layerid=layerid, priority=args.priority, compat=compat)
+                layername=layername, compat=compat)
         layerconf = os.path.join(conf, 'layer.conf')
         with open(layerconf, 'w') as fd:
             fd.write(layerconf_template)
@@ -83,8 +83,7 @@  class CreatePlugin(LayerPlugin):
         parser_create_layer = self.add_command(sp, 'create-layer', self.do_create_layer, parserecipes=False)
         parser_create_layer.add_argument('layerdir', help='Layer directory to create')
         parser_create_layer.add_argument('--add-layer', '-a', action='store_true', help='Add the layer to bblayers.conf after creation')
-        parser_create_layer.add_argument('--layerid', '-i', help='Layer ID to use in BBFILE_COLLECTIONS, if different from the layerdir basename')
-        parser_create_layer.add_argument('--priority', '-p', default=6, help='Priority of recipes in layer')
+        parser_create_layer.add_argument('--layername', '--layerid', '-i', dest='layername', help='Layer name to use for LAYERNAME, if different from the layerdir basename')
         parser_create_layer.add_argument('--example-recipe-name', '-e', dest='examplerecipe', default='example', help='Filename of the example recipe')
         parser_create_layer.add_argument('--example-recipe-version', '-v', dest='version', default='0.1', help='Version number for the example recipe')
 
diff --git a/meta/lib/bblayers/templates/layer.conf b/meta/lib/bblayers/templates/layer.conf
index dddfbf716e0..557d498c85d 100644
--- a/meta/lib/bblayers/templates/layer.conf
+++ b/meta/lib/bblayers/templates/layer.conf
@@ -1,13 +1,8 @@ 
-# We have a conf and classes directory, add to BBPATH
-BBPATH .= ":${{LAYERDIR}}"
+# BBPATH and BBFILES are constructed automatically by bitbake. Recipes and
+# bbappends in any recipes* directory within this layer are found automatically.
 
-# We have recipes-* directories, add to BBFILES
-BBFILES += "${{LAYERDIR}}/recipes-*/*/*.bb \
-            ${{LAYERDIR}}/recipes-*/*/*.bbappend"
+LAYERNAME = "{layername}"
+LAYERVERSION = "1"
 
-BBFILE_COLLECTIONS += "{layerid}"
-BBFILE_PATTERN_{layerid} = "^${{LAYERDIR}}/"
-BBFILE_PRIORITY_{layerid} = "{priority}"
-
-LAYERDEPENDS_{layerid} = "core"
-LAYERSERIES_COMPAT_{layerid} = "{compat}"
+LAYERDEPENDS = "oe-core"
+LAYERSERIES_COMPAT = "{compat}"
diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py
index 7ca82e0d5c0..b83ae6283df 100644
--- a/meta/lib/oeqa/selftest/cases/bblayers.py
+++ b/meta/lib/oeqa/selftest/cases/bblayers.py
@@ -102,29 +102,18 @@  class BitbakeLayers(OESelftestTestCase):
         self.assertIn('ERROR:', result.output)
 
     def test_bitbakelayers_createlayer(self):
-        priority = 10
         layername = 'test-bitbakelayer-layercreate'
         layerpath = os.path.join(self.builddir, layername)
         self.assertFalse(os.path.exists(layerpath), '%s should not exist at this point in time' % layerpath)
-        result = runCmd('bitbake-layers create-layer --priority=%d %s' % (priority, layerpath))
+        result = runCmd('bitbake-layers create-layer %s' % layerpath)
         self.track_for_cleanup(layerpath)
         result = runCmd('bitbake-layers add-layer %s' % layerpath)
         self.add_command_to_tearDown('bitbake-layers remove-layer %s' % layerpath)
         result = runCmd('bitbake-layers show-layers')
-        find_in_contents = re.search(re.escape(layername) + r'\s+' + re.escape(layerpath) + r'\s+' + re.escape(str(priority)), result.output)
+        find_in_contents = re.search(re.escape(layername) + r'\s+' + re.escape(layerpath) + r'\s+1\s+oe-core', result.output)
         self.assertTrue(find_in_contents, "%s not found in layers\n%s" % (layername, result.output))
 
-        layervars = ['BBFILE_PRIORITY', 'BBFILE_PATTERN', 'LAYERDEPENDS', 'LAYERSERIES_COMPAT']
-        bb_vars = get_bb_vars(['BBFILE_COLLECTIONS'] + ['%s_%s' % (v, layername) for v in layervars])
-
-        for v in layervars:
-            varname = '%s_%s' % (v, layername)
-            self.assertIsNotNone(bb_vars[varname], "%s not found" % varname)
-
-        find_in_contents = re.search(r'(^|\s)' + re.escape(layername) + r'($|\s)', bb_vars['BBFILE_COLLECTIONS'])
-        self.assertTrue(find_in_contents, "%s not in BBFILE_COLLECTIONS" % layername)
-
-        self.assertEqual(bb_vars['BBFILE_PRIORITY_%s' % layername], str(priority), 'BBFILE_PRIORITY_%s != %d' % (layername, priority))
+        self.assertEqual(get_bb_var('LAYERDIR_%s' % layername), layerpath, 'LAYERDIR_%s not set to %s' % (layername, layerpath))
 
         result = runCmd('bitbake-layers save-build-conf {} {}'.format(layerpath, "buildconf-1"))
         for f in ('local.conf.sample', 'bblayers.conf.sample', 'conf-summary.txt', 'conf-notes.txt'):