@jarkko "Learning to compile distro kernel for Fedora": which way?
Modify the SRPM?
Modify dist-git (https://src.fedoraproject.org/rpms/kernel – upstream for the SRPM)?
Modify kernel-ark (https://gitlab.com/cki-project/kernel-ark – upstream of dist-git)?
@jarkko reg -next:
I'm biased, but using something based on[1] (based on kernel-ark) might be the wises if you want to do that more often in the long run.
I really should write a short "how to use Thorsten's stuff for your own use cases as a kernel developer" entry for the faq…
[1] https://copr.fedorainfracloud.org/coprs/g/kernel-vanilla/next/ ; https://fedoraproject.org/wiki/Kernel_Vanilla_Repositories & https://fedoraproject.org/wiki/Kernel_Vanilla_Repositories-FAQ#Where_is_the_code_from_which_the_packages_are_built?;
then you most likely want kernel-ark: https://cki-project.gitlab.io/kernel-ark/
But it's a bit tricky to get used to it. :-/
And not idea wrt to secure boot signing. :-(
> But it's a bit tricky to get used to it. :-/
I really should write something up to make this easier, as the stuff in the "ark-infra" branch is really handy once you know about it and how to use it.
@jarkko I'm not sure if this is helpful or not, but for several years now I've been building Fedora Rawhide kernel packages with the LSM, SELinux, and audit linux-next patches included. It isn't perfect, but it works reasonably well for me and barring an odd merge conflict it runs completely automated.
https://paul-moore.com/blog/d/2019/04/kernel_secnext_repo.html
@jarkko I've been on Fedora since before Ubuntu existed :-D Contributing to Fedora is actually how I did my first steps in contributing to Open Source.
And yeah, I prefer to not touch Snap due to the Snap Store situation; there are also other problems that make it a bad candidate for corss-distro packaging tool. like the confinement depending on AppArmor for example.
FWIW, I started using copr for my builds (https://fedoraproject.org/wiki/Kernel_Vanilla_Repositories ) a while ago; build times are still a problem, but never saw something like the "the build chroot often breaks when Fedora Rawhide moves to the next release" you describe.
@kernellogger @jarkko That COPR build chroot problem may have gotten better over the years, I can't say for certain as I no longer rely on the COPR builds, I've found my local builds (repo.paul-moore.com) to much more reliable/quicker.
FWIW, I do still send the kernel-secnext builds to COPR, I just don't worry about it too much when the COPR build breaks.
@jarkko @kernellogger The automation is a big part of this, both in doing the build and executing your tests. You want something that can do what it needs to do with minimal manual intervention.
I'm not a good example here as my solution is a monstrous general job scheduler written in Bash back when the only other realistic option was Jenkins. If you're curious there is a slightly outdated version posted here, but be warned it is hacky beyond belief :)
@jarkko But the kernel you build isn't signed by your distro in this case?
> a kernel tree with extra patches adding the packaging shenanigans on top
1/ It should work round about like this with kernel-ark [untested, so I will have gotten something wrong or forget something]::
2/
sudo dnf install git make gcc flex bison bzip2 rpm-build python3-pyyaml
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/
git remote add -t ark-infra kernel-ark
git fetch kernel-ark
git merge kernel-ark/ark-infra
sed -i '/# We are using a recursive / i include Makefile.rhelver\n' Makefile
sudo dnf -y install $(make dist-get-buildreqs | grep "Missing dependencies:" | cut -d":" -f2-)
make dist-srpm
mock redhat/rpm/SRPMS/kernel-*.src.rpm
@jarkko can't wait for your article with "just" the right bits ;-)
3/ obviously you can add patches to the tree; that mock build will take a while, as it will build non-debug and debug kernels; disabling this requires commands I would have to look up.
not sure if "git merge kernel-ark/ark-infra" really works these days; maybe it's better to use "git archive --format=tar "kernel-ark/ark-infra" makefile Makefile.rhelver redhat/ | tar -
@kernellogger @jarkko @securepaul and also if you go this way, you can just run pesign at the end instead of trying to test if my rpm macro bits from 2012 that nobody really uses have survived the 12 years of buildsystem-hack wack-a-mole they sit in the middle of.
@kernellogger @jarkko @securepaul
to be clear the rpm macros and related shell scripts are used all the time, but I don't think anyone actually regularly tries just setting pe_signing_cert. It's supposed to work, but... all the code around it is heuristics to figure out where RPMs are getting built, if something is a scratch build, if some other signing mechanism is present, etc., and that's all churned quite a lot in the intervening decade.
@jarkko @kernellogger @securepaul I mean, I don't think it's wrong, I just think the userbase that actually tries to use it that way is vanishingly small.
@jarkko @kernellogger @securepaul rpm signing is different, pesign is just for signing kernel/bootloader/etc. Why are you bothering with RPMs to do kernel development, though?
@vathpela @jarkko @kernellogger FWIW, I build and provide RPMs because there are people who would like to help test things but are not necessarily comfortable with building a kernel. It also makes test automation easy; add a repo to your test system and then you just `dnf update`, test, and repeat.
@jarkko @kernellogger @securepaul okay "I want to include package install as part of my testing" would have sufficed ;) Do you really need your /own/ cert/signature for testing? Because I think if you just use the kernel-ark ./redhat/fedora-srpm.sh
workflow and build the srpm in a mock root, you should get a signature from the "Red Hat Test Certificate", which you can enroll in VMs and whatnot and have that just work.
@jarkko @kernellogger @securepaul ... and kernel-ark gets you a tree you can just cherry pick upstream packages into (with fixups when versions mismatch, obviously, but mostly you get jforbes and others doing rebases for you, which is nice.)
@jarkko @kernellogger @securepaul okay. If it helps, this is basically the workflow I've been using for making sure the aarch64 parts of pre-boot NX work using the Windows Dev Kit 2023 (a snapdragon desktoppy kind of device), which I've pushed here (not my kernel work, someone else's on a fedora kernel tree) https://gitlab.com/vathpela/kernel-ark/-/tree/blackrock-v6.8.y?ref_type=heads , which is on top of the fedora-6.8 tree (also here: https://gitlab.com/vathpela/kernel-ark/-/tree/fedora-6.8?ref_type=heads ). But I'm doing all that with Secure Boot disabled for expedience.
@jarkko @kernellogger @securepaul (yes, you heard it here first, Secure Boot guy does non-Secure Boot bootloader and kernel work with Secure Boot disabled ;)
1/ I took a closer look and that's how I'd do it:
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
cd linux
git remote add --no-tags -t ark-vanilla-mainline ark-vanilla https://gitlab.com/knurd42/linux/
git fetch ark-vanilla-mainline
git archive --format=tar ark-vanilla/ark-vanilla-mainline makefile Makefile.rhelver redhat/ .copr | tar -x
sed -i '/# We are using a recursive / i include Makefile.rhelver\n' Makefile
sed -i 's!define with_realtime 1!define with_realtime 0!' redhat/kernel.spec.template
…
2/…
sed -i 's!^\(UPSTREAM_BRANCH \?.\?=\)\(.*\)!\1 origin!' redhat/kernel.spec.template
git add Makefile makefile Makefile.rhelver redhat/
git add -f .copr redhat/kabi/kabi-module/kabi*
git commit -q -s -m "import ark-infra"
make -j $(nproc --all) dist-srpm
mock redhat/rpm/SRPMS/kernel-*.src.rpm
Yes, this uses a repo I maintain; this nicely avoid a few obstacles that using kernel-ark directly had, but you you use kernel-ark/os-build as well.
3/ Updating…
3/…that stuff in redhat/ over time and a few other aspects are not covered here, but that is relatively easy.
I maybe should create a script and write a blog post about it.
+1 - but not feeling partly motivated right now to go down that path currently; but who knows what the future might bring.
Side note: sadly the kernel missed hooks to easily and cleanly plug-in a distro-specific packaging infra as that from kernel-ark; its maintainers had the idea to upstream something, but haven't heard anything about it for a while…
Compiling kernel is my thing as well (I guess), but I do it for different reasons: so that others don't have to and thus are hopefully more willing to participate in testing upstream…
https://copr.fedorainfracloud.org/groups/g/kernel-vanilla/coprs/
nice name 😂 😂 😂
Anyway, okay, you convinced me, I will generalize the stuff I use to maintain the SRPM generation for https://fedoraproject.org/wiki/Kernel_Vanilla_Repositories, as the script that I used for that (https://gitlab.com/knurd42/ark-vanilla-scripts/-/blob/main/vk-gitmon.sh) does a lot of what will be needed already (and a lot of stuff that won't be needed, so I will have to rework a few things).
But it will take a few days.
> But it will take a few days.
curl --silent 'https://gitlab.com/knurd42/linux/-/raw/ark-scripts/arkify.sh' | bash
One to three minutes later you'll have a src.rpm you can build with rpmbuild, mock, copr, or koji. Used the later to give it a try:
https://koji.fedoraproject.org/koji/taskinfo?taskID=125255353
@jarkko yeah, TBH, I never bothered with the secure boot stuff because I can't really use it for my copr builds anyway (the private key would become public).
Adjusting the stuff that is there for signing in redhat/kernel.spec.template should work, but as @vathpela mentioned: maybe nobody used it and that stuff is broken.
@jarkko yw, but it's only a start; next steps: README and a way to update the stuff you import to the branch you want to build, as sooner or later that often will be needed.
rearranged and cleaned a few things up, created a README: https://gitlab.com/knurd42/linux/-/tree/arkify-arkify
The command provided earlier thus now is:
curl --silent 'https://gitlab.com/knurd42/linux/-/raw/arkify-arkify/arkify' | bash
Next step: updating the arkify-infra* branch and then importing the ark infra to target branches that already contain it.