Skip to content

Commit e3402fe

Browse files
michalsieronrpurdie
authored andcommitted
kernel-module-split: Allow for external conf files
Some recipes might provide conf files produced during build phase or simply tracked in the VCS instead of generating them with Yocto. In such cases those conf files wouldn't be assigned to correct packages. With this change, if user wants to generate a conf file they still can, but not generating them won't prevent assigning the file to proper package given the file exists. (From OE-Core rev: c7faf141592d1e2a5cab32a83f7e1498ee498d65) Signed-off-by: Michal Sieron <michalwsieron@gmail.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
1 parent 396e454 commit e3402fe

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

meta/classes-recipe/kernel-module-split.bbclass

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,22 @@ python split_kernel_module_packages () {
9999
bb.warn("module_autoload_%s was replaced by KERNEL_MODULE_AUTOLOAD for cases where basename == module name, please drop it" % basename)
100100
if autoload and basename not in autoloadlist:
101101
bb.warn("module_autoload_%s is defined but '%s' isn't included in KERNEL_MODULE_AUTOLOAD, please add it there" % (basename, basename))
102+
103+
# The .conf file can either be installed by a recipe or generated from module_autoload_*
104+
conf = '%s/%s.conf' % (d.getVar('modulesloaddir'), basename)
105+
name = '%s%s' % (dvar, conf)
106+
# If module name is in KERNEL_MODULE_AUTOLOAD, then generate the .conf file and write to `name`.
102107
if basename in autoloadlist:
103-
conf = '%s/%s.conf' % (d.getVar('modulesloaddir'), basename)
104-
name = '%s%s' % (dvar, conf)
105108
os.makedirs(os.path.dirname(name), exist_ok=True)
106109
with open(name, 'w') as f:
107110
if autoload:
108111
for m in autoload.split():
109112
f.write('%s\n' % m)
110113
else:
111114
f.write('%s\n' % basename)
115+
# If the .conf file exits, then add it to FILES:* and CONFFILES:* and add postinstall hook.
116+
# It doesn't matter if it was generated from module_autoload_* or installed by the recipe.
117+
if os.path.exists(name):
112118
conf2append = ' %s' % conf
113119
d.appendVar('FILES:%s' % pkg, conf2append)
114120
d.appendVar('CONFFILES:%s' % pkg, conf2append)
@@ -121,19 +127,24 @@ python split_kernel_module_packages () {
121127
# Write out any modconf fragment
122128
modconflist = (d.getVar("KERNEL_MODULE_PROBECONF") or "").split()
123129
modconf = d.getVar('module_conf_%s' % basename)
130+
131+
# The .conf file can either be installed by a recipe or generated from module_conf_*
132+
conf = '%s/%s.conf' % (d.getVar('modprobedir'), basename)
133+
name = '%s%s' % (dvar, conf)
134+
# If module name is in KERNEL_MODULE_PROBECONF, then generate the .conf file and write to `name`.
124135
if modconf and basename in modconflist:
125-
conf = '%s/%s.conf' % (d.getVar('modprobedir'), basename)
126-
name = '%s%s' % (dvar, conf)
127136
os.makedirs(os.path.dirname(name), exist_ok=True)
128137
with open(name, 'w') as f:
129138
f.write("%s\n" % modconf)
139+
elif modconf:
140+
bb.error("Please ensure module %s is listed in KERNEL_MODULE_PROBECONF since module_conf_%s is set" % (basename, basename))
141+
# If the .conf file exits, then add it to FILES:* and CONFFILES:*.
142+
# It doesn't matter if it was generated from module_conf_* or installed by the recipe.
143+
if os.path.exists(name):
130144
conf2append = ' %s' % conf
131145
d.appendVar('FILES:%s' % pkg, conf2append)
132146
d.appendVar('CONFFILES:%s' % pkg, conf2append)
133147

134-
elif modconf:
135-
bb.error("Please ensure module %s is listed in KERNEL_MODULE_PROBECONF since module_conf_%s is set" % (basename, basename))
136-
137148
if "description" in vals:
138149
old_desc = d.getVar('DESCRIPTION:' + pkg) or ""
139150
d.setVar('DESCRIPTION:' + pkg, old_desc + "; " + vals["description"])

0 commit comments

Comments
 (0)