Skip to contentSkip to conversation

kbuild: deb-pkg: Allow setting package name at build

PATCH In review Mario Limonciello (AMD) 2 participants 3 messages May 5 – May 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: deb-pkg: Allow setting package name at build

Users can change the source package by setting variable KDEB_SOURCENAME, but the binary package name is hardcoded.

Add support for setting binary package name by using KDEB_PACKAGENAME and let it affect both kernel image and debug image packages.

Update kbuild documentation to include defaults and mention both KDEB_PACKAGENAME and KDEB_SOURCENAME.

---
 Documentation/kbuild/kbuild.rst | 10 ++++++++++
 scripts/package/mkdebian        |  6 ++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
Documentation/kbuild/kbuild.rst +10 -0
index 5a9013bacfb75..cbdd2224c3a55 100644
@@ -177,6 +177,16 @@ the UTS_MACHINE variable, and on some architectures also the kernel config.
 The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
 architecture.
 
+KDEB_SOURCENAME
+----------------
+For the deb-pkg target, allows overriding the default source package name.
+The default package name is "linux-upstream".
+
+KDEB_PACKAGENAME
+----------------
+For the deb-pkg target, allows overriding the default binary package name.
+The default package name is "linux-image".
+
 KDOCFLAGS
 ---------
 Specify extra (warning/error) flags for kernel-doc checks during the build,
scripts/package/mkdebian +4 -2
index d4b007b38a475..cbe4266fac732 100755
@@ -166,7 +166,9 @@ else
 fi
 sourcename=${KDEB_SOURCENAME:-linux-upstream}
 
-if [ "$ARCH" = "um" ] ; then
+if [ "${KDEB_PACKAGENAME:+set}" ]; then
+	packagename=$KDEB_PACKAGENAME
+elif [ "$ARCH" = "um" ]; then
 	packagename=user-mode-linux
 else
 	packagename=linux-image
@@ -252,7 +254,7 @@ fi
 if is_enabled CONFIG_DEBUG_INFO; then
 cat <<EOF >> debian/control
 
-Package: linux-image-${KERNELRELEASE}-dbg
+Package: $packagename-${KERNELRELEASE}-dbg
 Section: debug
 Architecture: $debarch
 Build-Profiles: <!pkg.${sourcename}.nokerneldbg>
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 22 lines · Mario Limonciello (AMD)

Users can change the source package by setting variable KDEB_SOURCENAME, but the binary package name is hardcoded.

Add support for setting binary package name by using KDEB_PACKAGENAME and let it affect both kernel image and debug image packages.

Update kbuild documentation to include defaults and mention both KDEB_PACKAGENAME and KDEB_SOURCENAME.

---
 Documentation/kbuild/kbuild.rst | 10 ++++++++++
 scripts/package/mkdebian        |  6 ++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
Documentation/kbuild/kbuild.rst +0 -0
index 5a9013bacfb75..cbdd2224c3a55 100644
@@ -177,6 +177,16 @@ the UTS_MACHINE variable, and on some architectures also the kernel config.
 The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
 architecture.

Documentation/kbuild/kbuild.rst the UTS_MACHINE variable, and on some architectures also the kernel config. · line 188

Quoted 10 lines
Documentation/kbuild/kbuild.rst +9 -0
 
+KDEB_SOURCENAME
+----------------
+For the deb-pkg target, allows overriding the default source package name.
+The default package name is "linux-upstream".
+
+KDEB_PACKAGENAME
+----------------
+For the deb-pkg target, allows overriding the default binary package name.
+The default package name is "linux-image".

Do you see a real need for that? (We should prevent adding complexity when it's not neccessary.)

Quoted 31 lines
Documentation/kbuild/kbuild.rst +1 -0
+
 KDOCFLAGS
 ---------
 Specify extra (warning/error) flags for kernel-doc checks during the build,
scripts/package/mkdebian +4 -2
index d4b007b38a475..cbe4266fac732 100755
@@ -166,7 +166,9 @@ else
 fi
 sourcename=${KDEB_SOURCENAME:-linux-upstream}
 
-if [ "$ARCH" = "um" ] ; then
+if [ "${KDEB_PACKAGENAME:+set}" ]; then
+	packagename=$KDEB_PACKAGENAME
+elif [ "$ARCH" = "um" ]; then
 	packagename=user-mode-linux
 else
 	packagename=linux-image
@@ -252,7 +254,7 @@ fi
 if is_enabled CONFIG_DEBUG_INFO; then
 cat <<EOF >> debian/control
 
-Package: linux-image-${KERNELRELEASE}-dbg
+Package: $packagename-${KERNELRELEASE}-dbg
 Section: debug
 Architecture: $debarch
 Build-Profiles: <!pkg.${sourcename}.nokerneldbg>
Signature · 1 line
2.53.0

Did you test that patch?

These changes are not enough, as scripts/package/builddeb does not pick up the non-standard binary package name in its final 'case', and thus, _no_ binary package will be generated if KDEB_PACKAGENAME != "linux-image".

Kind regards,
Nicolas

#2 lore raw
Quoted 71 lines · Nicolas Schier
Quoted 22 lines · Mario Limonciello (AMD)

Users can change the source package by setting variable KDEB_SOURCENAME, but the binary package name is hardcoded.

Add support for setting binary package name by using KDEB_PACKAGENAME and let it affect both kernel image and debug image packages.

Update kbuild documentation to include defaults and mention both KDEB_PACKAGENAME and KDEB_SOURCENAME.

---
  Documentation/kbuild/kbuild.rst | 10 ++++++++++
  scripts/package/mkdebian        |  6 ++++--
  2 files changed, 14 insertions(+), 2 deletions(-)
Documentation/kbuild/kbuild.rst +0 -0
index 5a9013bacfb75..cbdd2224c3a55 100644
@@ -177,6 +177,16 @@ the UTS_MACHINE variable, and on some architectures also the kernel config.
  The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
  architecture.

Documentation/kbuild/kbuild.rst the UTS_MACHINE variable, and on some architectures also the kernel config. · line 188

Quoted 10 lines
Documentation/kbuild/kbuild.rst +9 -0
 
+KDEB_SOURCENAME
+----------------
+For the deb-pkg target, allows overriding the default source package name.
+The default package name is "linux-upstream".
+
+KDEB_PACKAGENAME
+----------------
+For the deb-pkg target, allows overriding the default binary package name.
+The default package name is "linux-image".

Do you see a real need for that? (We should prevent adding complexity when it's not neccessary.)

Quoted 31 lines
Documentation/kbuild/kbuild.rst +1 -0
+
  KDOCFLAGS
  ---------
  Specify extra (warning/error) flags for kernel-doc checks during the build,
scripts/package/mkdebian +4 -2
index d4b007b38a475..cbe4266fac732 100755
@@ -166,7 +166,9 @@ else
  fi
  sourcename=${KDEB_SOURCENAME:-linux-upstream}
 
-if [ "$ARCH" = "um" ] ; then
+if [ "${KDEB_PACKAGENAME:+set}" ]; then
+	packagename=$KDEB_PACKAGENAME
+elif [ "$ARCH" = "um" ]; then
  	packagename=user-mode-linux
  else
  	packagename=linux-image
@@ -252,7 +254,7 @@ fi
  if is_enabled CONFIG_DEBUG_INFO; then
  cat <<EOF >> debian/control
 
-Package: linux-image-${KERNELRELEASE}-dbg
+Package: $packagename-${KERNELRELEASE}-dbg
  Section: debug
  Architecture: $debarch
  Build-Profiles: <!pkg.${sourcename}.nokerneldbg>
Signature · 1 line
2.53.0

Did you test that patch?

Quoted 7 lines

These changes are not enough, as scripts/package/builddeb does not pick up the non-standard binary package name in its final 'case', and thus, _no_ binary package will be generated if KDEB_PACKAGENAME != "linux-image".

Kind regards,
Nicolas

Apparently I didn't test effectively beyond making sure it built and didn't introspect the build log closely enough. Sorry about that!

Let me explain the background of what I was looking to do here.

The changing a package name was mostly so that I could sync up the source package and binary package names.

So I could (for example) upload a source package from a given tree to a PPA and then the PPA would build binary packages.

I could then upload a source package for another tree and let the same PPA build the binary packages for it.

If you have the same binary package name for both packages then you need to do some git archaeology to figure out which hashes go with which trees. Or you can look at PPA build logs and figure it out.

Both of those methods are a lot of work for what I thought could be done pretty easily with a variable to differentiate.

This would allow easily cross referencing a test result between two different trees.