Making a kernel patch: advice needed

Hi, I need some advice on building and installing a kernel from source with a custom patch. To be specific, my goal is to build an Alma kernel after reverting a commit from a mainline Linux Git repo and resolving potential conflicts (featuring both subsequent mainline commits and RHEL/Alma patches). What is the most straight-forward way to do that?

My problem is that almalinux/kernel - kernel - AlmaLinux OS Foundation Git Server is a dist-git repo with no preserved commit history from a Linux git, a kernel.spec from source RPM expects kernel sources from a tarball, and a mainline Linux repo uses a different set of scripts to build an RPM package. I’m a bit confused, where should I start?

Hello and welcome to the forum :waving_hand:

If you want an older version of the AlmaLinux kernel, you can check this URL which contains the SRPMs of each released kernel

Change the number “10” for 9 or 8 to access those versions.

Hello, thanks for your reply.

I’m new to kernel development in RPM-based distros, so I was hoping to hear what should your routine look like if you need to revert or bisect some change in the kernel code, given the structure of the repos.

Like in my case, the change happened somewhere between OS versions 8 and 9, so there’s no readily available SRPM

So you look a change that occurred between
oldest 8 SRPM: https://vault.almalinux.org/8.3/BaseOS/Source/Packages/kernel-4.18.0-240.15.1.el8_3.src.rpm (that AlmaLinux had)
and
oldest 9 SRPM: https://vault.almalinux.org/9.0/BaseOS/Source/Packages/kernel-5.14.0-70.13.1.el9_0.src.rpm

Each does naturally differ from upstream 4.18 and 5.14 …

hello

One thing to keep in mind is that RHEL-family kernels contain a large number of backports, so they can differ significantly from the corresponding vanilla upstream kernels.
Therefore, comparing or bisecting only upstream 4.18 to 5.14 may not necessarily identify the change that caused the behavioral difference between RHEL/AlmaLinux 8 and 9.

That’s the reason why I created this topic. I believe there should be a convenient way to deal with a kernel git source tree with all the backports applied.

The closest thing I found so far is this link in sources: kernel/README.rst at a9 - kernel - AlmaLinux OS Foundation Git Server which points to this Fedora/ARK docs: Fedora/ARK Kernel — Fedora/ARK Kernel documentation

Is there any instruction on how to adapt it to Alma? Or should I just pick an original RHEL 9 kernel instead?