diff mbox series

kernel-module-split.bbclass: support muti-lines in module conf

Message ID 20251001093453.185784-1-liu.ming50@gmail.com
State New
Headers show
Series kernel-module-split.bbclass: support muti-lines in module conf | expand

Commit Message

Ming Liu Oct. 1, 2025, 9:34 a.m. UTC
The expanded bitbake variables are raw strings so it does not support
writting multiple lines to a kernel module conf, add the support by
decoding it with 'unicode-escape'.

Reported-by: Mathias Thore <mathias.thore@atlascopco.com>
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
 meta/classes-recipe/kernel-module-split.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Kanavin Oct. 1, 2025, 9:49 a.m. UTC | #1
On Wed, 1 Oct 2025 at 11:35, Ming Liu via lists.openembedded.org
<liu.ming50=gmail.com@lists.openembedded.org> wrote:
>
> The expanded bitbake variables are raw strings so it does not support
> writting multiple lines to a kernel module conf, add the support by
> decoding it with 'unicode-escape'.
> -                f.write("%s\n" % modconf)
> +                f.write("%s\n" % modconf.encode().decode('unicode-escape'))

Can you provide an example of such a variable which causes the issue?

Alex
Ming Liu Oct. 1, 2025, 10:02 a.m. UTC | #2
> Can you provide an example of such a variable which causes the issue?

Sure, when we have the following settings:

```
KERNEL_MODULE_AUTOLOAD = "mod1"
module_conf_mod1 = "line1\nline2\nline3"
```

// MIng

Alexander Kanavin <alex.kanavin@gmail.com> 於 2025年10月1日 週三 上午11:49寫道:

> On Wed, 1 Oct 2025 at 11:35, Ming Liu via lists.openembedded.org
> <liu.ming50=gmail.com@lists.openembedded.org> wrote:
> >
> > The expanded bitbake variables are raw strings so it does not support
> > writting multiple lines to a kernel module conf, add the support by
> > decoding it with 'unicode-escape'.
> > -                f.write("%s\n" % modconf)
> > +                f.write("%s\n" %
> modconf.encode().decode('unicode-escape'))
>
> Can you provide an example of such a variable which causes the issue?
>
> Alex
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-module-split.bbclass b/meta/classes-recipe/kernel-module-split.bbclass
index 75ed696b72..c289808404 100644
--- a/meta/classes-recipe/kernel-module-split.bbclass
+++ b/meta/classes-recipe/kernel-module-split.bbclass
@@ -131,7 +131,7 @@  python split_kernel_module_packages () {
         if modconf and basename in modconflist:
             os.makedirs(os.path.dirname(name), exist_ok=True)
             with open(name, 'w') as f:
-                f.write("%s\n" % modconf)
+                f.write("%s\n" % modconf.encode().decode('unicode-escape'))
         elif modconf:
             bb.error("Please ensure module %s is listed in KERNEL_MODULE_PROBECONF since module_conf_%s is set" % (basename, basename))
         # If the .conf file exits, then add it to FILES:* and CONFFILES:*.