[v3,2/3] multiarch: avoid separate builds when DPKG_ARCH is all

Message ID 20240926033935.2955085-3-cedric.hombourger@siemens.com
State Accepted, archived
Headers show
Series do not build -compat/-native for dpkg-raw packages | expand

Commit Message

cedric.hombourger@siemens.com Sept. 26, 2024, 3:39 a.m. UTC
Binary-independent packages (DPKG_ARCH == all) do not require separate
builds for our special -compat and -native targets: extend PROVIDES for
these cases. It should be noted that DPKG_ARCH is always set for all
dpkg variants and defaults to "any" (only recipes setting DPKG_ARCH to
"all" explicitly will be impacted).

Signed-off-by: Cedric Hombourger <cedric.hombourger@siemens.com>
---
 meta/classes/multiarch.bbclass | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Patch

diff --git a/meta/classes/multiarch.bbclass b/meta/classes/multiarch.bbclass
index 802686d5..9df8eefd 100644
--- a/meta/classes/multiarch.bbclass
+++ b/meta/classes/multiarch.bbclass
@@ -5,7 +5,9 @@ 
 
 inherit compat
 python() {
+    pn = d.getVar('PN')
     archDiffers = d.getVar('HOST_ARCH') != d.getVar('DISTRO_ARCH')
+    archIsAll = d.getVar('DPKG_ARCH') == 'all'
 
     def pn_multiarch_target(pn):
         return pn.endswith('-native') or pn.endswith('-compat')
@@ -20,15 +22,17 @@  python() {
 
     # provide compat only when we can build it
     if isar_can_build_compat(d):
-        d.appendVar('BBCLASSEXTEND', ' compat')
+        # but do not build separately if architecture-independent
+        if archIsAll:
+            extend_provides(pn, 'compat', d)
+        else:
+            d.appendVar('BBCLASSEXTEND', ' compat')
 
     # build native separately only when it differs from the target variant
-    if archDiffers is False:
-        pn = d.getVar('PN')
-        if pn_multiarch_target(pn) is False:
-            extend_provides(pn, 'native', d)
-    else:
+    if archIsAll is False and archDiffers:
         d.appendVar('BBCLASSEXTEND', ' native')
+    else:
+        extend_provides(pn, 'native', d)
 
     # drop own -native build dependencies at recipe level if building natively
     # and not for the builder architecture