kernel-module-split: install config modules directories only when they are needed

Instaed of allways create the directories and removing it at the if they are
not used, we can just do it when there are modules configuration to be created.
So the best thing to do is install the directories only when necessary.

(From OE-Core rev: 71460993f350bca3d5a22115fd5551696f955c9f)

Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Jose Quaresma
2023-06-27 10:16:41 +00:00
committed by Richard Purdie
parent ff3d1490a4
commit 66b8e3c14d

View File

@@ -30,10 +30,6 @@ fi
PACKAGE_WRITE_DEPS += "kmod-native depmodwrapper-cross"
do_install:append() {
install -d ${D}${sysconfdir}/modules-load.d/ ${D}${sysconfdir}/modprobe.d/
}
KERNEL_SPLIT_MODULES ?= "1"
PACKAGESPLITFUNCS =+ "split_kernel_module_packages"
@@ -102,7 +98,9 @@ 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)
conf = '/etc/modules-load.d/%s.conf' % basename
name = '%s%s' % (dvar, conf)
os.makedirs(os.path.dirname(name), exist_ok=True)
f = open(name, 'w')
if autoload:
for m in autoload.split():
@@ -110,6 +108,9 @@ python split_kernel_module_packages () {
else:
f.write('%s\n' % basename)
f.close()
conf2append = ' %s' % conf
d.appendVar('FILES:%s' % pkg, conf2append)
d.appendVar('CONFFILES:%s' % pkg, conf2append)
postinst = d.getVar('pkg_postinst:%s' % pkg)
if not postinst:
bb.fatal("pkg_postinst:%s not defined" % pkg)
@@ -120,21 +121,19 @@ python split_kernel_module_packages () {
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)
conf = '/etc/modprobe.d/%s.conf' % basename
name = '%s%s' % (dvar, conf)
os.makedirs(os.path.dirname(name), exist_ok=True)
f = open(name, 'w')
f.write("%s\n" % modconf)
f.close()
conf2append = ' %s' % conf
d.appendVar('FILES:%s' % pkg, conf2append)
d.appendVar('CONFFILES:%s' % pkg, conf2append)
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)
if "description" in vals:
old_desc = d.getVar('DESCRIPTION:' + pkg) or ""
d.setVar('DESCRIPTION:' + pkg, old_desc + "; " + vals["description"])
@@ -184,14 +183,6 @@ python split_kernel_module_packages () {
modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
if modules:
d.appendVar('RDEPENDS:' + metapkg, ' '+' '.join(modules))
# If modules-load.d and modprobe.d are empty at this point, remove them to
# 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)]:
if len(os.listdir(dir)) == 0:
os.rmdir(dir)
}
do_package[vardeps] += '${@" ".join(map(lambda s: "module_conf_" + s, (d.getVar("KERNEL_MODULE_PROBECONF") or "").split()))}'