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

Bug 785754

Summary: Allow use of -dist kernels as boot/kernel/gentoo/sources .spec entries
Product: Gentoo Hosted Projects Reporter: Kenneth G. Strawn <kenny.strawn>
Component: CatalystAssignee: Gentoo Catalyst Developers <catalyst>
Status: RESOLVED FIXED    
Severity: normal CC: azamat.hackimov, dist-kernel, kenny.strawn
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Patch to kmerge.sh to detect whether a kernel has already been built before proceeding
Allow use of -dist kernels in .spec files

Description Kenneth G. Strawn 2021-04-26 01:33:22 UTC
Created attachment 702537 [details, diff]
Patch to kmerge.sh to detect whether a kernel has already been built before proceeding

Although the Gentoo kernel team has managed to release distribution kernel packages that compile on the fly instead of relying on genkernel, the Catalyst team is lagging behind in this by still depending on genkernel instead of letting the user choose a -dist kernel at build time. So, time to patch the Catalyst support scripts to allow the use of -dist kernels as live kernels.
Comment 1 Matt Turner gentoo-dev 2021-04-26 05:56:58 UTC
Please don't mess with the importance fields. Most developers consider it a bit pompous.

> the Catalyst team is lagging behind in this by still depending on genkernel

Provocative, and unlikely to do anything positive to my interest in investigating the report further.
Comment 2 Kenneth G. Strawn 2021-07-31 20:11:49 UTC
Created attachment 728907 [details, diff]
Allow use of -dist kernels in .spec files

Better solution: detect whether $clst_boot_kernel_${kname}_sources points to a sys-kernel/gentoo-kernel or sys-kernel/vanilla-kernel derived package, then refuse to run genkernel_compile if that turns out to be the case.
Comment 3 Kenneth G. Strawn 2021-08-26 19:07:58 UTC
Since it doesn't appear that anyone saw it based on it not yet being merged, I'm copying and pasting the attached patch into the comments:

From 3cc96ad99e400b963e7a0104fd1db26e23a6d5b9 Mon Sep 17 00:00:00 2001
From: Kenny Strawn <Kenny.Strawn@gmail.com>
Date: Sat, 31 Jul 2021 13:06:31 -0700
Subject: [PATCH] Allow use of -dist kernels in .spec files

---
 targets/support/kmerge.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh
index 20b471f1..3d28bd8a 100755
--- a/targets/support/kmerge.sh
+++ b/targets/support/kmerge.sh
@@ -129,7 +129,11 @@ if [[ -n ${clst_kextraversion} ]]; then
 		/usr/src/linux/Makefile
 fi
 
-genkernel_compile
+if [[ "$clst_boot_kernel_${kname}_sources" == *"gentoo-kernel"* || "$clst_boot_kernel_${kname}_sources" == *"vanilla-kernel"* ]]; then
+  echo "Spec file points to -dist kernel package instead of sources; skipping kernel build"
+else
+  genkernel_compile
+fi
 
 # Write out CONFIG, USE, VERSION, and EXTRAVERSION files
 if [[ -n ${clst_KERNCACHE} && ! ${cached_kernel_found} ]]; then
-- 
2.32.0
Comment 4 Mike Gilbert gentoo-dev 2021-08-26 19:17:40 UTC
I don't think hard-coding package names is a very good solution. There should probably be a separate config option to toggle it.
Comment 5 Mike Gilbert gentoo-dev 2021-08-26 19:20:19 UTC
Also, please do not add people to the CC list. I am not a catalyst developer and really don't care about this bug.

It seems like you are trying to get someone to pay attention to you by being annoying.
Comment 6 Kenneth G. Strawn 2021-08-26 21:26:44 UTC
(In reply to Mike Gilbert from comment #4)
> I don't think hard-coding package names is a very good solution. There
> should probably be a separate config option to toggle it.

The package names aren't hard-coded. Cue the substring wildcards in the check:

> if [[ "$clst_boot_kernel_${kname}_sources" == *"gentoo-kernel"* || "$clst_boot_kernel_${kname}_sources" == *"vanilla-kernel"* ]]; then

A, the "clst_boot_kernel_${kname}_sources" variable is what the "boot/kernel/gentoo/sources" livecd-stage2.spec entry defines, and B, there are asterisks on either side of the names in question ― wrapping a substring in asterisks is the Bash way of saying "if ANY package name defined in boot/kernel/gentoo/sources contains this substring, do this.

So what my patch is designed to do is check if the package name specified in the boot/kernel/gentoo/sources entry contains either of the two substrings "gentoo-kernel" or "vanilla-kernel" and skip the invocation of genkernel_compile if they do. As it currently stands, kmerge.sh lazily fails to run this check.
Comment 7 Mike Gilbert gentoo-dev 2021-08-27 01:24:11 UTC
(In reply to Kenneth G. Strawn from comment #6)

You have hard-coded the names "gentoo-kernel" and "vanilla-kernel". What happens when someone adds another kernel package called "fubar-kernel"?
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-28 01:02:42 UTC
commit 7247751e4c5ad19786c40a7ed1c87ad0b836026e
Author: Azamat H. Hackimov <azamat.hackimov@gmail.com>
Date:   Wed Aug 23 03:39:03 2023 +0300

    Compile external modules with dist-kernel

    If boot/kernel/${kernel}/packages is defined, force build external module packages for dist-kernels.

    Also don't unmerge kernel after merging as it may needed for building process, just deselect. Later it will be unmerged by depclean process.

    Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>

commit 3d4fb24383716958dadea95d100911037bb2b557
Author: Azamat H. Hackimov <azamat.hackimov@gmail.com>
Date:   Tue Aug 1 11:18:31 2023 +0300

    Implementing distkernel installation

    Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>