sdk: Fix build with custom DISTRO when host==target

Message ID 363ef9b2-335b-44ed-b2e9-6df662bc0452@siemens.com
State Accepted, archived
Headers show
Series sdk: Fix build with custom DISTRO when host==target | expand

Commit Message

Jan Kiszka March 14, 2024, 7:54 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

HOST_DISTRO is not always the right choice for building an SDK. If the
host arch is identical to the target and DISTRO was customized, there is
no HOST_DISTRO to get the bootstrap from. Account for that.

This issue could have been reproduced e.g by xenomai-images when
selecting an x86 target and requesting to build the SDK for it.

Reported-by: Fabian Scheler <fabian.scheler@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/sdk.bbclass | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Florian Bezdeka March 15, 2024, 8:42 a.m. UTC | #1
On Thu, 2024-03-14 at 08:54 +0100, 'Jan Kiszka' via isar-users wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> HOST_DISTRO is not always the right choice for building an SDK. If the
> host arch is identical to the target and DISTRO was customized, there is
> no HOST_DISTRO to get the bootstrap from. Account for that.
> 
> This issue could have been reproduced e.g by xenomai-images when
> selecting an x86 target and requesting to build the SDK for it.
> 
> Reported-by: Fabian Scheler <fabian.scheler@siemens.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
[snip]

Is there no test in place that covers this case? The SDK was broken a
couple of times now. Maybe it's time to increase the test coverage.

Florian
Uladzimir Bely March 22, 2024, 1:14 p.m. UTC | #2
On Fri, 2024-03-15 at 09:42 +0100, 'Florian Bezdeka' via isar-users
wrote:
> On Thu, 2024-03-14 at 08:54 +0100, 'Jan Kiszka' via isar-users wrote:
> > From: Jan Kiszka <jan.kiszka@siemens.com>
> > 
> > HOST_DISTRO is not always the right choice for building an SDK. If
> > the
> > host arch is identical to the target and DISTRO was customized,
> > there is
> > no HOST_DISTRO to get the bootstrap from. Account for that.
> > 
> > This issue could have been reproduced e.g by xenomai-images when
> > selecting an x86 target and requesting to build the SDK for it.
> > 
> > Reported-by: Fabian Scheler <fabian.scheler@siemens.com>
> > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> > ---
> [snip]
> 
> Is there no test in place that covers this case? The SDK was broken a
> couple of times now. Maybe it's time to increase the test coverage.
> 
> Florian
> 

Hello everyone.

In order not to delay merging, we are ready to apply this to next.
Possible CI tests for sdk could be added later.

Best regards,
Uladzimir.
Anton Mikanovich April 2, 2024, 2:58 p.m. UTC | #3
15/03/2024 10:42, 'Florian Bezdeka' via isar-users wrote:
> [snip]
>
> Is there no test in place that covers this case? The SDK was broken a
> couple of times now. Maybe it's time to increase the test coverage.
>
> Florian
>
Is anyone interested in helping create such a test case?
Jan Kiszka April 9, 2024, 6:13 a.m. UTC | #4
On 02.04.24 16:58, Anton Mikanovich wrote:
> 15/03/2024 10:42, 'Florian Bezdeka' via isar-users wrote:
>> [snip]
>>
>> Is there no test in place that covers this case? The SDK was broken a
>> couple of times now. Maybe it's time to increase the test coverage.
>>
>> Florian
>>
> Is anyone interested in helping create such a test case?
> 

This is not a trivial thing, given that we have no pattern yet to model
downstream layers (with custom ) in the testsuite.

In any case, this should not delay merging this fix.

Jan
Uladzimir Bely April 15, 2024, 9:21 a.m. UTC | #5
On Thu, 2024-03-14 at 08:54 +0100, 'Jan Kiszka' via isar-users wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> HOST_DISTRO is not always the right choice for building an SDK. If
> the
> host arch is identical to the target and DISTRO was customized, there
> is
> no HOST_DISTRO to get the bootstrap from. Account for that.
> 
> This issue could have been reproduced e.g by xenomai-images when
> selecting an x86 target and requesting to build the SDK for it.
> 
> Reported-by: Fabian Scheler <fabian.scheler@siemens.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  meta/classes/sdk.bbclass | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/sdk.bbclass b/meta/classes/sdk.bbclass
> index 74c0acb9..71db6f3a 100644
> --- a/meta/classes/sdk.bbclass
> +++ b/meta/classes/sdk.bbclass
> @@ -44,9 +44,17 @@ SDK_PREINSTALL += " \
>      devscripts \
>      equivs"
>  
> +def get_rootfs_distro(d):
> +    host_arch = d.getVar('HOST_ARCH')
> +    distro_arch = d.getVar('DISTRO_ARCH')
> +    if host_arch == distro_arch:
> +        return d.getVar('DISTRO')
> +    else:
> +        return d.getVar('HOST_DISTRO')
> +
>  # rootfs/image overrides for the SDK
>  ROOTFS_ARCH:class-sdk = "${HOST_ARCH}"
> -ROOTFS_DISTRO:class-sdk = "${HOST_DISTRO}"
> +ROOTFS_DISTRO:class-sdk = "${@get_rootfs_distro(d)}"
>  ROOTFS_PACKAGES:class-sdk = "sdk-files ${SDK_TOOLCHAIN}
> ${SDK_PREINSTALL} ${@isar_multiarch_packages('SDK_INSTALL', d)}"
>  ROOTFS_FEATURES:append:class-sdk = " clean-package-cache generate-
> manifest export-dpkg-status"
>  ROOTFS_MANIFEST_DEPLOY_DIR:class-sdk = "${DEPLOY_DIR_SDKCHROOT}"
> -- 
> 2.35.3
> 

Applied to next, thanks.

Patch

diff --git a/meta/classes/sdk.bbclass b/meta/classes/sdk.bbclass
index 74c0acb9..71db6f3a 100644
--- a/meta/classes/sdk.bbclass
+++ b/meta/classes/sdk.bbclass
@@ -44,9 +44,17 @@  SDK_PREINSTALL += " \
     devscripts \
     equivs"
 
+def get_rootfs_distro(d):
+    host_arch = d.getVar('HOST_ARCH')
+    distro_arch = d.getVar('DISTRO_ARCH')
+    if host_arch == distro_arch:
+        return d.getVar('DISTRO')
+    else:
+        return d.getVar('HOST_DISTRO')
+
 # rootfs/image overrides for the SDK
 ROOTFS_ARCH:class-sdk = "${HOST_ARCH}"
-ROOTFS_DISTRO:class-sdk = "${HOST_DISTRO}"
+ROOTFS_DISTRO:class-sdk = "${@get_rootfs_distro(d)}"
 ROOTFS_PACKAGES:class-sdk = "sdk-files ${SDK_TOOLCHAIN} ${SDK_PREINSTALL} ${@isar_multiarch_packages('SDK_INSTALL', d)}"
 ROOTFS_FEATURES:append:class-sdk = " clean-package-cache generate-manifest export-dpkg-status"
 ROOTFS_MANIFEST_DEPLOY_DIR:class-sdk = "${DEPLOY_DIR_SDKCHROOT}"