Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Force portage to download kernel source
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5050
Location: Bavaria

PostPosted: Mon Aug 05, 2024 11:43 am    Post subject: Reply with quote

RomikB wrote:
[...] 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.

I know that most kernels of other distributions are heavily patched; not so our kernel (which has only minimal extensions). AFAIK the part for wireguard is identical to the official Linux kernel.

Is there also a patch against the official Linux source code? If so, then I would recommend our package "gentoo-sources" (just make your own kernel configuration *) and apply this patch to these sources.


*) I Dont know your experience with doing a manual kernel configuration; maybe you are interested in:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Manual_kernel_configuration
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Manual_Configuring_Kernel_Version_6.6
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9605
Location: beyond the rim

PostPosted: Mon Aug 05, 2024 4:11 pm    Post subject: Reply with quote

RomikB wrote:
Thats why they use current system kernel source to build compatible to system kernel module.


Yeah, but unlike most other distros on Gentoo you don't have a standard kernel everyone uses, so that approach doesn't work quite the same. If you really need to work with the installed kernel sources vs. packaging it yourself, just check if they exist in src_prepare, fail if they don't and let the user sort it out. Don't try to pull them yourself as chances are high that you'll pull the wrong version or patchset.
Back to top
View user's profile Send private message
RomikB
n00b
n00b


Joined: 03 Aug 2024
Posts: 23

PostPosted: Mon Aug 05, 2024 5:14 pm    Post subject: Reply with quote

Genone wrote:
Yeah, but unlike most other distros on Gentoo you don't have a standard kernel everyone uses, so that approach doesn't work quite the same. If you really need to work with the installed kernel sources vs. packaging it yourself, just check if they exist in src_prepare, fail if they don't and let the user sort it out. Don't try to pull them yourself as chances are high that you'll pull the wrong version or patchset.
Thats why me idea was to get current emerged kernel sources or emerge them.
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9605
Location: beyond the rim

PostPosted: Mon Aug 05, 2024 5:44 pm    Post subject: Reply with quote

RomikB wrote:
Thats why me idea was to get current emerged kernel sources or emerge them.

Wrong approach. When the user build their own kernels the sources are usually already installed. When they use a -bin kernel chances are high that they don't want to install a full kernel sourcetree on their system. And there simply is no such function as "get package containing sources for currently running kernel" (you can have a lot more than one kernel installed).

So just check if /usr/src/linux contains a valid and compatible source tree (pretty sure linux_mod eclass can help with that) and notify the user if there is a problem. Not everything needs to be fully automated.
Back to top
View user's profile Send private message
RomikB
n00b
n00b


Joined: 03 Aug 2024
Posts: 23

PostPosted: Mon Aug 05, 2024 8:38 pm    Post subject: Reply with quote

Zucca wrote:
Nope. At least gentoo-kernel does contain sources.
I change my kernel from gentoo-kernel-bin to gentoo-kernel and get the same result. gentoo-kernel also not provide sources for virtual/linux-sources. Both packages download base kernel sources, patch them, use them for compilation, but user is have no option to leave the sources on disk.

pietinger wrote:
Yes, you can just download sys-kernel/gentoo-kernel (emerge -f) and then unpack it:
https://devmanual.gentoo.org/ebuild-writing/functions/index.html
The result will be unpatched base kernel sources and patches separately. Not the best option :-(

Genone wrote:
Wrong approach. When the user build their own kernels the sources are usually already installed. When they use a -bin kernel chances are high that they don't want to install a full kernel sourcetree on their system. And there simply is no such function as "get package containing sources for currently running kernel" (you can have a lot more than one kernel installed).

So just check if /usr/src/linux contains a valid and compatible source tree (pretty sure linux_mod eclass can help with that) and notify the user if there is a problem. Not everything needs to be fully automated.

You are right, Gentoo is often used with a complex setups. I try to cover only a way when a single kernel, for example gentoo-kernel-bin or gentoo-kernel is used. One kernel and a valid sources at /usr/src/linux.

Now I'm stuck trying to get the kernel sources for gentoo-kernel-bin and gentoo-kernel. The only way I found is fetch unpatched sources and manually patch them.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3683
Location: Rasi, Finland

PostPosted: Mon Aug 05, 2024 9:02 pm    Post subject: Reply with quote

RomikB wrote:
Both packages download base kernel sources, patch them, use them for compilation, but user is have no option to leave the sources on disk.
Well that's strange...
Code:
zucca@NBLK-WAX9X ~ $ find /usr/src/linux/ -type f -name Makefile | fgrep wireguard
/usr/src/linux/drivers/net/wireguard/Makefile
/usr/src/linux/tools/testing/selftests/wireguard/qemu/Makefile
zucca@NBLK-WAX9X ~ $ equery b /usr/src/linux/drivers/net/wireguard/Makefile
 * Searching for /usr/src/linux/drivers/net/wireguard/Makefile ...
sys-kernel/gentoo-kernel-6.1.100 (/usr/src/linux-6.1.100-NBLK-WAX9X/drivers/net/wireguard/Makefile)
... and no USE -flag seem to affect that:
Code:
zucca@NBLK-WAX9X ~ $ equery u gentoo-kernel
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for sys-kernel/gentoo-kernel-6.1.100:
 U I
 - - debug       : Enable extra debug codepaths, like asserts and extra output. If you
                   want to get meaningful backtraces see
                   https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
 - - hardened    : Use selection of hardening options recommended by Kernel Self
                   Protection Project
 - - savedconfig : Use this to restore your config from /etc/portage/savedconfig
                   ${CATEGORY}/${PN}. Make sure your USE flags allow for appropriate
                   dependencies
 + + strip       : Allow symbol stripping to be performed by the ebuild for special
                   files
 - - test        : Enable dependencies and/or preparations necessary to run tests
                   (usually controlled by FEATURES=test but can be toggled
                   independently)

I have the sources, you don't. But why?

What's the contents of your /usr/src/?
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
RomikB
n00b
n00b


Joined: 03 Aug 2024
Posts: 23

PostPosted: Mon Aug 05, 2024 10:22 pm    Post subject: Reply with quote

Zucca wrote:
I have the sources, you don't. But why?
What's the contents of your /usr/src/?

I have headers, Kconfigs and Makefiles in /usr/src/. No *.c files.
Back to top
View user's profile Send private message
logrusx
Advocate
Advocate


Joined: 22 Feb 2018
Posts: 2380

PostPosted: Tue Aug 06, 2024 4:55 am    Post subject: Reply with quote

Zucca wrote:

I have the sources, you don't. But why?


Are you sure you can actually build a kernel from those sources or you're relying only on your command? My memory is gentoo-kernel didn't provide sources and I had to reemerge it if I wanted to rebuild a kernel.

Best Regards,
Georgi
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3683
Location: Rasi, Finland

PostPosted: Tue Aug 06, 2024 6:15 am    Post subject: Reply with quote

RomikB wrote:
I have headers, Kconfigs and Makefiles in /usr/src/. No *.c files.
logrusx wrote:
Are you sure you can actually build a kernel from those sources or you're relying only on your command?

Indeed, I was wrong. I only have few .c files.
Code:
zucca@NBLK-WAX9X ~ $ find /usr/src/linux/ -type f -name '*.c' | wc -l
68
This is interesting. As I have modified my kernel config by make nconfig then edit the parts I needed, then save the config, and finally run ./scripts/diffconfig -m to create a config snippet which I place under /etc/kernel/config.d/. Then I would re-emerge the kernel.

But now I get this
Code:
NBLK-WAX9X /usr/src/linux # make nconfig
Makefile:2143: !!!! WARNING !!!!
Makefile:2144: This kernel was configured and installed by the package manager.
Makefile:2145: "make" should not be run manually here.
Makefile:2146: See also: https://wiki.gentoo.org/wiki/Project:Distribution_Kernel
Makefile:2147: See also: https://wiki.gentoo.org/wiki/Kernel/Configuration
Makefile:2148: !!!! WARNING !!!!
... however I can still create kernel config this way.
So I'm not sure if the kernel sources were left in to the system before or if this warning has been added lately and there were no sources ever present.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum