[v3,2/4] linux-custom: fix name collision on cross profile

Message ID 20251106141122.2887558-3-felix.moessbauer@siemens.com
State Under Review
Headers show
Series propagate distro-specific dependencies of arch all packages | expand

Commit Message

MOESSBAUER, Felix Nov. 6, 2025, 2:11 p.m. UTC
The cross build profile is currently used to control which packages are
built in a DISTRO_ARCH != HOST_ARCH scenario. This is fundamentally
wrong, as the cross profile is one of the standard debian build profiles
which is used to control if sbuild runs in cross mode. Further, the
build profile spec [1] forbids to conditionally generate binary packages
based on this profile. We now split this profile off into a custom one
to not interfere with the standard cross profile.

Due to the split, we now also need to set our cross profile explicitly
in the desired cases, which we now control via the cross-pkgs overrides.

[1] https://wiki.debian.org/BuildProfileSpec#Registered_profile_names

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/recipes-kernel/linux/files/debian/control.tmpl |  6 +++---
 meta/recipes-kernel/linux/linux-custom.inc          | 10 ++++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

Patch

diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl b/meta/recipes-kernel/linux/files/debian/control.tmpl
index 01b1a63f..ee87cf92 100644
--- a/meta/recipes-kernel/linux/files/debian/control.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/control.tmpl
@@ -33,7 +33,7 @@  Description: Linux support headers for userspace development
  are used by the installed headers for GNU glibc and other system libraries.
 
 Package: linux-libc-dev-${DISTRO_ARCH}-cross
-Build-Profiles: <!pkg.${BPN}.nolibcdev cross !pkg.${BPN}.kbuild>
+Build-Profiles: <!pkg.${BPN}.nolibcdev pkg.${BPN}.cross !pkg.${BPN}.kbuild>
 Section: devel
 Provides: linux-kernel-headers-${DISTRO_ARCH}-cross
 Architecture: all
@@ -53,7 +53,7 @@  Description: Linux kernel debugging symbols for @KR@
  all the necessary debug symbols for the kernel and its modules.
 
 Package: linux-kbuild-${KERNEL_NAME_PROVIDED}
-Build-Profiles: <pkg.${BPN}.kbuild !cross>
+Build-Profiles: <pkg.${BPN}.kbuild !pkg.${BPN}.cross>
 Architecture: any
 Depends: ${perl:Depends}, ${shlibs:Depends}
 Description: ${KERNEL_NAME_PROVIDED} Linux kbuild scripts and tools for @KR@
@@ -61,7 +61,7 @@  Description: ${KERNEL_NAME_PROVIDED} Linux kbuild scripts and tools for @KR@
  This is useful for people who need to build external modules
 
 Package: linux-kbuild-${KERNEL_NAME_PROVIDED}-${DISTRO_ARCH}-cross
-Build-Profiles: <pkg.${BPN}.kbuild cross>
+Build-Profiles: <pkg.${BPN}.kbuild pkg.${BPN}.cross>
 Architecture: any
 Multi-Arch: foreign
 Depends: ${perl:Depends}, ${shlibs:Depends}
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index 1f46bb31..9dd9abb5 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -110,8 +110,13 @@  KERNEL_NAME_PROVIDED ?= "${@ d.getVar('BPN').partition('linux-')[2]}"
 
 # Determine cross-profile override
 python() {
-    if d.getVar("DISTRO_ARCH") != d.getVar("HOST_ARCH") and bb.utils.to_boolean(d.getVar("ISAR_CROSS_COMPILE")) and "class-native" not in d.getVar("OVERRIDES").split(":"):
-        d.appendVar("OVERRIDES", ":cross-profile")
+    if d.getVar("DISTRO_ARCH") != d.getVar("HOST_ARCH") and bb.utils.to_boolean(d.getVar("ISAR_CROSS_COMPILE")):
+        if "class-native" not in d.getVar("OVERRIDES").split(":"):
+            # cross compiling
+            d.appendVar("OVERRIDES", ":cross-profile")
+        else:
+            # generating -cross packages (in HOST_ARCH) from a -native variant
+            d.appendVar("OVERRIDES", ":cross-pkgs")
 }
 
 # Default profiles and provides
@@ -126,6 +131,7 @@  BUILD_PROFILES:cross-profile = "pkg.${BPN}.kernel"
 
 # -native: kbuild package for host
 BUILD_PROFILES:class-native = "pkg.${BPN}.kbuild"
+BUILD_PROFILES:append:cross-pkgs = " pkg.${BPN}.cross"
 RECIPE_PROVIDES:class-native = " \
     linux-headers-${KERNEL_NAME_PROVIDED} \
     linux-kbuild-${KERNEL_NAME_PROVIDED}"