Bug 14492

Summary: Error when installing split kernel modules on rootfs
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Otavio Salvador <otavio>
Component: coreAssignee: Unassigned <unassigned>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Medium+ CC: alex.stewart, astewart.49c6, meta.mr.watcher, meta.watcher, randy.macleod, richard.purdie, zhe.he
Version: unspecified   
Target Milestone: Future   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: New (Never tested)
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Screenshot of error none

Description Otavio Salvador 2021-07-28 15:10:58 UTC
When adding a new Linux Wireless driver to a customer BSP we noticed this weird behavior. In fact, we could reproduce it using hello-mod.

Long history, short, is that we get an error when generating the image. The rootfs log says:

 * opkg_prepare_url_for_install: Couldn't find anything to satisfy 'kernel-module-hello'.


To reproduce the error, we need to apply following patch:

diff --git a/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb b/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb
index bc9acccd5f..e931428538 100644
--- a/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb
+++ b/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb
@@ -15,4 +15,6 @@ S = "${WORKDIR}"
 # The inherit of module.bbclass will automatically name module packages with
 # "kernel-module-" prefix as required by the oe-core build environment.
 
-RPROVIDES_${PN} += "kernel-module-hello"
+PACKAGES_DYNAMIC = "^kernel-module-.*"
+
+#RPROVIDES_${PN} += "kernel-module-hello"

So we can avoid adding the explicit rprovides to the main recipe. Next, I added to local.conf:

PACKAGE_CLASSES = 'package_ipk'
IMAGE_INSTALL_append = " kernel-module-hello"

and enabled meta-skeleton in bblayers.conf.

I used 'core-image-minimal' as image.
Comment 1 Otavio Salvador 2021-07-28 15:15:54 UTC
On first run, the kernel module is not built.  So I triggered it using:

bitbake hello-mod

and it still fail on rootfs generation. oe-pkgdata-util has:

% oe-pkgdata-util package-info kernel-module-hello                                                                                         kernel-module-hello is in the RPROVIDES of kernel-module-hello-5.4.126+ga402819056e6:
kernel-module-hello 0.1-r0 hello-mod 0.1-r0 3008
Comment 2 Otavio Salvador 2021-07-28 15:21:45 UTC
I understand that BitBake cannot infer that kernel-module-hello will be built, so it cannot add the rprovides to the metadata automatically however once the hello-mod recipe is built it does know it.

I tried multiple things:

  - PROVIDES += "kernel-module-hello"
  - PACKAGES_DYNAMIC = "^kernel-module-hello$"

and I could only proceed adding it to the RPROVIDES_${PN} list. This seems like a bug to me and I'd like to understand what is going on here.
Comment 3 Otavio Salvador 2021-07-28 20:10:49 UTC
Created attachment 4817 [details]
Screenshot of error
Comment 4 Richard Purdie 2021-07-28 20:15:41 UTC
Alex - This does look a bit like an opkg issue. Could you have a look at the attached screenshot as it shows the opkg command and the fact the package has an RPROVIDES that should mean opkg should install it, at least as I understand things.
Comment 5 Alex Stewart 2021-07-29 02:37:01 UTC
That certainly seems concerning. I should have some time to take a look at it this weekend.

Interesting that it bares some superficial similarities to opkg bug 11459.
https://bugzilla.yoctoproject.org/show_bug.cgi?id=14459
Comment 6 Alex Stewart 2021-08-04 00:03:24 UTC
I was able to reproduce the do_rootfs error here, using the diff that Otavio posted. When the `core-image-minimal` recipe is building its rootfs, it first populates a recipe-specific package feed at...

`build:tmp-glibc/work/qemux86_64-oe-linux/core-image-minimal/1.0-r0/oe-rootfs-repo`

... to-which the create_packages_dir() method [1] will copy all IPKs which are owned by recipes *which are task-dependencies of the core-image-minimal.do_rootfs` task*.

When you removed the `RPROVIDES:${PN}` line, it broke the task dependecy with the core image. And neither the PACKAGES_DYNAMIC, nor IMAGE_INSTALL variables asserts a task dependency in its place. So the `hello-mod` IPKs are never added to the recipe-specific dir, and opkg is unaware of them at install time.

You can interrogate the `core-image-minimal` dependencies using `bitbake -g`.

So this isn't an opkg bug, since the IPK is never gets that far. I'll move this bug back to OE, since there is an argument to be made that IMAGE_INSTALL should be more intelligent about adding do_rootfs dependencies.

[1] https://git.openembedded.org/openembedded-core/tree/meta/lib/oe/package_manager/__init__.py#n451
Comment 7 Richard Purdie 2021-08-04 15:21:48 UTC
(In reply to comment #6)
> I was able to reproduce the do_rootfs error here, using the diff that Otavio
> posted. When the `core-image-minimal` recipe is building its rootfs, it
> first populates a recipe-specific package feed at...
> 
> `build:tmp-glibc/work/qemux86_64-oe-linux/core-image-minimal/1.0-r0/oe-
> rootfs-repo`
> 
> ... to-which the create_packages_dir() method [1] will copy all IPKs which
> are owned by recipes *which are task-dependencies of the
> core-image-minimal.do_rootfs` task*.
> 
> When you removed the `RPROVIDES:${PN}` line, it broke the task dependecy
> with the core image. And neither the PACKAGES_DYNAMIC, nor IMAGE_INSTALL
> variables asserts a task dependency in its place. So the `hello-mod` IPKs
> are never added to the recipe-specific dir, and opkg is unaware of them at
> install time.

Thanks for debugging that and sorry it turned out to be an OE-Core issue. It certainly makes more sense now, I was rather worried it was an opkg issue similar to that other reported bug.

The trouble now is I don't know how we can have bitbake know to get "kernel-module-hello" from hello-mod instead of the default kernel, or even how to make it clear to the user there is a potential issue...
Comment 8 Otavio Salvador 2021-08-04 16:30:49 UTC
Using the generated package name isn't a possibility?
Comment 9 Richard Purdie 2021-08-04 16:55:58 UTC
(In reply to comment #8)
> Using the generated package name isn't a possibility?

No, the task graph can't use generated information.
Comment 10 Alex Stewart 2021-08-04 19:01:26 UTC
I think it's interesting that `RPROVIDES` *does* add a task dependency to the image recipe, and also that `PROVIDES` does not (in both my and Otavio's testing).

AFAIK, the only breadcrumb which connects the image and module recipes is IMAGE_INSTALL - so it seems like *something* is doing a reverse lookup based on the package name. Maybe the next step is to trace down that codepath and see if we're doing something wacky, or if it can service as the basis for a better solution.
Comment 11 Randy MacLeod 2025-08-14 14:56:34 UTC
Zhe, can you try to find time for this in the coming month or so?
I'm not sure if it's still a problem.