Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 937566

Summary: virtual/linux-sources do not provide sources for dist kernels
Product: Gentoo Linux Reporter: romikb
Component: Current packagesAssignee: Distribution Kernel Project <dist-kernel>
Status: UNCONFIRMED ---    
Severity: normal CC: andrewammerlaan, dist-kernel, kernel, kuraga333, mgorny, romikb
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Example ebuild
proof of concept patch for kernel-build.eclass

Description romikb 2024-08-08 09:31:37 UTC
The virtual/linux-sources depends from sys-kernel/gentoo-kernel or sys-kernel/gentoo-kernel-bin packages which not provide sources. The virtual/linux-sources should not depend from this packages or the packages should provide sources.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-08-08 09:33:49 UTC
Can you explain why this matters? virtual/linux-sources is for ebuilds to depend on when they, really, need you to just have some kernel to build modules against or whatever. It's not intended for users to just emerge the virtual hence it shouldn't matter.

Please elaborate.
Comment 2 romikb 2024-08-08 10:48:39 UTC
There are two types of modules. The usual that require only the headers for build. And modules that depend of kernel source and require reuse some of kernel sources (*.c files for example) for build. With traditional source based kernels virtual/linux-sources is sufficient for any type of module because the headers and sources are in /usr/src/linux. When dist kernels are used only the headers are provided by virtual/linux-sources and only the first type of modules can be build.

I think that should be a way for an all types of modules to be build. And somehow providing sources (not only headers) for dist kernels with virtual/linux-sources is look as the best way for me. For exmaple adding sys-kernel/gentoo-kernel-sources and sys-kernel/gentoo-kernel-bin-source packages of some USE flags for existing packages can help.

Or if the virtual/linux-sources are exist only to provide headers than it should be renamed to virtual/linux-headers or the corresponding description should be added.
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-08-08 11:02:48 UTC
(In reply to romikb from comment #2)
> There are two types of modules. The usual that require only the headers for
> build. And modules that depend of kernel source and require reuse some of
> kernel sources (*.c files for example) for build.

Can you give an example of one of the latter so we can look into it?

> [...]

Yeah, this is a fair point, I think. I'm just surprised to learn such modules exist. Can you show me a few?
Comment 4 romikb 2024-08-08 12:10:20 UTC
I am new to Gentoo and can't say anything about the modules in main tree. May be some overlays have.
My example is https://github.com/amnezia-vpn/amneziawg-linux-kernel-module. It have packages for other distros. Some month ago I wrote a simple ebuild for Funtoo for this module. Funtoo prebuild kernel provide sources by default. Now I try to add an ebuild to my Gentoo overlay.
I attach my Funtoo module ebuild as example after this post.
Comment 5 romikb 2024-08-08 12:12:10 UTC
Created attachment 899603 [details]
Example ebuild
Comment 6 Nowa Ammerlaan gentoo-dev 2024-08-08 12:14:10 UTC
It is my understanding that it is bad practice for an out-of-tree kernel module to directly rely on the kernel sources.

That being said, I suppose we could add USE=source to optionally also install the kernel source code.
Comment 7 Nowa Ammerlaan gentoo-dev 2024-08-08 12:54:53 UTC
Created attachment 899604 [details]
proof of concept patch for kernel-build.eclass

Just as a quick proof of concept, the attached patch installs the dist-kernel with the kernel sources included if USE=source.
Comment 8 romikb 2024-08-08 13:06:23 UTC
> It is my understanding that it is bad practice for an out-of-tree kernel module to directly rely on the kernel sources.
I agree with this. Module dev says that source they require is different on different kernels and different distros and they can't put it in repo.

>That being said, I suppose we could add USE=source to optionally also install the kernel source code.
It looks like one of solutions. But if the module ebuild is depend from virtual/linux-sources and if virtual/linux-sources will be dependent from sys-kernel/gentoo-kernel[source] will it require the kernel rebuild if user have sys-kernel/gentoo-kernel without USE=sources?
I look at having a separate sys-kernel/gentoo-kernel(-bin)-source package that emerge source when module emerge virtual/linux-sources and remove them after module build on unmerge virtual/linux-sources. But it look weird.
Comment 9 Nowa Ammerlaan gentoo-dev 2024-08-08 13:15:50 UTC
(In reply to romikb from comment #8).
> It looks like one of solutions. But if the module ebuild is depend from
> virtual/linux-sources and if virtual/linux-sources will be dependent from
> sys-kernel/gentoo-kernel[source] will it require the kernel rebuild if user
> have sys-kernel/gentoo-kernel without USE=sources?

Yes

> I look at having a separate sys-kernel/gentoo-kernel(-bin)-source package
> that emerge source when module emerge virtual/linux-sources and remove them
> after module build on unmerge virtual/linux-sources. But it look weird.

We already have a separate package package providing the sources for sys-kernel/gentoo-kernel(-bin). That is what sys-kernel/gentoo-sources is.

Is your proposal to adjust virtual/linux-sources to depend only on sys-kernel/*-sources packages? I suppose it could be done, but it would require adjusting a bunch of dependencies elsewhere, and possibly introducing a new virtual/linux that depends on either virtual/linux-sources or virtual/dist-kernel.
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-08-08 13:42:23 UTC
I'd rather look into providing the specific source files that specific modules need.  The whole set can be rather big.
Comment 11 Nowa Ammerlaan gentoo-dev 2024-08-08 13:50:32 UTC
(In reply to romikb from comment #8)
> > It is my understanding that it is bad practice for an out-of-tree kernel module to directly rely on the kernel sources.
> I agree with this. Module dev says that source they require is different on
> different kernels and different distros and they can't put it in repo.

On another note, this seems *extremely* fragile. It really needs a better solution upstream.
Comment 12 romikb 2024-08-08 18:10:05 UTC
(In reply to Andrew Nowa Ammerlaan from comment #9)
> We already have a separate package package providing the sources for
> sys-kernel/gentoo-kernel(-bin). That is what sys-kernel/gentoo-sources is.

Can I somehow ask the portage to emerge gentoo-sources of the same version as gentoo-kernel(-bin) is installed?

> Is your proposal to adjust virtual/linux-sources to depend only on
> sys-kernel/*-sources packages?

I would like to propose to eliminate the uncertainty.

Remove packages that not provide sources or make this packages provide sources or change the description to "Provide headers and sources (if available)" or anything else. I am too new in Gentoo and don't know the right way.

> I'd rather look into providing the specific source files that specific modules
> need.  The whole set can be rather big.

Possibly I can fork the module repo later. Now I don't sure how different required for module kernel sources in different kernels in Gentoo.
Comment 13 Nowa Ammerlaan gentoo-dev 2024-08-08 18:35:52 UTC
(In reply to romikb from comment #12)
> (In reply to Andrew Nowa Ammerlaan from comment #9)
> > We already have a separate package package providing the sources for
> > sys-kernel/gentoo-kernel(-bin). That is what sys-kernel/gentoo-sources is.
> 
> Can I somehow ask the portage to emerge gentoo-sources of the same version
> as gentoo-kernel(-bin) is installed?

Sort off, you can specifically choose which kernel version to emerge:

emerge sys-kernel/gentoo-sources:x.y.z sys-kernel/gentoo-kernel:x.y.z

 
> > Is your proposal to adjust virtual/linux-sources to depend only on
> > sys-kernel/*-sources packages?
> 
> I would like to propose to eliminate the uncertainty.
> 
> Remove packages that not provide sources or make this packages provide
> sources or change the description to "Provide headers and sources (if
> available)" or anything else. I am too new in Gentoo and don't know the
> right way.

I suppose it does make sense for the package named linux-sources to actually provide the sources. The difficulty is just that a lot of stuff depends on this, so changing it is probably a lot of work (not to mention that the documentation would need updating as well).
Comment 14 Mike Pagano gentoo-dev 2024-10-21 20:35:16 UTC
Reassigning to Distribution Kernel folks as this discussion is around those ebuilds and proposed changes to them