diff mbox series

[2/2] oeqa/selftest/incompatible_lic: test INCOMPATIBLE_LICENSE in populate_sdk

Message ID 20261113101537.3586467-2-sean@geanix.com
State New
Headers show
Series [1/2] license_image: don't apply INCOMPATIBLE_LICENSE to SDK host tools | expand

Commit Message

Sean Nyekjaer Nov. 13, 2026, 10:15 a.m. UTC
Check that do_populate_sdk ignores the image's INCOMPATIBLE_LICENSE for
SDK host tools (nativesdk-bash) and still applies it to packages in the
SDK target sysroot (which).

bash can't be used for the target check, as target-sdk-provides-dummy
RPROVIDES bash, so it is never installed into the SDK target sysroot.

Autoconf-exception-macro is added to the exceptions, as the SDK's
complementary packages include xz-src.

AI-Generated: Claude Opus 5.5 (Claude Code)
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
It seems weird to add the AI-Generated tag here.
It took quite a lot of effort to get the tests to fail before 1/2 and
pass after 1/2.

 .../oeqa/selftest/cases/incompatible_lic.py   | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/incompatible_lic.py b/meta/lib/oeqa/selftest/cases/incompatible_lic.py
index 406f92e37b..e05e2ee31c 100644
--- a/meta/lib/oeqa/selftest/cases/incompatible_lic.py
+++ b/meta/lib/oeqa/selftest/cases/incompatible_lic.py
@@ -155,6 +155,34 @@  NO_GENERIC_LICENSE[SomeLicense] = "COPYING"
             """))
         bitbake('core-image-minimal')
 
+class IncompatibleLicensePerImageSDKTests(OESelftestTestCase):
+    def default_config(self):
+        return """
+INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0* LGPL-3.0*"
+INCOMPATIBLE_LICENSE_EXCEPTIONS:pn-core-image-minimal = "GCC-exception-3.1 Autoconf-exception-macro"
+ERROR_QA:remove:pn-core-image-minimal = "license-exception"
+
+require conf/distro/include/no-gplv3.inc
+"""
+
+    # Verify that host tools in the SDK (nativesdk, cross-canadian) are not
+    # checked against the image's INCOMPATIBLE_LICENSE, the same as at parse
+    # time
+    def test_sdk_host_gpl3(self):
+        self.write_config(self.default_config() + '\nTOOLCHAIN_HOST_TASK:append:pn-core-image-minimal = " nativesdk-bash"')
+
+        bitbake('core-image-minimal -c populate_sdk')
+
+    # Verify that target packages in the SDK sysroot are still checked
+    # against the image's INCOMPATIBLE_LICENSE
+    def test_sdk_target_gpl3(self):
+        self.write_config(self.default_config() + '\nTOOLCHAIN_TARGET_TASK:append:pn-core-image-minimal = " which"')
+        error_msg = "ERROR: core-image-minimal-1.0-r0 do_populate_sdk: Some packages cannot be installed into the image because they have incompatible licenses:\n\twhich (GPL-3.0-or-later)"
+
+        result = bitbake('core-image-minimal -c populate_sdk', ignore_status=True)
+        if error_msg not in result.output:
+            raise AssertionError(result.output)
+
 class NoGPL3InImagesTests(OESelftestTestCase):
     def test_core_image_minimal(self):
         self.write_config("""