All of lore.kernel.org
 help / color / mirror / Atom feed
* [OE-core][PATCH 1/2] kernel-module-split: make autoload and probeconf distribution specific
@ 2023-02-15 13:00 Jose Quaresma
  2023-02-15 13:00 ` [OE-core][PATCH 2/2] kernel: autoload and probeconf are handled by kernel-module-split Jose Quaresma
  2023-02-15 13:25 ` [OE-core][PATCH 1/2] kernel-module-split: make autoload and probeconf distribution specific Otavio Salvador
  0 siblings, 2 replies; 10+ messages in thread
From: Jose Quaresma @ 2023-02-15 13:00 UTC (permalink / raw)
  To: openembedded-core; +Cc: 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

Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
 .../kernel-module-split.bbclass               | 30 +++++++++----------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/meta/classes-recipe/kernel-module-split.bbclass b/meta/classes-recipe/kernel-module-split.bbclass
index 50882c31a7..b70650888a 100644
--- a/meta/classes-recipe/kernel-module-split.bbclass
+++ b/meta/classes-recipe/kernel-module-split.bbclass
@@ -31,7 +31,8 @@ fi
 PACKAGE_WRITE_DEPS += "kmod-native depmodwrapper-cross"
 
 do_install:append() {
-	install -d ${D}${sysconfdir}/modules-load.d/ ${D}${sysconfdir}/modprobe.d/
+	install -d ${D}${libdir}/modules-load.d
+	install -d ${D}${nonarch_base_libdir}/modprobe.d
 }
 
 KERNEL_SPLIT_MODULES ?= "1"
@@ -93,8 +94,9 @@ python split_kernel_module_packages () {
 
         dvar = d.getVar('PKGD')
 
-        # If autoloading is requested, output /etc/modules-load.d/<name>.conf and append
+        # If autoloading is requested, output ${libdir}/modules-load.d/<name>.conf and append
         # appropriate modprobe commands to the postinst
+        autoloadpath = '%s/modules-load.d/%s.conf' % (d.getVar('libdir'), basename)
         autoloadlist = (d.getVar("KERNEL_MODULE_AUTOLOAD") or "").split()
         autoload = d.getVar('module_autoload_%s' % basename)
         if autoload and autoload == basename:
@@ -102,8 +104,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 +118,19 @@ python split_kernel_module_packages () {
             d.setVar('pkg_postinst:%s' % pkg, postinst)
 
         # Write out any modconf fragment
+        modconfpath = '%s/modprobe.d/%s.conf' % (d.getVar('nonarch_base_libdir'), 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 ""
@@ -167,10 +164,11 @@ python split_kernel_module_packages () {
     splitmods = d.getVar('KERNEL_SPLIT_MODULES')
     postinst = d.getVar('pkg_postinst:modules')
     postrm = d.getVar('pkg_postrm:modules')
+    nonarch_base_libdir = d.getVar("nonarch_base_libdir")
+    libdir = d.getVar("libdir")
 
     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/modules-load.d/ %s/modprobe.d/ %s/modules/' % (libdir, nonarch_base_libdir, 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/modprobe.d" % (dvar, nonarch_base_libdir), "%s%s/modules-load.d" % (dvar, libdir)]:
         if len(os.listdir(dir)) == 0:
             os.rmdir(dir)
 }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-06-19 23:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15 13:00 [OE-core][PATCH 1/2] kernel-module-split: make autoload and probeconf distribution specific Jose Quaresma
2023-02-15 13:00 ` [OE-core][PATCH 2/2] kernel: autoload and probeconf are handled by kernel-module-split Jose Quaresma
2023-02-15 13:25 ` [OE-core][PATCH 1/2] kernel-module-split: make autoload and probeconf distribution specific Otavio Salvador
2023-02-15 15:10   ` Jose Quaresma
2023-02-16  8:21     ` Ola x Nilsson
2023-02-16 11:08       ` Jose Quaresma
2023-02-17 10:52         ` Peter Kjellerstedt
2023-02-17 16:53           ` Jose Quaresma
2023-06-16 16:03             ` Peter Kjellerstedt
2023-06-19 23:20               ` Jose Quaresma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.