I am trying to modify the kernel that is based on rocky. By following these steps:
After downloading the src rpm once and installing it.
I unpacked the kernel sources tar ball.
Modified the kernel.
Repacked the sources into a tar ball.
Rebuilt the sources rpm “rpmbuild -bs ~/rpmbuild/SPECS/kernel.spec”
Built the kernel using mock: mock -r ~/rpmbuild/SRPMS/kernel-5.14.0-162.23.1.el9.src.rpm"
And I would like to tell my kernel apart from Rocky’s standard kernels. So, I would like to change the standard version name: 5.14.0-162.6.1.el9_1.0.1.x86_64
to anything else. Say 5.14.0-162.6.1.idk9_1.0.1.x86_64.
But I am having hard time identifying where the variable “release” in kernel.spec is assigned value. Because that variable is important for the build process when creating the modules folder where they will be signed.
el9 or any variation of that is determined by the dist macro. I would highly recommend using rpm --showrc or checking /usr/lib/rpm/macros.d/macros.dist to see what’s available to you.
Read the spec files of any rpm and you’ll find %{?dist} in Release. In my opinion, you should not be messing with this value. And if you are, keep el9 and add something else to it. Or, changing/appending some other value at the end of Release.
Compiling custom kernels are not recommended. Please see this page for more information.
Rocky Linux 9.1, and its packages/sources are no longer supported. Please see the version guide.
It is, actually. Look for pkg_release, as that is the macro referenced in that field. You can create macros at the top of a spec file and then use them later, which is what this spec file does. We also do this in rocky-release.
$ grep -E '^Release:|pkg_release|specrelease' kernel.spec
# This allows pkg_release to have configurable %%{?dist} tag
%define specrelease 427.16.1%{?buildid}%{?dist}
%define pkg_release %{specrelease}
Release: %{pkg_release}
Provides: kernel = %{specversion}-%{pkg_release}\
Provides: kernel-%{_target_cpu} = %{specversion}-%{pkg_release}%{uname_suffix %{?1:%{1}}}\
The %dist macro we employ uses macro logic to determine what the dist is going to eventually be, depending on the situation. Someone can set distprefix or distsuffix, which can alter how it ends up appearing. If you look in the middle, you’ll see .el9, which is the only static/constant part of that variable’s value.
Here are some examples of what that logic does.
[label@xmpp01 ~]$ rpm --eval '%dist'
.el9
[label@xmpp01 ~]$ rpm --define 'distprefix .0' --eval '%dist'
.0.el9
# This is the lua for loop. many distprefix* can be set.
[label@xmpp01 ~]$ rpm --define 'distprefix0 .test' --define 'distprefix1 .test2' --eval '%dist'
.test.test2.el9
[label@xmpp01 ~]$ rpm --define 'distsuffix .0.1' --eval '%dist'
.el9.0.1
[label@xmpp01 ~]$ rpm --define 'with_bootstrap 1' --eval '%dist'
.el9~bootstrap