kbuild: rpm-pkg: append %{?dist} macro to Release tag
PATCH 1/1 kbuild: rpm-pkg: append %{?dist} macro to Release tag
Add support for the %{?dist} macro in the kernel.spec file. This enables building and releasing kernel RPMs with a custom distribution suffix (e.g., via rpmbuild's --define option) to better match production environment tracking.
--- scripts/package/kernel.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/kernel.spec +1 -1
@@ -6,7 +6,7 @@ Name: kernel Summary: The Linux Kernel Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') -Release: %{pkg_release} +Release: %{pkg_release}%{?dist} License: GPL Group: System Environment/Kernel Vendor: The Linux Community
Signature · 1 line
2.47.3
Nathan Chancellor
maintainerscripts/package/kernel.spec line 9
Quoted 10 lines · Yafang Shao
scripts/package/kernel.spec +1
-1@@ -6,7 +6,7 @@ Name: kernel Summary: The Linux Kernel Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') -Release: %{pkg_release} +Release: %{pkg_release}%{?dist}
This seems reasonable at face value, especially since Fedora recommends this for all of its packages but the value of dist will be included in the version string with how this is currently written:
$ make -skj"$(nproc)" ARCH=x86_64 RPMOPTS="--define 'dist .distval123'" mrproper defconfig rpm-pkg ...
$ cat include/generated/utsversion.h #define UTS_VERSION "#1.distval123 SMP PREEMPT_DYNAMIC Wed May 27 17:27:34 MST 2026"
Maybe that's fine (or even considered a feature)? Figured it was worth pointing out in case anyone can think of problems from allowing this. Another option could be just changing
KBUILD_BUILD_VERSION=%{release}
to
KBUILD_BUILD_VERSION=%{pkg_release}
to avoid this.
Signature · 2 lines
Cheers, Nathan
Quoted 17 lines · Nathan Chancellor
scripts/package/kernel.spec line 9
Quoted 10 lines · Yafang Shao
scripts/package/kernel.spec +1
-1@@ -6,7 +6,7 @@ Name: kernel Summary: The Linux Kernel Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') -Release: %{pkg_release} +Release: %{pkg_release}%{?dist}This seems reasonable at face value, especially since Fedora recommends this for all of its packages but the value of dist will be included in the version string with how this is currently written:
Quoted 7 lines
$ make -skj"$(nproc)" ARCH=x86_64 RPMOPTS="--define 'dist .distval123'" mrproper defconfig rpm-pkg ...$ cat include/generated/utsversion.h #define UTS_VERSION "#1.distval123 SMP PREEMPT_DYNAMIC Wed May 27 17:27:34 MST 2026"Maybe that's fine (or even considered a feature)?
I believe the current behavior is fine because the 'dist' value is properly displayed in the uname -a output, as shown below:
$ uname -a Linux localhost.localdomain 7.1.0-rc5+ #1.distval123 SMP PREEMPT_DYNAMIC Thu May 28 06:25:23 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
However, if we apply the change below, the 'dist' value will be omitted from the uname -a output:
$ uname -a Linux localhost.localdomain 7.1.0-rc5+ #2 SMP PREEMPT_DYNAMIC Thu May 28 07:43:05 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Quoted 16 lines
Figured it was worth
pointing out in case anyone can think of problems from allowing this. Another option could be just changingKBUILD_BUILD_VERSION=%{release}
to
KBUILD_BUILD_VERSION=%{pkg_release}
to avoid this.
--
Cheers,
Nathan
Signature · 2 lines
Regards Yafang
Nathan Chancellor
maintainerQuoted 1 line · Yafang Shao
kbuild: rpm-pkg: append %{?dist} macro to Release tag
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-next
Thanks!
[1/1] kbuild: rpm-pkg: append %{?dist} macro to Release tag
https://git.kernel.org/kbuild/c/159921d63da16
Please look out for regression or issue reports or other follow up comments, as they may result in the patch/series getting dropped or reverted. Patches applied to an "unstable" branch are accepted pending wider testing in -next and any post-commit review; they will generally be moved to the main branch in a week if no issues are found.
Best regards,
Signature · 2 lines
Cheers, Nathan