Where is the "release" variable is given a value?

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.

  1. I unpacked the kernel sources tar ball.
  2. Modified the kernel.
  3. Repacked the sources into a tar ball.
  4. Rebuilt the sources rpm “rpmbuild -bs ~/rpmbuild/SPECS/kernel.spec”
  5. 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.

I feel stupid.

I searched for “Release” in the kernel.spec and I found this:

$ grep "Release" ~/rpmbuild/SPECS/kernel.spec 
Release: %{pkg_release}
* Tue Apr 11 2023 Release Engineering <releng@rockylinux.org> - 5.14.0-162.23.1
- ALSA: oss: Release temporary buffers upon errors (Jaroslav Kysela) [2065572]
- brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path (Íñigo Huguet) [2059999]
- VMCI: Release notification_bitmap in error path (Cathy Avery) [2079153]
- scsi: iscsi: Release endpoint ID when its freed (Chris Leech) [2071524]
- IB/cm: Release previously acquired reference counter in the cm_id_priv (Kamal Heib) [2056771]
- KVM: arm64: Release mmap_lock when using VM_SHARED with MTE (Andrew Jones) [2009341]
- RDMA/iwcm: Release resources if iw_cm module initialization fails (Kamal Heib) [2036599]
- Only include open merge requests with "Include in Releases" label (Jeremy Cline)

So, Release is not related to “dist” in the spec file.

And when I search in the system for dist in all macros.dist files in the system, I get:

# find . -name "macros.dist" -exec grep  "dist" {} \;
# dist macros.
%dist %{!?distprefix0:%{?distprefix}}%{expand:%{lua:for i=0,9999 do print("%{?distprefix" .. i .."}") end}}.el9%{?distsuffix}%{?with_bootstrap:~bootstrap}
%dist_vendor         RESF
%dist_name           %{distro}
%dist_home_url       https://rockylinux.org/
%dist_bug_report_url https://bugs.rockylinux.org/
%dist_debuginfod_url https://debuginfod.rockylinux.org/
# dist macros.
%dist %{!?distprefix0:%{?distprefix}}%{expand:%{lua:for i=0,9999 do print("%{?distprefix" .. i .."}") end}}.el9%{?distsuffix}%{?with_bootstrap:~bootstrap}
%dist_vendor         RESF
%dist_name           %{distro}
%dist_home_url       https://rockylinux.org/
%dist_bug_report_url https://bugs.rockylinux.org/
%dist_debuginfod_url https://debuginfod.rockylinux.org/
# dist macros.
%dist %{!?distprefix0:%{?distprefix}}%{expand:%{lua:for i=0,9999 do print("%{?distprefix" .. i .."}") end}}.el9%{?distsuffix}%{?with_bootstrap:~bootstrap}
%dist_vendor         RESF
%dist_name           Rocky Linux
%dist_home_url       https://rockylinux.org/
%dist_bug_report_url https://bugs.rockylinux.org/
%dist_debuginfod_url https://debuginfod.rockylinux.org/

I am an idiot software engineer, when I see i = x + 1 , I know “i”'s value is dependent on “x”.

but, can I figure out from that same sentence that is dependent on “y”?

What I am trying to say, please bring it down to my level of stupidity. Please.

And I do appreciate your help btw, when you do not have to. Much love :slight_smile:

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

Thank you! I am starting to get it.

but the last thing I would like to bother you with is:

How can I add a suffix just like the above with mock?

Meaning, I would like to see how mock plays with rpm/rpmbuild.

On the mock command, you can just add --define "distsuffix .0.1". Mock will accept --define just like the rpm commands do.

1 Like

Thank you!

I really appreciate your help!

Tell us a bit about the modification, to understand your needs …