Re: [OE-core] [PATCH V2 1/2] kernel-module-split: make autoload and probeconf distribution specific

2023-06-20 Thread Jose Quaresma
Luca Ceresoli  escreveu no dia terça, 20/06/2023
à(s) 14:57:

> Hello Jose,
>
> On Mon, 19 Jun 2023 23:13:43 +
> "Jose Quaresma"  wrote:
>
> > The modules-load.d [1] - Configure kernel modules to load at boot
> > should install their configuration files in /usr/lib/modules-load.d.
> >
> > The modprobe.d [2] - Configuration directory for modprobe
> > should install their configuration files in /lib/modprobe.d
> >
> > [1] https://www.freedesktop.org/software/systemd/man/modules-load.d.html
> > [2] https://www.man7.org/linux/man-pages//man5/modprobe.d.5.html
> >
> > [YOCTO #12212] https://bugzilla.yoctoproject.org/show_bug.cgi?id=12212
> >
> > CC: Ola x Nilsson 
> > CC: Peter Kjellerstedt 
> > Signed-off-by: Jose Quaresma 
>
> This patchset is triggering some AB failures:
>
>   Exception: NameError: name 'modprobedir' is not defined
>
> Some logs:
>
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/104/builds/6229/steps/12/logs/stdio
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/23/builds/7658/steps/14/logs/stdio
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/120/builds/2935/steps/12/logs/stdio
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/89/builds/7369/steps/17/logs/stdio


Hi Luca,

Thanks for the info.

I missed some parts of the patch when updating to v2.
I am also addressing some comments on v2 and will send a v3
after some more testing.

--- a/meta/classes-recipe/kernel-module-split.bbclass
+++ b/meta/classes-recipe/kernel-module-split.bbclass
@@ -166,6 +166,8 @@ python split_kernel_module_packages () {
 splitmods = d.getVar('KERNEL_SPLIT_MODULES')
 postinst = d.getVar('pkg_postinst:modules')
 postrm = d.getVar('pkg_postrm:modules')
+modulesloaddir = d.getVar('modulesloaddir')
+modprobedir = d.getVar('modprobedir')

 if splitmods != '1':
 d.appendVar('FILES:' + metapkg, '%s/ %s/ %s/modules/' %
(modulesloaddir, modprobedir, d.getVar("nonarch_base_libdir")))



>
> Luca
>
> --
> Luca Ceresoli, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>


-- 
Best regards,

José Quaresma

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#183138): 
https://lists.openembedded.org/g/openembedded-core/message/183138
Mute This Topic: https://lists.openembedded.org/mt/99634397/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [OE-core] [PATCH V2 1/2] kernel-module-split: make autoload and probeconf distribution specific

2023-06-20 Thread Luca Ceresoli via lists.openembedded.org
Hello Jose,

On Mon, 19 Jun 2023 23:13:43 +
"Jose Quaresma"  wrote:

> The modules-load.d [1] - Configure kernel modules to load at boot
> should install their configuration files in /usr/lib/modules-load.d.
> 
> The modprobe.d [2] - Configuration directory for modprobe
> should install their configuration files in /lib/modprobe.d
> 
> [1] https://www.freedesktop.org/software/systemd/man/modules-load.d.html
> [2] https://www.man7.org/linux/man-pages//man5/modprobe.d.5.html
> 
> [YOCTO #12212] https://bugzilla.yoctoproject.org/show_bug.cgi?id=12212
> 
> CC: Ola x Nilsson 
> CC: Peter Kjellerstedt 
> Signed-off-by: Jose Quaresma 

This patchset is triggering some AB failures:

  Exception: NameError: name 'modprobedir' is not defined

Some logs:

https://autobuilder.yoctoproject.org/typhoon/#/builders/104/builds/6229/steps/12/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/23/builds/7658/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/120/builds/2935/steps/12/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/89/builds/7369/steps/17/logs/stdio

Luca

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#183137): 
https://lists.openembedded.org/g/openembedded-core/message/183137
Mute This Topic: https://lists.openembedded.org/mt/99634397/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [OE-core] [PATCH V2 1/2] kernel-module-split: make autoload and probeconf distribution specific

2023-06-20 Thread Ola x Nilsson

On Mon, Jun 19 2023, Jose Quaresma wrote:

> The modules-load.d [1] - Configure kernel modules to load at boot
> should install their configuration files in /usr/lib/modules-load.d.
>
> The modprobe.d [2] - Configuration directory for modprobe
> should install their configuration files in /lib/modprobe.d
>
> [1] https://www.freedesktop.org/software/systemd/man/modules-load.d.html
> [2] https://www.man7.org/linux/man-pages//man5/modprobe.d.5.html
>
> [YOCTO #12212] https://bugzilla.yoctoproject.org/show_bug.cgi?id=12212
>
> CC: Ola x Nilsson 
> CC: Peter Kjellerstedt 
> Signed-off-by: Jose Quaresma 
> ---
>
> V2: use the same location as before on the class and define the new
> location just for systemd.
>
>  .../kernel-module-split.bbclass   | 30 +--
>  .../distro/include/init-manager-systemd.inc   |  4 +++
>  2 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/meta/classes-recipe/kernel-module-split.bbclass 
> b/meta/classes-recipe/kernel-module-split.bbclass
> index 50882c31a7..ee14bb6910 100644
> --- a/meta/classes-recipe/kernel-module-split.bbclass
> +++ b/meta/classes-recipe/kernel-module-split.bbclass
> @@ -30,8 +30,11 @@ fi
>  
>  PACKAGE_WRITE_DEPS += "kmod-native depmodwrapper-cross"
>  
> +modulesloaddir ??= "${sysconfdir}/modules-load.d"
> +modprobedir ??= "${sysconfdir}/modprobe.d"
> +
>  do_install:append() {
> - install -d ${D}${sysconfdir}/modules-load.d/ 
> ${D}${sysconfdir}/modprobe.d/
> + install -d ${D}${modulesloaddir} ${D}${modprobedir}
>  }
>  
>  KERNEL_SPLIT_MODULES ?= "1"
> @@ -93,8 +96,9 @@ python split_kernel_module_packages () {
>  
>  dvar = d.getVar('PKGD')
>  
> -# If autoloading is requested, output 
> /etc/modules-load.d/.conf and append
> +# If autoloading is requested, output ${modulesloaddir}/.conf 
> and append
>  # appropriate modprobe commands to the postinst
> +autoloadpath = '%s/%s.conf' % (d.getVar('modulesloaddir'), basename)
>  autoloadlist = (d.getVar("KERNEL_MODULE_AUTOLOAD") or "").split()
>  autoload = d.getVar('module_autoload_%s' % basename)
>  if autoload and autoload == basename:
> @@ -102,8 +106,7 @@ python split_kernel_module_packages () {
>  if autoload and basename not in autoloadlist:
>  bb.warn("module_autoload_%s is defined but '%s' isn't included 
> in KERNEL_MODULE_AUTOLOAD, please add it there" % (basename, basename))
>  if basename in autoloadlist:
> -name = '%s/etc/modules-load.d/%s.conf' % (dvar, basename)
> -f = open(name, 'w')
> +f = open("%s%s" % (dvar, autoloadpath), 'w')
>  if autoload:
>  for m in autoload.split():
>  f.write('%s\n' % m)

You could take the opportunity to rewrite this section to use context
manager to handle the file object:
  with open(...) as f


> @@ -117,23 +120,19 @@ python split_kernel_module_packages () {
>  d.setVar('pkg_postinst:%s' % pkg, postinst)
>  
>  # Write out any modconf fragment
> +modconfpath = '%s/%s.conf' % (d.getVar('modprobedir'), basename)
>  modconflist = (d.getVar("KERNEL_MODULE_PROBECONF") or "").split()
>  modconf = d.getVar('module_conf_%s' % basename)
>  if modconf and basename in modconflist:
> -name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
> -f = open(name, 'w')
> +f = open("%s%s" % (dvar, modconfpath), 'w')

Same.

>  f.write("%s\n" % modconf)
>  f.close()
>  elif modconf:
>  bb.error("Please ensure module %s is listed in 
> KERNEL_MODULE_PROBECONF since module_conf_%s is set" % (basename, basename))
>  
> -files = d.getVar('FILES:%s' % pkg)
> -files = "%s /etc/modules-load.d/%s.conf /etc/modprobe.d/%s.conf" % 
> (files, basename, basename)
> -d.setVar('FILES:%s' % pkg, files)
> -
> -conffiles = d.getVar('CONFFILES:%s' % pkg)
> -conffiles = "%s /etc/modules-load.d/%s.conf /etc/modprobe.d/%s.conf" 
> % (conffiles, basename, basename)
> -d.setVar('CONFFILES:%s' % pkg, conffiles)
> +appendfiles = " %s %s" % (autoloadpath, modconfpath)
> +d.appendVar('FILES:%s' % pkg, appendfiles)
> +d.appendVar('CONFFILES:%s' % pkg, appendfiles)
>  

I think it would be best to use autoloadpath and modconfpath for the
automatic creation of such files, but use all known variants of these
paths for the package splitting.  If the module makefile creates the
files in one of the places the package splitter should find them without
requireing the customization of the recipe. 

>  if "description" in vals:
>  old_desc = d.getVar('DESCRIPTION:' + pkg) or ""
> @@ -169,8 +168,7 @@ python split_kernel_module_packages () {
>  postrm = d.getVar('pkg_postrm:modules')
>  
>  if splitmods != '1':
> -etcdir = d.getVar('sysconfdir')
> -

Re: [OE-core] [PATCH V2 1/2] kernel-module-split: make autoload and probeconf distribution specific

2023-06-19 Thread Peter Kjellerstedt
> -Original Message-
> From: Jose Quaresma 
> Sent: den 20 juni 2023 01:14
> To: openembedded-core@lists.openembedded.org
> Cc: Jose Quaresma ; Ola x Nilsson 
> ; Peter Kjellerstedt 
> Subject: [PATCH V2 1/2] kernel-module-split: make autoload and probeconf 
> distribution specific
> 
> The modules-load.d [1] - Configure kernel modules to load at boot
> should install their configuration files in /usr/lib/modules-load.d.
> 
> The modprobe.d [2] - Configuration directory for modprobe
> should install their configuration files in /lib/modprobe.d
> 
> [1] https://www.freedesktop.org/software/systemd/man/modules-load.d.html
> [2] https://www.man7.org/linux/man-pages//man5/modprobe.d.5.html
> 
> [YOCTO #12212] https://bugzilla.yoctoproject.org/show_bug.cgi?id=12212
> 
> CC: Ola x Nilsson 
> CC: Peter Kjellerstedt 
> Signed-off-by: Jose Quaresma 
> ---
> 
> V2: use the same location as before on the class and define the new
> location just for systemd.
> 
>  .../kernel-module-split.bbclass   | 30 +--
>  .../distro/include/init-manager-systemd.inc   |  4 +++
>  2 files changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/meta/classes-recipe/kernel-module-split.bbclass 
> b/meta/classes-recipe/kernel-module-split.bbclass
> index 50882c31a7..ee14bb6910 100644
> --- a/meta/classes-recipe/kernel-module-split.bbclass
> +++ b/meta/classes-recipe/kernel-module-split.bbclass

[cut]

> @@ -169,8 +168,7 @@ python split_kernel_module_packages () {
>  postrm = d.getVar('pkg_postrm:modules')
> 
>  if splitmods != '1':
> -etcdir = d.getVar('sysconfdir')
> -d.appendVar('FILES:' + metapkg, '%s/modules-load.d/ %s/modprobe.d/ 
> %s/modules/' % (etcdir, etcdir, d.getVar("nonarch_base_libdir")))
> +d.appendVar('FILES:' + metapkg, '%s/ %s/ %s/modules/' % 
> (modulesloaddir, modprobedir, d.getVar("nonarch_base_libdir")))

There is no need for the trailing slashes in FILES:${PN}, so the above 
can be simplified to: 

d.appendVar('FILES:' + metapkg, '%s %s %s/modules' % (modulesloaddir, 
modprobedir, d.getVar("nonarch_base_libdir")))

Not sure that warrants a new patch though.

>  d.appendVar('pkg_postinst:%s' % metapkg, postinst)
>  d.prependVar('pkg_postrm:%s' % metapkg, postrm);
>  return

Reviewed-by: Peter Kjellerstedt 

//Peter


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#183127): 
https://lists.openembedded.org/g/openembedded-core/message/183127
Mute This Topic: https://lists.openembedded.org/mt/99634397/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[OE-core] [PATCH V2 1/2] kernel-module-split: make autoload and probeconf distribution specific

2023-06-19 Thread Jose Quaresma
The modules-load.d [1] - Configure kernel modules to load at boot
should install their configuration files in /usr/lib/modules-load.d.

The modprobe.d [2] - Configuration directory for modprobe
should install their configuration files in /lib/modprobe.d

[1] https://www.freedesktop.org/software/systemd/man/modules-load.d.html
[2] https://www.man7.org/linux/man-pages//man5/modprobe.d.5.html

[YOCTO #12212] https://bugzilla.yoctoproject.org/show_bug.cgi?id=12212

CC: Ola x Nilsson 
CC: Peter Kjellerstedt 
Signed-off-by: Jose Quaresma 
---

V2: use the same location as before on the class and define the new
location just for systemd.

 .../kernel-module-split.bbclass   | 30 +--
 .../distro/include/init-manager-systemd.inc   |  4 +++
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/meta/classes-recipe/kernel-module-split.bbclass 
b/meta/classes-recipe/kernel-module-split.bbclass
index 50882c31a7..ee14bb6910 100644
--- a/meta/classes-recipe/kernel-module-split.bbclass
+++ b/meta/classes-recipe/kernel-module-split.bbclass
@@ -30,8 +30,11 @@ fi
 
 PACKAGE_WRITE_DEPS += "kmod-native depmodwrapper-cross"
 
+modulesloaddir ??= "${sysconfdir}/modules-load.d"
+modprobedir ??= "${sysconfdir}/modprobe.d"
+
 do_install:append() {
-   install -d ${D}${sysconfdir}/modules-load.d/ 
${D}${sysconfdir}/modprobe.d/
+   install -d ${D}${modulesloaddir} ${D}${modprobedir}
 }
 
 KERNEL_SPLIT_MODULES ?= "1"
@@ -93,8 +96,9 @@ python split_kernel_module_packages () {
 
 dvar = d.getVar('PKGD')
 
-# If autoloading is requested, output /etc/modules-load.d/.conf 
and append
+# If autoloading is requested, output ${modulesloaddir}/.conf 
and append
 # appropriate modprobe commands to the postinst
+autoloadpath = '%s/%s.conf' % (d.getVar('modulesloaddir'), basename)
 autoloadlist = (d.getVar("KERNEL_MODULE_AUTOLOAD") or "").split()
 autoload = d.getVar('module_autoload_%s' % basename)
 if autoload and autoload == basename:
@@ -102,8 +106,7 @@ python split_kernel_module_packages () {
 if autoload and basename not in autoloadlist:
 bb.warn("module_autoload_%s is defined but '%s' isn't included in 
KERNEL_MODULE_AUTOLOAD, please add it there" % (basename, basename))
 if basename in autoloadlist:
-name = '%s/etc/modules-load.d/%s.conf' % (dvar, basename)
-f = open(name, 'w')
+f = open("%s%s" % (dvar, autoloadpath), 'w')
 if autoload:
 for m in autoload.split():
 f.write('%s\n' % m)
@@ -117,23 +120,19 @@ python split_kernel_module_packages () {
 d.setVar('pkg_postinst:%s' % pkg, postinst)
 
 # Write out any modconf fragment
+modconfpath = '%s/%s.conf' % (d.getVar('modprobedir'), basename)
 modconflist = (d.getVar("KERNEL_MODULE_PROBECONF") or "").split()
 modconf = d.getVar('module_conf_%s' % basename)
 if modconf and basename in modconflist:
-name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
-f = open(name, 'w')
+f = open("%s%s" % (dvar, modconfpath), 'w')
 f.write("%s\n" % modconf)
 f.close()
 elif modconf:
 bb.error("Please ensure module %s is listed in 
KERNEL_MODULE_PROBECONF since module_conf_%s is set" % (basename, basename))
 
-files = d.getVar('FILES:%s' % pkg)
-files = "%s /etc/modules-load.d/%s.conf /etc/modprobe.d/%s.conf" % 
(files, basename, basename)
-d.setVar('FILES:%s' % pkg, files)
-
-conffiles = d.getVar('CONFFILES:%s' % pkg)
-conffiles = "%s /etc/modules-load.d/%s.conf /etc/modprobe.d/%s.conf" % 
(conffiles, basename, basename)
-d.setVar('CONFFILES:%s' % pkg, conffiles)
+appendfiles = " %s %s" % (autoloadpath, modconfpath)
+d.appendVar('FILES:%s' % pkg, appendfiles)
+d.appendVar('CONFFILES:%s' % pkg, appendfiles)
 
 if "description" in vals:
 old_desc = d.getVar('DESCRIPTION:' + pkg) or ""
@@ -169,8 +168,7 @@ python split_kernel_module_packages () {
 postrm = d.getVar('pkg_postrm:modules')
 
 if splitmods != '1':
-etcdir = d.getVar('sysconfdir')
-d.appendVar('FILES:' + metapkg, '%s/modules-load.d/ %s/modprobe.d/ 
%s/modules/' % (etcdir, etcdir, d.getVar("nonarch_base_libdir")))
+d.appendVar('FILES:' + metapkg, '%s/ %s/ %s/modules/' % 
(modulesloaddir, modprobedir, d.getVar("nonarch_base_libdir")))
 d.appendVar('pkg_postinst:%s' % metapkg, postinst)
 d.prependVar('pkg_postrm:%s' % metapkg, postrm);
 return
@@ -189,7 +187,7 @@ python split_kernel_module_packages () {
 # avoid warnings. removedirs only raises an OSError if an empty
 # directory cannot be removed.
 dvar = d.getVar('PKGD')
-for dir in ["%s/etc/modprobe.d" % (dvar), "%s/etc/modules-load.d" % 
(dvar), "%s/etc" % (dvar)]:
+for dir in ["%s%s"