Skip to contentSkip to conversation

bitbake-config-build: add an alias to bitbake-layers intended for managing specific local configs

PATCH New Alexander Kanavin 1 participant 3 messages Nov 14, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 bitbake-config-build: add an alias to bitbake-layers intended for managing specific local configs

From: Alexander Kanavin <[email protected]>

This was prompted by adding support for config fragments (in a separate commit to oe-core); after some deliberation I concluded there should be a separate tool, as bitbake-layers is already somewhat over-stuffed, and this will give space for more build/conf/* operations in the future that anyone can come up with (such as tweaking site-specific items in site.conf etc.)

The alias completely reuses existing code via symlink and the difference is in where it looks for plugins.

---
 bin/bitbake-config-build | 1 +
 bin/bitbake-layers       | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
 create mode 120000 bitbake/bin/bitbake-config-build
bin/bitbake-config-build new file +1 -0
new file mode 120000
index 00000000000..11e6df80c4b
@@ -0,0 +1 @@
+bitbake-layers
\ No newline at end of file
bin/bitbake-layers +4 -2
index aebb5100c2c..3923c4db562 100755
@@ -18,13 +18,14 @@ import warnings
 warnings.simplefilter("default")
 
 bindir = os.path.dirname(__file__)
+toolname = os.path.basename(__file__).split(".")[0]
 topdir = os.path.dirname(bindir)
 sys.path[0:0] = [os.path.join(topdir, 'lib')]
 
 import bb.tinfoil
 import bb.msg
 
-logger = bb.msg.logger_create('bitbake-layers', sys.stdout)
+logger = bb.msg.logger_create(toolname, sys.stdout)
 
 def main():
     parser = argparse.ArgumentParser(
@@ -67,7 +68,8 @@ def main():
     
     try: 
         for path in ([topdir] + bbpaths):
-            pluginpath = os.path.join(path, 'lib', 'bblayers')
+            pluginbasepath = {"bitbake-layers":'bblayers', 'bitbake-config-build':'bbconfigbuild'}[toolname]
+            pluginpath = os.path.join(path, 'lib', pluginbasepath)
             bb.utils.load_plugins(logger, plugins, pluginpath)
 
         registered = False
Signature · 1 line
2.39.5
#1 lore raw

PATCH 2/3 parse: add support for 'addfragments' directive

From: Alexander Kanavin <[email protected]>

It takes two parameters:
- location prefix for fragments
- name of variable that holds the list of enabled fragments

Implementation of this directive essentially expands the fragment list obtained from it into 'require' entries and hands them to the implementation of 'require'.

---
 lib/bb/parse/ast.py                  | 19 +++++++++++++++++++
 lib/bb/parse/parse_py/ConfHandler.py |  6 ++++++
 2 files changed, 25 insertions(+)
lib/bb/parse/ast.py +19 -0
index 001ba8d289a..b7272dfdc65 100644
@@ -326,6 +326,20 @@ class InheritDeferredNode(AstNode):
         inherits.append(self.inherit)
         data.setVar('__BBDEFINHERITS', inherits)
 
+class AddFragmentsNode(AstNode):
+    def __init__(self, filename, lineno, fragments_path_prefix, fragments_variable):
+        AstNode.__init__(self, filename, lineno)
+        self.path = fragments_path_prefix
+        self.variable = fragments_variable
+
+    def eval(self, data):
+        fragments = data.getVar(self.variable)
+        if not fragments:
+            return
+        for f in fragments.split():
+            full_fragment_name = data.expand("{}/{}.conf".format(self.path, f))
+            bb.parse.ConfHandler.include(self.filename, full_fragment_name, self.lineno, data, "include fragment")
+
 def handleInclude(statements, filename, lineno, m, force):
     statements.append(IncludeNode(filename, lineno, m.group(1), force))
 
@@ -370,6 +384,11 @@ def handleInheritDeferred(statements, filename, lineno, m):
     classes = m.group(1)
     statements.append(InheritDeferredNode(filename, lineno, classes))
 
+def handleAddFragments(statements, filename, lineno, m):
+    fragments_path_prefix = m.group(1)
+    fragments_variable = m.group(2)
+    statements.append(AddFragmentsNode(filename, lineno, fragments_path_prefix, fragments_variable))
+
 def runAnonFuncs(d):
     code = []
     for funcname in d.getVar("__BBANONFUNCS", False) or []:
lib/bb/parse/parse_py/ConfHandler.py +6 -0
index 7826dee7d3d..31001e2afe1 100644
@@ -47,6 +47,7 @@ __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" )
 __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" )
 __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\]$" )
 __addpylib_regexp__      = re.compile(r"addpylib\s+(.+)\s+(.+)" )
+__addfragments_regexp__  = re.compile(r"addfragments\s+(.+)\s+(.+)" )
 
 def init(data):
     return
@@ -197,6 +198,11 @@ def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True):
         ast.handlePyLib(statements, fn, lineno, m)
         return
 
+    m = __addfragments_regexp__.match(s)
+    if m:
+        ast.handleAddFragments(statements, fn, lineno, m)
+        return
+
     raise ParseError("unparsed line: '%s'" % s, fn, lineno);
 
 # Add us to the handlers list
Signature · 1 line
2.39.5
#2 lore raw

PATCH 3/3 parse/ConfHandler: allow / in variable flags

In reply to Alexander Kanavin

From: Alexander Kanavin <[email protected]>

This is beneficial for config fragments, as their names are specified via flags, and those names can include slashes:

BB_CONF_FRAGMENT_SUMMARY[init/systemd] = "This fragment enables systemd as an init manager"

---
 lib/bb/parse/parse_py/ConfHandler.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/parse/parse_py/ConfHandler.py +1 -1
index 31001e2afe1..35321dacfe1 100644
@@ -21,7 +21,7 @@ __config_regexp__  = re.compile( r"""
     ^
     (?P<exp>export\s+)?
     (?P<var>[a-zA-Z0-9\-_+.${}/~:]+?)
-    (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]*)\])?
+    (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@/]*)\])?
 
     \s* (
         (?P<colon>:=) |
Signature · 1 line
2.39.5