[v2,2/4] sbuild: do not build arch all packages on cross

Message ID 20260504085048.705717-3-felix.moessbauer@siemens.com
State Under Review
Headers show
Series Only build arch=all package from -native variant | expand

Commit Message

Felix Moessbauer May 4, 2026, 8:50 a.m. UTC
Architecture all packages often cannot be built in cross mode, as the
dependencies cannot be resolved in the host architecture. This
especially applies to all packages which split their build dependencies
into Build-Depends-Arch and Build-Depends-Indep. We already have logic
in isar to built DPKG_ARCH=all packages non-cross, but this does not
work for packages that generate both arch specific and arch all binary
packages.

While sbuild automatically disables builds of arch-all packages on
cross, we previously explicitly overrode this setting. We now change
this by explicitly setting --no-arch-all flag on cross and --arch-all on
non-cross.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 RECIPE-API-CHANGELOG.md               | 16 ++++++++++++++++
 meta/classes-recipe/dpkg.bbclass      |  3 ++-
 meta/classes-recipe/multiarch.bbclass |  4 ++++
 3 files changed, 22 insertions(+), 1 deletion(-)

Patch

diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
index 856da5de..d4b093f4 100644
--- a/RECIPE-API-CHANGELOG.md
+++ b/RECIPE-API-CHANGELOG.md
@@ -1001,3 +1001,19 @@  do_copy_boot_files: The recipe isar-image-base is trying to install
 files into a shared area when those files already exists. It happens
 when some files have the same names (e.g., dtb files) for different
 distros.
+
+### No building of arch=all packages when cross building
+
+Architecture all packages often cannot be built in cross mode, as the
+dependencies cannot be resolved in the foreign architecture. This especially
+applies to all packages which split their build dependencies into
+`Build-Depends-Arch` and `Build-Depends-Indep`. We already have logic
+in isar to built `DPKG_ARCH = "all"` packages non-cross, but this does not
+work for packages that generate both arch specific and arch all binary packages.
+
+We now explicitly disable building `arch=all` binary packages during cross
+compilation (this only affects packages that produce both architecture-specific
+and `arch=all` binary packages). Recipes for such mixed packages should append
+`-all` to the `arch=all` binary packages listed in `PROVIDES` (e.g.,
+`PROVIDES="foo-doc-all"` for an `arch=all` binary package `foo-doc`). Consumers
+can then simply reference the package by its original name (e.g., `foo-doc`).
diff --git a/meta/classes-recipe/dpkg.bbclass b/meta/classes-recipe/dpkg.bbclass
index c1c38184..500aaefe 100644
--- a/meta/classes-recipe/dpkg.bbclass
+++ b/meta/classes-recipe/dpkg.bbclass
@@ -109,8 +109,9 @@  dpkg_runbuild() {
 
     DSC_FILE=$(find ${WORKDIR} -maxdepth 1 -name "${DEBIAN_SOURCE}_*.dsc" -print)
 
-    sbuild -A -n -c ${SBUILD_CHROOT} --chroot-mode=schroot \
+    sbuild -n -c ${SBUILD_CHROOT} --chroot-mode=schroot \
         --host=${PACKAGE_ARCH} --build=${BUILD_ARCH} ${profiles} \
+        ${@'--no-arch-all' if 'cross' in isar_deb_build_profiles(d).split() else '--arch-all'} \
         --no-run-lintian --no-run-piuparts --no-run-autopkgtest --resolve-alternatives \
         --bd-uninstallable-explainer=apt \
         --no-apt-update --apt-distupgrade \
diff --git a/meta/classes-recipe/multiarch.bbclass b/meta/classes-recipe/multiarch.bbclass
index cdd35f12..6c0fa809 100644
--- a/meta/classes-recipe/multiarch.bbclass
+++ b/meta/classes-recipe/multiarch.bbclass
@@ -83,6 +83,10 @@  python multiarch_virtclass_handler() {
             for v in val.split():
                 if v.endswith('-compat') or v.endswith('-native'):
                     multiarch_var.append(v)
+                # dispatch -all (arch=all) to native variant
+                if v.endswith('-all'):
+                    if suffix == '-native':
+                        multiarch_var.append(v[:-len('-all')])
                 else:
                     multiarch_var.append(v + suffix)
             d.setVar(var, ' '.join(multiarch_var))