public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 1/1] multiarch: inject native variants of preferred providers
@ 2025-10-17  8:53 'Felix Moessbauer' via isar-users
  2025-10-17  9:09 ` 'Jan Kiszka' via isar-users
  2025-10-24 12:17 ` Zhihang Wei
  0 siblings, 2 replies; 3+ messages in thread
From: 'Felix Moessbauer' via isar-users @ 2025-10-17  8:53 UTC (permalink / raw)
  To: isar-users; +Cc: adriaan.schmidt, Felix Moessbauer, Jan Kiszka

We already create multiarch variants of our recipes in case the host and
target arch are not the same. However, this currently breaks when
combining with PREFERRED_PROVIDERS, as no entries for the -native
variantes are created. By that, bitbake bails out with the following
error:
  Multiple .bb files are due to be built which each provide
  <recipe>-native.

We fix this by injecting the -native variants for all preferred
providers as well (but only in case no explicit one is provided for the
-native variant). This needs to be done after config parsing (hence in
base.bblcass), as the PREFERRED_PROVIDERS are already used at recipe
parsing time (where multiarch.bbclass is loaded).

Fixes: 5a7c2f70 ("handle DPKG_ARCH=all case for transitive deps")
Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
Note, that this can be tested on isar-cip-core, but requires the other
fix in "image: Fix construction of do_image_tools dependencies" as well.

 meta/classes/base.bbclass | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 90fd570c..471442e5 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -62,6 +62,30 @@ def get_deb_host_arch():
 HOST_ARCH ??= "${@get_deb_host_arch()}"
 HOST_DISTRO ??= "${DISTRO}"
 
+# Inject the PREFERRED_PROVIDERs for multiarch variants. This corresponds to
+# the multiarch_virtclass_handler logic in multiarch.bbclass, but needs to be
+# done prior to recipe parsing.
+def inject_preferred_providers(provider, suffix, d):
+    PP_PREFIX = 'PREFERRED_PROVIDER_'
+    if provider.endswith(suffix):
+        return
+    prefp_value = d.getVar(PP_PREFIX + provider)
+    if prefp_value and not d.getVar(PP_PREFIX + provider + suffix):
+        d.setVar(PP_PREFIX + provider + suffix, prefp_value + suffix)
+
+python multiarch_preferred_providers_handler() {
+    if d.getVar('HOST_ARCH') == d.getVar('DISTRO_ARCH'):
+        return
+
+    pref_vars = {var: e.data.getVar(var)
+                 for var in e.data.keys()
+                 if var.startswith('PREFERRED_PROVIDER_')}
+    for p in pref_vars:
+        inject_preferred_providers(p.replace('PREFERRED_PROVIDER_', ''), '-native', e.data)
+}
+addhandler multiarch_preferred_providers_handler
+multiarch_preferred_providers_handler[eventmask] = "bb.event.ConfigParsed"
+
 die() {
 	bbfatal "$*"
 }
-- 
2.51.0

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20251017085344.2647058-1-felix.moessbauer%40siemens.com.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] multiarch: inject native variants of preferred providers
  2025-10-17  8:53 [PATCH 1/1] multiarch: inject native variants of preferred providers 'Felix Moessbauer' via isar-users
@ 2025-10-17  9:09 ` 'Jan Kiszka' via isar-users
  2025-10-24 12:17 ` Zhihang Wei
  1 sibling, 0 replies; 3+ messages in thread
From: 'Jan Kiszka' via isar-users @ 2025-10-17  9:09 UTC (permalink / raw)
  To: Felix Moessbauer, isar-users; +Cc: adriaan.schmidt

On 17.10.25 10:53, Felix Moessbauer wrote:
> We already create multiarch variants of our recipes in case the host and
> target arch are not the same. However, this currently breaks when
> combining with PREFERRED_PROVIDERS, as no entries for the -native
> variantes are created. By that, bitbake bails out with the following
> error:
>   Multiple .bb files are due to be built which each provide
>   <recipe>-native.
> 
> We fix this by injecting the -native variants for all preferred
> providers as well (but only in case no explicit one is provided for the
> -native variant). This needs to be done after config parsing (hence in
> base.bblcass), as the PREFERRED_PROVIDERS are already used at recipe
> parsing time (where multiarch.bbclass is loaded).
> 
> Fixes: 5a7c2f70 ("handle DPKG_ARCH=all case for transitive deps")
> Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
> Note, that this can be tested on isar-cip-core, but requires the other
> fix in "image: Fix construction of do_image_tools dependencies" as well.
> 
>  meta/classes/base.bbclass | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index 90fd570c..471442e5 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -62,6 +62,30 @@ def get_deb_host_arch():
>  HOST_ARCH ??= "${@get_deb_host_arch()}"
>  HOST_DISTRO ??= "${DISTRO}"
>  
> +# Inject the PREFERRED_PROVIDERs for multiarch variants. This corresponds to
> +# the multiarch_virtclass_handler logic in multiarch.bbclass, but needs to be
> +# done prior to recipe parsing.
> +def inject_preferred_providers(provider, suffix, d):
> +    PP_PREFIX = 'PREFERRED_PROVIDER_'
> +    if provider.endswith(suffix):
> +        return
> +    prefp_value = d.getVar(PP_PREFIX + provider)
> +    if prefp_value and not d.getVar(PP_PREFIX + provider + suffix):
> +        d.setVar(PP_PREFIX + provider + suffix, prefp_value + suffix)
> +
> +python multiarch_preferred_providers_handler() {
> +    if d.getVar('HOST_ARCH') == d.getVar('DISTRO_ARCH'):
> +        return
> +
> +    pref_vars = {var: e.data.getVar(var)
> +                 for var in e.data.keys()
> +                 if var.startswith('PREFERRED_PROVIDER_')}
> +    for p in pref_vars:
> +        inject_preferred_providers(p.replace('PREFERRED_PROVIDER_', ''), '-native', e.data)
> +}
> +addhandler multiarch_preferred_providers_handler
> +multiarch_preferred_providers_handler[eventmask] = "bb.event.ConfigParsed"
> +
>  die() {
>  	bbfatal "$*"
>  }

Works well.

Tested-by: Jan Kiszka <jan.kiszka@siemens.com>

I suppose we should do the same for PREFERRED_VERSION, and also for
-kbuildtarget of self-built kernels.

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/8c8b0d6e-95e6-449c-8834-20042035a7ed%40siemens.com.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] multiarch: inject native variants of preferred providers
  2025-10-17  8:53 [PATCH 1/1] multiarch: inject native variants of preferred providers 'Felix Moessbauer' via isar-users
  2025-10-17  9:09 ` 'Jan Kiszka' via isar-users
@ 2025-10-24 12:17 ` Zhihang Wei
  1 sibling, 0 replies; 3+ messages in thread
From: Zhihang Wei @ 2025-10-24 12:17 UTC (permalink / raw)
  To: Felix Moessbauer, isar-users; +Cc: adriaan.schmidt, Jan Kiszka

Applied to next, thanks.

There was an issue with ssh-keygen task blocking oops when booting qemu 
image,
but the same image file can be booted on the same host later without any
problem. It's most likely a one-off issue on the CI server.

Best regards,
Zhihang

On 10/17/25 10:53, 'Felix Moessbauer' via isar-users wrote:
> We already create multiarch variants of our recipes in case the host and
> target arch are not the same. However, this currently breaks when
> combining with PREFERRED_PROVIDERS, as no entries for the -native
> variantes are created. By that, bitbake bails out with the following
> error:
>    Multiple .bb files are due to be built which each provide
>    <recipe>-native.
>
> We fix this by injecting the -native variants for all preferred
> providers as well (but only in case no explicit one is provided for the
> -native variant). This needs to be done after config parsing (hence in
> base.bblcass), as the PREFERRED_PROVIDERS are already used at recipe
> parsing time (where multiarch.bbclass is loaded).
>
> Fixes: 5a7c2f70 ("handle DPKG_ARCH=all case for transitive deps")
> Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
> Note, that this can be tested on isar-cip-core, but requires the other
> fix in "image: Fix construction of do_image_tools dependencies" as well.
>
>   meta/classes/base.bbclass | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
>
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index 90fd570c..471442e5 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -62,6 +62,30 @@ def get_deb_host_arch():
>   HOST_ARCH ??= "${@get_deb_host_arch()}"
>   HOST_DISTRO ??= "${DISTRO}"
>   
> +# Inject the PREFERRED_PROVIDERs for multiarch variants. This corresponds to
> +# the multiarch_virtclass_handler logic in multiarch.bbclass, but needs to be
> +# done prior to recipe parsing.
> +def inject_preferred_providers(provider, suffix, d):
> +    PP_PREFIX = 'PREFERRED_PROVIDER_'
> +    if provider.endswith(suffix):
> +        return
> +    prefp_value = d.getVar(PP_PREFIX + provider)
> +    if prefp_value and not d.getVar(PP_PREFIX + provider + suffix):
> +        d.setVar(PP_PREFIX + provider + suffix, prefp_value + suffix)
> +
> +python multiarch_preferred_providers_handler() {
> +    if d.getVar('HOST_ARCH') == d.getVar('DISTRO_ARCH'):
> +        return
> +
> +    pref_vars = {var: e.data.getVar(var)
> +                 for var in e.data.keys()
> +                 if var.startswith('PREFERRED_PROVIDER_')}
> +    for p in pref_vars:
> +        inject_preferred_providers(p.replace('PREFERRED_PROVIDER_', ''), '-native', e.data)
> +}
> +addhandler multiarch_preferred_providers_handler
> +multiarch_preferred_providers_handler[eventmask] = "bb.event.ConfigParsed"
> +
>   die() {
>   	bbfatal "$*"
>   }

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/9577771c-2905-41d7-a986-097e1d9ebc65%40ilbers.de.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-24 12:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-17  8:53 [PATCH 1/1] multiarch: inject native variants of preferred providers 'Felix Moessbauer' via isar-users
2025-10-17  9:09 ` 'Jan Kiszka' via isar-users
2025-10-24 12:17 ` Zhihang Wei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox