View previous topic :: View next topic |
Author |
Message |
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 12:16 pm Post subject: Force portage to download kernel source |
|
|
I developing a kernel module that require kernel sources while emerging.
How can I ask the portage to install a kernel source (not headers) when for example the system kernel is gentoo-kernel-bin?
gentoo-kernel-bin itself not install the sources and virtual/linux-sources not install any sources.
Should I in 2024 ask users download kernel sources manually? |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2402
|
Posted: Sun Aug 04, 2024 12:25 pm Post subject: Re: Force portage to download kernel source |
|
|
RomikB wrote: | I developing a kernel module that require kernel sources while emerging. |
then you're using something you're not supposed to.
RomikB wrote: | Should I in 2024 ask users download kernel sources manually? |
That's the wrong question to ask. Kernel modules in 2024 require kernel headers only. And they should always have. Headers are the contract with the outside world, what happens in sources is not guaranteed to stay stable. You should conform to the contract, not dig something from the sources.
Best Regards,
Georgi |
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9608 Location: beyond the rim
|
Posted: Sun Aug 04, 2024 1:18 pm Post subject: |
|
|
There is no way you can ensure that installed kernel sources would match the running kernel anyway.
Why do you think you need kernel sources installed for your module? |
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 1:26 pm Post subject: Re: Force portage to download kernel source |
|
|
logrusx wrote: | then you're using something you're not supposed to. |
I try to emerge the sources of prebuild kernel. Many distribs, possible all, allow it, why gentoo not?
logrusx wrote: | That's the wrong question to ask. Kernel modules in 2024 require kernel headers only. And they should always have. Headers are the contract with the outside world, what happens in sources is not guaranteed to stay stable. You should conform to the contract, not dig something from the sources. |
I need to clone some sources from a module integrated in kernel and make a new a little changed module.
And the general question why virtual/linux-sources not emerge sources? Any distrib do it for prebuild kernels why gentoo not? |
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 1:29 pm Post subject: |
|
|
Genone wrote: | There is no way you can ensure that installed kernel sources would match the running kernel anyway.
Why do you think you need kernel sources installed for your module? |
Any prebuild kernel have sources, I just want to find a correct and automatic way to emerge it. |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5093 Location: Bavaria
|
Posted: Sun Aug 04, 2024 1:34 pm Post subject: Re: Force portage to download kernel source |
|
|
RomikB wrote: | And the general question why virtual/linux-sources not emerge sources? Any distrib do it for prebuild kernels why gentoo not? |
... because you dont need virtual/linux-sources but sys-kernel/gentoo-sources.
Be aware that the default configuration is NOT the configuration of our distribution kernel. You surely know how to get the config from the dist-kernel (zcat /proc/config.gz > running.config) _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 1:52 pm Post subject: Re: Force portage to download kernel source |
|
|
pietinger wrote: | ... because you dont need virtual/linux-sources but sys-kernel/gentoo-sources. |
I know. But it is not the answer why linux-sources emege headers not sources for gentoo prebuild kernel.
pietinger wrote: | Be aware that the default configuration is NOT the configuration of our distribution kernel. You surely know how to get the config from the dist-kernel (zcat /proc/config.gz > running.config) |
Not sure what are try to say. I guess that for this kernel sys-kernel/gentoo-kernel-bin the sources are in sys-kernel/gentoo-kernel and there is a way to emerge it (without additional kernel compilations). |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2402
|
Posted: Sun Aug 04, 2024 2:00 pm Post subject: Re: Force portage to download kernel source |
|
|
RomikB wrote: | I guess that for this kernel sys-kernel/gentoo-kernel-bin the sources are in sys-kernel/gentoo-kernel and there is a way to emerge it (without additional kernel compilations). |
They are not. Gentoo-kernel produces the same result as gentoo-kernel-bin but compiled on your computer. Once again, you should not be needing kernel sources to compile a kernel module. That's wrong.
May I ask what does that kernel module do? Is it necessarily a kernel module?
Best Regards,
Georgi |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22619
|
Posted: Sun Aug 04, 2024 2:05 pm Post subject: Re: Force portage to download kernel source |
|
|
RomikB wrote: | pietinger wrote: | ... because you dont need virtual/linux-sources but sys-kernel/gentoo-sources. | I know. But it is not the answer why linux-sources emege headers not sources for gentoo prebuild kernel. | As I read the ebuild, virtual/linux-sources will pull in some source package, though not necessarily sys-kernel/gentoo-sources. It could pull in any of 13 different possibilities, all of which look to me like they would provide actual kernel sources. |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5093 Location: Bavaria
|
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 2:21 pm Post subject: Re: Force portage to download kernel source |
|
|
logrusx wrote: | They are not. Gentoo-kernel produces the same result as gentoo-kernel-bin but compiled on your computer. Once again, you should not be needing kernel sources to compile a kernel module. That's wrong. |
Is the answer is: "gentoo-kernel-bin have no sources if you need sources use another kernel.
logrusx wrote: | May I ask what does that kernel module do? Is it necessarily a kernel module? |
It is a fork of the wireguard kernel module. It use the sources of wireguard, patch them and add new. I not the author, just try to make a gentoo ebuild. It compiles and work on many distribs that use prebuild kernel. I want to do the same here on gentoo. |
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 2:27 pm Post subject: Re: Force portage to download kernel source |
|
|
Hu wrote: | As I read the ebuild, virtual/linux-sources will pull in some source package, though not necessarily sys-kernel/gentoo-sources. It could pull in any of 13 different possibilities, all of which look to me like they would provide actual kernel sources. |
The virtual/linux-sources think that gentoo-kernel-bin provide sources and not try any other possibilities. But gentoo-kernel-bin not provide sources only headers. |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2402
|
Posted: Sun Aug 04, 2024 2:27 pm Post subject: Re: Force portage to download kernel source |
|
|
RomikB wrote: |
It is a fork of the wireguard kernel module. |
That does not need to be a kernel module. The poor choice to make it so also explains the need for kernel sources. Better not bother with it.
Best Regards,
Georgi |
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 2:33 pm Post subject: Re: Force portage to download kernel source |
|
|
logrusx wrote: | That does not need to be a kernel module. The poor choice to make it so also explains the need for kernel sources. Better not bother with it. |
A module wants to be a module for the same reason that wireguard does. Network modules are faster and use less resources. |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2402
|
Posted: Sun Aug 04, 2024 2:47 pm Post subject: Re: Force portage to download kernel source |
|
|
RomikB wrote: | logrusx wrote: | That does not need to be a kernel module. The poor choice to make it so also explains the need for kernel sources. Better not bother with it. |
A module wants to be a module for the same reason that wireguard does. Network modules are faster and use less resources. |
What I see is two poor design choices. For me this is alarming.
You can do whatever you like of course, but I would not bother with it. Especially writing an ebuild for it.
Best Regards,
Georgi |
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 3:05 pm Post subject: Re: Force portage to download kernel source |
|
|
logrusx wrote: | What I see is two poor design choices. For me this is alarming. |
As I know all linux network are inside the kernel. Is it poor design?
logrusx wrote: | You can do whatever you like of course, but I would not bother with it. Especially writing an ebuild for it. |
Unfortunately I need to use it. And if I make an ebuild upgrading kernel will be easy. |
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Sun Aug 04, 2024 3:08 pm Post subject: Re: Force portage to download kernel source |
|
|
Thank you, I try to use this option. |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2402
|
Posted: Sun Aug 04, 2024 4:15 pm Post subject: Re: Force portage to download kernel source |
|
|
RomikB wrote: | logrusx wrote: | What I see is two poor design choices. For me this is alarming. |
As I know all linux network are inside the kernel. Is it poor design? |
That's false. Look at openvpn.
RomikB wrote: | logrusx wrote: | You can do whatever you like of course, but I would not bother with it. Especially writing an ebuild for it. |
Unfortunately I need to use it. And if I make an ebuild upgrading kernel will be easy. |
That's also false. You can always run make and make install on your module after a kernel update. An ebuild won't make it easier, rather slower. Just be careful that you either supply the correct kernel dir or adjust it by eselect kernel.
p.s. you can download your own sources as part of the ebuild. It's overkill but it'll work. This way it'll be actually easier when you upgrade your kernel.
Best Regards,
Georgi |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3687 Location: Rasi, Finland
|
Posted: Sun Aug 04, 2024 6:14 pm Post subject: Re: Force portage to download kernel source |
|
|
RomikB wrote: | It is a fork of the wireguard kernel module. It use the sources of wireguard, patch them and add new. I not the author, just try to make a gentoo ebuild. It compiles and work on many distribs that use prebuild kernel. I want to do the same here on gentoo. | Patch would be the "correct" route. But that cannot work with *-bin kernels.
To make it work, you could- only download the code for wireguard module
- apply your patch
- compile
... inside an ebuild. But you'd need to have checks there to make sure the kernel in host system is compatible... That may be hard task.
Or just outright make your ebuild block *-bin kernels. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2402
|
Posted: Sun Aug 04, 2024 7:17 pm Post subject: Re: Force portage to download kernel source |
|
|
Zucca wrote: |
Or just outright make your ebuild block *-bin kernels. |
-kernel as well. Unless gentoo-kernel installs sources, which I think is not the case.
I still see it as too much and too hard work to be worth it. Still there should be a check if the sources match the running kernel and so on. Only if they wrote it the right way it would have been so much less trouble.
Another option is patches for gentoo-kernel to include it in the kernel. On their site that's a viable option. It should work with default gentoo -kernel configuration, if it works with gentoo-kernel-bin.
Best Regards,
Georgi |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3687 Location: Rasi, Finland
|
Posted: Sun Aug 04, 2024 7:28 pm Post subject: Re: Force portage to download kernel source |
|
|
logrusx wrote: | Unless gentoo-kernel installs sources, which I think is not the case. | Nope. At least gentoo-kernel does contain sources. Code: | zucca@NBLK-WAX9X ~ $ qlist -Iv gentoo-kernel
sys-kernel/gentoo-kernel-6.1.69
zucca@NBLK-WAX9X ~ $ qlist =sys-kernel/gentoo-kernel-6.1.69 | grep '^/usr/src/linux-' | wc -l
17936 | (Yeah. I should update already.)
That said... maybe *-bin kernels should have USE=include-sources or something similar.
logrusx wrote: | Only if they wrote it the right way it would have been so much less trouble. | Yes. A proper fork of the module would be easiest maybe. I can't state much more as I haven't had a need to write a kernel module, let alone know enough to do so. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9608 Location: beyond the rim
|
Posted: Sun Aug 04, 2024 11:15 pm Post subject: |
|
|
The proper solution for your use-case is not to depend on kernel sources and do some copy+patch routine, but provide the patched wireguard sourcetree with your ebuild (like the wireguard-modules ebuild does for older kernels).
Keep in mind that gentoo-kernel-bin is just an option for users, many users will use a different kernel so installing the sources for gentoo-kernel-bin wouldn't fly anyway. Not to mention that you'd have to figure out which version to use as well.
That said, it seems strange to me that gentoo-kernel-bin (and vanilla-sources-bin) is actually a provider for virtual/linux-sources. But I guess there is a reason for that. |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3420
|
Posted: Sun Aug 04, 2024 11:40 pm Post subject: |
|
|
I wonder, what does this patch even do?
Like in: how is it better than wireguard already included in mainline kernel?
Since you're writing an ebuild, I suppose you want to share it. For local-only tweaks, you could just drop a diff into /etc/portage/patches/<category>/<package>/ and have emerge apply your changes automatically to every new version your install. Very convenient, though not very portable. _________________ Make Computing Fun Again |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2402
|
Posted: Mon Aug 05, 2024 4:38 am Post subject: Re: Force portage to download kernel source |
|
|
Zucca wrote: | logrusx wrote: | Unless gentoo-kernel installs sources, which I think is not the case. | Nope. At least gentoo-kernel does contain sources. |
Back when I used gentoo kernel it seemed it didn't provide sources, just replicate what gentoo-kernel-bin is locally. I don't have the time to test now.
Best Regards,
Georgi |
|
Back to top |
|
|
RomikB n00b
Joined: 03 Aug 2024 Posts: 23
|
Posted: Mon Aug 05, 2024 8:19 am Post subject: |
|
|
szatox wrote: | I wonder, what does this patch even do?
Like in: how is it better than wireguard already included in mainline kernel? |
Wireguard protocol is easy to detect by Deep Packet Inspection (DPI) systems. In my country wireguard protocol is detected and blocked.
The patch add some advanced obfuscation methods to make "Undetectable by DPI analysis systems, resistant to blocking".
Zucca wrote: | That said... maybe *-bin kernels should have USE=include-sources or something similar. |
I want to offer something like this also.
Genone wrote: | That said, it seems strange to me that gentoo-kernel-bin (and vanilla-sources-bin) is actually a provider for virtual/linux-sources. But I guess there is a reason for that. |
It is my main guestion.
Genone wrote: | The proper solution for your use-case is not to depend on kernel sources and do some copy+patch routine, but provide the patched wireguard sourcetree with your ebuild (like the wireguard-modules ebuild does for older kernels). | I ask the wireguard fork devs about using kernel source. They say that wireguard module source is different in different kernels on different distros. Thats why they use current system kernel source to build compatible to system kernel module. |
|
Back to top |
|
|
|