kbuild: deb-pkg: allow to set package name version
PATCH 1/1 kbuild: deb-pkg: allow to set package name version
Instead of hardcoding ${KERNELRELEASE} in the package name allow the user to override this.
This can be useful if one doesn't want to accumulate different packages for every commit or micro version bump by setting KDEB_PKGNAMEVERSION=7.3 or even KDEB_PKGNAMEVERSION=stable.
--- scripts/package/mkdebian | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
scripts/package/mkdebian +9 -3
@@ -172,6 +172,12 @@ else packagename=linux-image fi +if [ "${KDEB_PKGNAMEVERSION:+set}" ]; then + packagenameversion=$KDEB_PKGNAMEVERSION +else + packagenameversion=$KERNELRELEASE +fi + debarch= set_debarch
@@ -215,7 +221,7 @@ Build-Depends-Arch: bc, bison, flex, python3:native, rsync Homepage: https://www.kernel.org/ -Package: $packagename-${KERNELRELEASE} +Package: $packagename-${packagenameversion} Architecture: $debarch Description: Linux kernel, version ${KERNELRELEASE} This package contains the Linux kernel, modules and corresponding other
@@ -238,7 +244,7 @@ EOF if is_enabled CONFIG_MODULES; then cat <<EOF >> debian/control -Package: linux-headers-${KERNELRELEASE} +Package: linux-headers-${packagenameversion} Architecture: $debarch Build-Profiles: <!pkg.${sourcename}.nokernelheaders> Description: Linux kernel headers for ${KERNELRELEASE} on $debarch
@@ -252,7 +258,7 @@ fi if is_enabled CONFIG_DEBUG_INFO; then cat <<EOF >> debian/control -Package: linux-image-${KERNELRELEASE}-dbg +Package: linux-image-${packagenameversion}-dbg Section: debug Architecture: $debarch Build-Profiles: <!pkg.${sourcename}.nokerneldbg>
---
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
change-id: 20261019-deb-pkg-a6ef2837687e
Best regards,
Signature · 1 line
Guido Günther <[email protected]>
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] kbuild: deb-pkg: broken build symlink in install_kernel_headers() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] kbuild: deb-pkg: broken build symlink in install_kernel_headers() --
commit bc8efaaf9e21748a005be3c75bb9c6c2334ac049
Author: Guido Günther <[email protected]>
kbuild: deb-pkg: allow to set package name version
This commit introduces KDEB_PKGNAMEVERSION in scripts/package/mkdebian to allow overriding the version suffix used in the generated Debian binary package names instead of always using KERNELRELEASE.
Quoted 27 lines
scripts/package/mkdebian +7
-1@@ -172,6 +172,12 @@ else packagename=linux-image fi +if [ "${KDEB_PKGNAMEVERSION:+set}" ]; then + packagenameversion=$KDEB_PKGNAMEVERSION +else + packagenameversion=$KERNELRELEASE +fi + debarch= set_debarch@@ -215,7 +221,7 @@ Build-Depends-Arch: bc, bison, flex, python3:native, rsync Homepage: https://www.kernel.org/ -Package: $packagename-${KERNELRELEASE} +Package: $packagename-${packagenameversion} Architecture: $debarch Description: Linux kernel, version ${KERNELRELEASE} This package contains the Linux kernel, modules and corresponding other
scripts/package/mkdebian EOF · line 247
Quoted 5 lines
scripts/package/mkdebian +1
-1@@ -238,7 +244,7 @@ EOF if is_enabled CONFIG_MODULES; then cat <<EOF >> debian/control -Package: linux-headers-${KERNELRELEASE} +Package: linux-headers-${packagenameversion}
[Severity: Medium]
When KDEB_PKGNAMEVERSION is set to a value different from KERNELRELEASE (such as 7.3 or stable) with CONFIG_MODULES enabled, does this break the /lib/modules/${KERNELRELEASE}/build symlink in the linux-headers package?
In scripts/package/builddeb, install_linux_image() installs modules under /lib/modules/${KERNELRELEASE} and removes the build symlink so the headers package can provide it:
scripts/package/builddeb:install_linux_image() {
...
${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" INSTALL_MOD_STRIP=1 modules_install
rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build"
...
}However, install_kernel_headers() in scripts/package/builddeb derives $version by stripping "linux-headers-" from the package name ($1) rather than using ${KERNELRELEASE}:
scripts/package/builddeb:install_kernel_headers() {
pdir=debian/$1
version=${1#linux-headers-}
...
mkdir -p $pdir/lib/modules/$version/
ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
}Because $1 is now linux-headers-${KDEB_PKGNAMEVERSION}, won't install_kernel_headers() create the symlink at /lib/modules/${KDEB_PKGNAMEVERSION}/build instead of /lib/modules/${KERNELRELEASE}/build, leaving /lib/modules/$(uname -r)/build missing for out-of-tree module builds and DKMS?
[ ... ]
Quoted 14 lines
[]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hi,
Quoted 4 lines · On Tue, Oct 20, 2026 at 07:16:51PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] kbuild: deb-pkg: broken build symlink ininstall_kernel_headers()--
Quoted 8 lines
commit
bc8efaaf9e21748a005be3c75bb9c6c2334ac049
Author: Guido Günther <[email protected]>kbuild: deb-pkg: allow to set package name version
This commit introduces
KDEB_PKGNAMEVERSIONinscripts/package/mkdebianto allow overriding the version suffix used in the generated Debian binary package names instead of always using KERNELRELEASE.
That's true, the script should use ${KERNELRELEASE} when referring to the kernel version and $version elsewhere. Other parts of the script have that correct so it's just a:
scripts/package/builddeb +2 -2
@@ -147,8 +147,8 @@ install_kernel_headers () { "${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}" fi - mkdir -p $pdir/lib/modules/$version/ - ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build + mkdir -p $pdir/lib/modules/${KERNELRELEASE}/ + ln -s /usr/src/linux-headers-$version $pdir/lib/modules/${KERNELRELEASE}/build } install_libc_headers () {
I'll fold that into a v2 after waiting a bit more for other feedback.
Cheers,
-- Guido
Nicolas Schier
maintainerQuoted 6 lines · Guido Günther
Instead of hardcoding ${KERNELRELEASE} in the package name allow the user to override this.
This can be useful if one doesn't want to accumulate different packages for every commit or micro version bump by setting KDEB_PKGNAMEVERSION=7.3 or even KDEB_PKGNAMEVERSION=stable.
I am not yet convinced, that this is a good idea. Do you want to elaborate a bit more, why you think this is necessary? Have you tested your patch? I don't like that source package name and binary package name divert w/o good reasoning.
Kind regards
Nicolas
Quoted 4 lines · Nicolas Schier
Quoted 3 lines · Guido Günther
Instead of hardcoding ${KERNELRELEASE} in the package name allow the user to override this.
Quoted 8 lines
Quoted 3 lines
This can be useful if one doesn't want to accumulate different packages for every commit or micro version bump by setting KDEB_PKGNAMEVERSION=7.3 or even KDEB_PKGNAMEVERSION=stable.
I am not yet convinced, that this is a good idea. Do you want to elaborate a bit more, why you think this is necessary? Have you tested your patch? I don't like that source package name and binary package name divert w/o good reasoning.
FWIW we have something similar for the Arch Linux packaging with PACMAN_PKGBASE. It is the complement to the proposed patch, as Arch Linux by default does *not* allow multiple installed kernel packages of a single type at the same time. PACMAN_PKGBASE allows this. KDEB_PKGNAMEVERSION would enable the Arch Linux behavior for the Debian packages. Personally I would have found this convenient in the past.
Thomas
Hi Nicolas,
Quoted 4 lines · Nicolas Schier
Quoted 3 lines · Guido Günther
Instead of hardcoding ${KERNELRELEASE} in the package name allow the user to override this.
Quoted 8 lines
Quoted 3 lines
This can be useful if one doesn't want to accumulate different packages for every commit or micro version bump by setting KDEB_PKGNAMEVERSION=7.3 or even KDEB_PKGNAMEVERSION=stable.
I am not yet convinced, that this is a good idea. Do you want to elaborate a bit more, why you think this is necessary? Have you tested your patch? I don't like that source package name and binary package name divert w/o good reasoning.
The source and the binary package names can already differ due to the KDEB_SOURCENAME variable (and we're making use of that).
What this patch adds is the ability to control the suffix so we can e.g. build a linux-ng-foo and a linux-stable-bar instead of having a linux-image-7.3.17, linux-image-7.3.18 (or with git versions or …). It's just about having a bit more control over the generated binary package names so we can decide what replaces what on upgrades.
I have tested the patch with and without setting KDEB_PKGNAMEVERSION. Without setting this variable nothing should change for existing users.
Cheers,
-- Guido
Quoted 4 lines
Kind regards
Nicolas
Nicolas Schier
maintainerQuoted 18 lines · Guido Günther
Hi Nicolas,
Quoted 4 lines · Nicolas Schier
Quoted 3 lines · Guido Günther
Instead of hardcoding ${KERNELRELEASE} in the package name allow the user to override this.
Quoted 8 lines
Quoted 3 lines
This can be useful if one doesn't want to accumulate different packages for every commit or micro version bump by setting KDEB_PKGNAMEVERSION=7.3 or even KDEB_PKGNAMEVERSION=stable.
I am not yet convinced, that this is a good idea. Do you want to elaborate a bit more, why you think this is necessary? Have you tested your patch? I don't like that source package name and binary package name divert w/o good reasoning.
The source and the binary package names can already differ due to the
KDEB_SOURCENAMEvariable (and we're making use of that).
Quoted 8 lines
What this patch adds is the ability to control the suffix so we can e.g. build a
linux-ng-fooand alinux-stable-barinstead of having a linux-image-7.3.17, linux-image-7.3.18 (or with git versions or …). It's just about having a bit more control over the generated binary package names so we can decide what replaces what on upgrades.I have tested the patch with and without setting
KDEB_PKGNAMEVERSION. Without setting this variable nothing should change for existing users.
Ack, thanks for clarification. I'll try to review this next week. Thanks.
Signature · 1 line
Nicolas