diff mbox series

[v2,2/3] license_image: don't apply INCOMPATIBLE_LICENSE to SDK host tools

Message ID 20261117120155.3986876-3-sean@geanix.com
State New
Headers show
Series license_image: don't apply INCOMPATIBLE_LICENSE to SDK host tools | expand

Commit Message

Sean Nyekjaer Nov. 17, 2026, 12:01 p.m. UTC
Since the SDK host and target sysroots are passed through
write_license_files(), do_populate_sdk checks every nativesdk and
cross-canadian package against the image's INCOMPATIBLE_LICENSE and
fails, e.g. with INCOMPATIBLE_LICENSE = "GPL-3.0*":

  Some packages cannot be installed into the image because they have
  incompatible licenses:
        nativesdk-autoconf (GPL-3.0-or-later)

At parse time skip_incompatible_package_licenses() exempts these
recipes, so they are built and packaged, and only the SDK manifest
step rejects them. Use incompatible_license_check_needed() in
write_license_files() too, so host tools in the SDK are treated the
same way. Target packages in the image and in the SDK target sysroot
are still checked.

Fixes: f757ae4dadab ("license_image: extend to SDK coverage")
AI-Generated: Claude Opus 5.5 (Claude Code)
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
 meta/classes-recipe/license_image.bbclass | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Peter Kjellerstedt Nov. 17, 2026, 1:04 p.m. UTC | #1
> -----Original Message-----
> From: Sean Nyekjaer via openembedded-core <sean=geanix.com@lists.openembedded.org>
> Sent: den 17 november 2026 13:02
> To: openembedded-core@lists.openembedded.org
> Cc: Sean Nyekjaer <sean@geanix.com>
> Subject: [OE-core] [PATCH v2 2/3] license_image: don't apply INCOMPATIBLE_LICENSE to SDK host tools
> 
> Since the SDK host and target sysroots are passed through
> write_license_files(), do_populate_sdk checks every nativesdk and
> cross-canadian package against the image's INCOMPATIBLE_LICENSE and
> fails, e.g. with INCOMPATIBLE_LICENSE = "GPL-3.0*":
> 
>   Some packages cannot be installed into the image because they have
>   incompatible licenses:
>         nativesdk-autoconf (GPL-3.0-or-later)
> 
> At parse time skip_incompatible_package_licenses() exempts these
> recipes, so they are built and packaged, and only the SDK manifest
> step rejects them. Use incompatible_license_check_needed() in
> write_license_files() too, so host tools in the SDK are treated the
> same way. Target packages in the image and in the SDK target sysroot
> are still checked.
> 
> Fixes: f757ae4dadab ("license_image: extend to SDK coverage")
> AI-Generated: Claude Opus 5.5 (Claude Code)
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> ---
>  meta/classes-recipe/license_image.bbclass | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/classes-recipe/license_image.bbclass b/meta/classes-recipe/license_image.bbclass
> index 7d00b1ae53..728db8ae3a 100644
> --- a/meta/classes-recipe/license_image.bbclass
> +++ b/meta/classes-recipe/license_image.bbclass
> @@ -128,16 +128,23 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs):
> 
>              pkg_allow_licenses = oe.license.filter_pkg_license_list(pkg, allow_licenses)
> 
> +            # Host tools in the SDK (nativesdk, cross-canadian) are not
> +            # subject to INCOMPATIBLE_LICENSE, same as at parse time.
> +            if oe.license.incompatible_license_check_needed(d, pkg_dic[pkg]["PN"]):
> +                pkg_bad_licenses = bad_licenses
> +            else:
> +                pkg_bad_licenses = []
> +
>              if node:
> -                if incompatible_licenses := oe.license.license_allowed(node, bad_licenses, pkg_allow_licenses):
> +                if incompatible_licenses := oe.license.license_allowed(node, pkg_bad_licenses, pkg_allow_licenses):
>                      incompatible_packages.append("%s (%s)" % (pkg, ' '.join(n.to_string() for n in incompatible_licenses)))
> -                elif incompatible_licenses := oe.license.license_allowed(node, bad_licenses, []):
> +                elif incompatible_licenses := oe.license.license_allowed(node, pkg_bad_licenses, []):
>                      oe.qa.handle_error('license-exception', "Including %s with incompatible license(s) %s into the image, because it has been allowed by exception list." %
>                                         (pkg, ' '.join(n.to_string() for n in incompatible_licenses)), d)
> 
>              (pkg_dic[pkg]["LICENSE"], pkg_dic[pkg]["LICENSES"]) = \
>                  oe.license.manifest_licenses(d, pkg_dic[pkg]["LICENSE"],
> -                                             bad_licenses, pkg_allow_licenses)
> +                                             pkg_bad_licenses, pkg_allow_licenses)
> 
>              if not "IMAGE_MANIFEST" in pkg_dic[pkg]:
>                  # Rootfs manifest
> --
> 2.56.0

IANAL, but for the record, I believe you risk violating the (L)GPL-3 license 
if you distribute an SDK after applying the above, and then do not comply 
with the license requirements of the (L)GPL-3 license. And the whole point of
using INCOMPATIBLE_LICENSE = "*GPL-3.0*" in your configuration is to avoid this
risk.

Since the GPL license is all about what you distribute, it does not matter if it
is target or native tools, you are *distributing* them all as part of the SDK.

Thus I believe it is wrong to apply this, but if it is applied, it should be 
opt-in, and come with a massive warning.

//Peter
Sean Nyekjaer Nov. 17, 2026, 1:26 p.m. UTC | #2
> On 17 Nov 2026, at 14.04, Peter Kjellerstedt <peter.kjellerstedt@axis.com> wrote:
> 
>> -----Original Message-----
>> From: Sean Nyekjaer via openembedded-core <sean=geanix.com@lists.openembedded.org>
>> Sent: den 17 november 2026 13:02
>> To: openembedded-core@lists.openembedded.org
>> Cc: Sean Nyekjaer <sean@geanix.com>
>> Subject: [OE-core] [PATCH v2 2/3] license_image: don't apply INCOMPATIBLE_LICENSE to SDK host tools
>> 
>> Since the SDK host and target sysroots are passed through
>> write_license_files(), do_populate_sdk checks every nativesdk and
>> cross-canadian package against the image's INCOMPATIBLE_LICENSE and
>> fails, e.g. with INCOMPATIBLE_LICENSE = "GPL-3.0*":
>> 
>>  Some packages cannot be installed into the image because they have
>>  incompatible licenses:
>>        nativesdk-autoconf (GPL-3.0-or-later)
>> 
>> At parse time skip_incompatible_package_licenses() exempts these
>> recipes, so they are built and packaged, and only the SDK manifest
>> step rejects them. Use incompatible_license_check_needed() in
>> write_license_files() too, so host tools in the SDK are treated the
>> same way. Target packages in the image and in the SDK target sysroot
>> are still checked.
>> 
>> Fixes: f757ae4dadab ("license_image: extend to SDK coverage")
>> AI-Generated: Claude Opus 5.5 (Claude Code)
>> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
>> ---
>> meta/classes-recipe/license_image.bbclass | 13 ++++++++++---
>> 1 file changed, 10 insertions(+), 3 deletions(-)
>> 
>> diff --git a/meta/classes-recipe/license_image.bbclass b/meta/classes-recipe/license_image.bbclass
>> index 7d00b1ae53..728db8ae3a 100644
>> --- a/meta/classes-recipe/license_image.bbclass
>> +++ b/meta/classes-recipe/license_image.bbclass
>> @@ -128,16 +128,23 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs):
>> 
>>             pkg_allow_licenses = oe.license.filter_pkg_license_list(pkg, allow_licenses)
>> 
>> +            # Host tools in the SDK (nativesdk, cross-canadian) are not
>> +            # subject to INCOMPATIBLE_LICENSE, same as at parse time.
>> +            if oe.license.incompatible_license_check_needed(d, pkg_dic[pkg]["PN"]):
>> +                pkg_bad_licenses = bad_licenses
>> +            else:
>> +                pkg_bad_licenses = []
>> +
>>             if node:
>> -                if incompatible_licenses := oe.license.license_allowed(node, bad_licenses, pkg_allow_licenses):
>> +                if incompatible_licenses := oe.license.license_allowed(node, pkg_bad_licenses, pkg_allow_licenses):
>>                     incompatible_packages.append("%s (%s)" % (pkg, ' '.join(n.to_string() for n in incompatible_licenses)))
>> -                elif incompatible_licenses := oe.license.license_allowed(node, bad_licenses, []):
>> +                elif incompatible_licenses := oe.license.license_allowed(node, pkg_bad_licenses, []):
>>                     oe.qa.handle_error('license-exception', "Including %s with incompatible license(s) %s into the image, because it has been allowed by exception list." %
>>                                        (pkg, ' '.join(n.to_string() for n in incompatible_licenses)), d)
>> 
>>             (pkg_dic[pkg]["LICENSE"], pkg_dic[pkg]["LICENSES"]) = \
>>                 oe.license.manifest_licenses(d, pkg_dic[pkg]["LICENSE"],
>> -                                             bad_licenses, pkg_allow_licenses)
>> +                                             pkg_bad_licenses, pkg_allow_licenses)
>> 
>>             if not "IMAGE_MANIFEST" in pkg_dic[pkg]:
>>                 # Rootfs manifest
>> --
>> 2.56.0
> 
> IANAL, but for the record, I believe you risk violating the (L)GPL-3 license
> if you distribute an SDK after applying the above, and then do not comply
> with the license requirements of the (L)GPL-3 license. And the whole point of
> using INCOMPATIBLE_LICENSE = "*GPL-3.0*" in your configuration is to avoid this
> risk.
> 
> Since the GPL license is all about what you distribute, it does not matter if it
> is target or native tools, you are *distributing* them all as part of the SDK.
> 
> Thus I believe it is wrong to apply this, but if it is applied, it should be
> opt-in, and come with a massive warning.
> 
> //Peter
> 

Thanks for the review.

The problem is that until recently INCOMPATIBLE_LICENSE never covered the
SDK. My build broke after commit f757ae4dadab ("license_image: extend to
SDK coverage"), which started checking the SDK host and target sysroots
in do_populate_sdk.

So "GPL-3.0*" has never given a GPLv3-free SDK. 

The documentation also describes INCOMPATIBLE_LICENSE in terms of the
build and images: it excludes licenses "from the build (if set
globally), or from an image (if set locally in an image recipe)", and
recommends setting it "in specific image recipes". I read "image" as the
target image you deploy, not the SDK built from it. My customer has to
keep GPLv3 out of the target image but is fine with GPLv3 in the SDK,
which is exactly what worked before.

That said, I see the value of being able to check the SDK too. How about
a separate variable, e.g. INCOMPATIBLE_LICENSE_SDK, that do_populate_sdk
checks the SDK host packages against? Target packages in the SDK target
sysroot would still be checked against INCOMPATIBLE_LICENSE, as with this
series.

The open question is the default:
- INCOMPATIBLE_LICENSE_SDK ?= "${INCOMPATIBLE_LICENSE}" keeps the
  current master behaviour, and the rest of us have to opt out.

/Sean
Peter Kjellerstedt Nov. 17, 2026, 3:09 p.m. UTC | #3
> -----Original Message-----
> From: Sean Nyekjaer <sean@geanix.com>
> Sent: den 17 november 2026 14:27
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH v2 2/3] license_image: don't apply INCOMPATIBLE_LICENSE to SDK host tools
> 
> > On 17 Nov 2026, at 14.04, Peter Kjellerstedt <peter.kjellerstedt@axis.com> wrote:
> >
> >> -----Original Message-----
> >> From: Sean Nyekjaer via openembedded-core <sean=geanix.com@lists.openembedded.org>
> >> Sent: den 17 november 2026 13:02
> >> To: openembedded-core@lists.openembedded.org
> >> Cc: Sean Nyekjaer <sean@geanix.com>
> >> Subject: [OE-core] [PATCH v2 2/3] license_image: don't apply INCOMPATIBLE_LICENSE to SDK host tools
> >>
> >> Since the SDK host and target sysroots are passed through
> >> write_license_files(), do_populate_sdk checks every nativesdk and
> >> cross-canadian package against the image's INCOMPATIBLE_LICENSE and
> >> fails, e.g. with INCOMPATIBLE_LICENSE = "GPL-3.0*":
> >>
> >>  Some packages cannot be installed into the image because they have
> >>  incompatible licenses:
> >>        nativesdk-autoconf (GPL-3.0-or-later)
> >>
> >> At parse time skip_incompatible_package_licenses() exempts these
> >> recipes, so they are built and packaged, and only the SDK manifest
> >> step rejects them. Use incompatible_license_check_needed() in
> >> write_license_files() too, so host tools in the SDK are treated the
> >> same way. Target packages in the image and in the SDK target sysroot
> >> are still checked.
> >>
> >> Fixes: f757ae4dadab ("license_image: extend to SDK coverage")
> >> AI-Generated: Claude Opus 5.5 (Claude Code)
> >> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> >> ---
> >> meta/classes-recipe/license_image.bbclass | 13 ++++++++++---
> >> 1 file changed, 10 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/meta/classes-recipe/license_image.bbclass b/meta/classes-recipe/license_image.bbclass
> >> index 7d00b1ae53..728db8ae3a 100644
> >> --- a/meta/classes-recipe/license_image.bbclass
> >> +++ b/meta/classes-recipe/license_image.bbclass
> >> @@ -128,16 +128,23 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs):
> >>
> >>             pkg_allow_licenses = oe.license.filter_pkg_license_list(pkg, allow_licenses)
> >>
> >> +            # Host tools in the SDK (nativesdk, cross-canadian) are not
> >> +            # subject to INCOMPATIBLE_LICENSE, same as at parse time.
> >> +            if oe.license.incompatible_license_check_needed(d, pkg_dic[pkg]["PN"]):
> >> +                pkg_bad_licenses = bad_licenses
> >> +            else:
> >> +                pkg_bad_licenses = []
> >> +
> >>             if node:
> >> -                if incompatible_licenses := oe.license.license_allowed(node, bad_licenses, pkg_allow_licenses):
> >> +                if incompatible_licenses := oe.license.license_allowed(node, pkg_bad_licenses, pkg_allow_licenses):
> >>                     incompatible_packages.append("%s (%s)" % (pkg, ' '.join(n.to_string() for n in incompatible_licenses)))
> >> -                elif incompatible_licenses := oe.license.license_allowed(node, bad_licenses, []):
> >> +                elif incompatible_licenses := oe.license.license_allowed(node, pkg_bad_licenses, []):
> >>                     oe.qa.handle_error('license-exception', "Including %s with incompatible license(s) %s into the image, because it has been allowed by exception list." %
> >>                                        (pkg, ' '.join(n.to_string() for n in incompatible_licenses)), d)
> >>
> >>             (pkg_dic[pkg]["LICENSE"], pkg_dic[pkg]["LICENSES"]) = \
> >>                 oe.license.manifest_licenses(d, pkg_dic[pkg]["LICENSE"],
> >> -                                             bad_licenses, pkg_allow_licenses)
> >> +                                             pkg_bad_licenses, pkg_allow_licenses)
> >>
> >>             if not "IMAGE_MANIFEST" in pkg_dic[pkg]:
> >>                 # Rootfs manifest
> >> --
> >> 2.56.0
> >
> > IANAL, but for the record, I believe you risk violating the (L)GPL-3 license
> > if you distribute an SDK after applying the above, and then do not comply
> > with the license requirements of the (L)GPL-3 license. And the whole point of
> > using INCOMPATIBLE_LICENSE = "*GPL-3.0*" in your configuration is to avoid this
> > risk.
> >
> > Since the GPL license is all about what you distribute, it does not matter if it
> > is target or native tools, you are *distributing* them all as part of the SDK.
> >
> > Thus I believe it is wrong to apply this, but if it is applied, it should be
> > opt-in, and come with a massive warning.
> >
> > //Peter
> >
> 
> Thanks for the review.
> 
> The problem is that until recently INCOMPATIBLE_LICENSE never covered the
> SDK. My build broke after commit f757ae4dadab ("license_image: extend to
> SDK coverage"), which started checking the SDK host and target sysroots
> in do_populate_sdk.
> 
> So "GPL-3.0*" has never given a GPLv3-free SDK.
> 
> The documentation also describes INCOMPATIBLE_LICENSE in terms of the
> build and images: it excludes licenses "from the build (if set
> globally), or from an image (if set locally in an image recipe)", and
> recommends setting it "in specific image recipes". I read "image" as the
> target image you deploy, not the SDK built from it. My customer has to
> keep GPLv3 out of the target image but is fine with GPLv3 in the SDK,
> which is exactly what worked before.
> 
> That said, I see the value of being able to check the SDK too. How about
> a separate variable, e.g. INCOMPATIBLE_LICENSE_SDK, that do_populate_sdk
> checks the SDK host packages against? Target packages in the SDK target
> sysroot would still be checked against INCOMPATIBLE_LICENSE, as with this
> series.
> 
> The open question is the default:
> - INCOMPATIBLE_LICENSE_SDK ?= "${INCOMPATIBLE_LICENSE}" keeps the
>   current master behaviour, and the rest of us have to opt out.
> 
> /Sean

The way we solved the above when the license check for the SDK was introduced 
was to add explicit exceptions for the nativesdk packages, e.g.:

AXIS_SDK_LICENSE_EXCEPTIONS += " \
    binutils-cross-canadian-${TRANSLATED_TARGET_ARCH}:GPL-3.0-only \
    elfutils-dev:GPL-3.0-or-later \
    gawk:GPL-3.0-or-later \
    gawk-dev:AGPL-3.0-or-later \
    gawk-dev:GPL-3.0-or-later \
    gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}:GPL-3.0-only \
    gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}:GPL-3.0-or-later \
    gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}:LGPL-3.0-or-later \
    gdb-cross-canadian-${TRANSLATED_TARGET_ARCH}:GPL-3.0-only \
    gdb-cross-canadian-${TRANSLATED_TARGET_ARCH}:LGPL-3.0-only \
    ...
"

We put them in a separate variable, which we only add to 
INCOMPATIBLE_LICENSE_EXCEPTIONS in the image recipe we use to build our SDK. 
That way the exceptions do not affect our normal images, but at the same 
time we have documented every tool and exception so that we can be sure to 
comply with their licenses.

//Peter
diff mbox series

Patch

diff --git a/meta/classes-recipe/license_image.bbclass b/meta/classes-recipe/license_image.bbclass
index 7d00b1ae53..728db8ae3a 100644
--- a/meta/classes-recipe/license_image.bbclass
+++ b/meta/classes-recipe/license_image.bbclass
@@ -128,16 +128,23 @@  def write_license_files(d, license_manifest, pkg_dic, rootfs):
 
             pkg_allow_licenses = oe.license.filter_pkg_license_list(pkg, allow_licenses)
 
+            # Host tools in the SDK (nativesdk, cross-canadian) are not
+            # subject to INCOMPATIBLE_LICENSE, same as at parse time.
+            if oe.license.incompatible_license_check_needed(d, pkg_dic[pkg]["PN"]):
+                pkg_bad_licenses = bad_licenses
+            else:
+                pkg_bad_licenses = []
+
             if node:
-                if incompatible_licenses := oe.license.license_allowed(node, bad_licenses, pkg_allow_licenses):
+                if incompatible_licenses := oe.license.license_allowed(node, pkg_bad_licenses, pkg_allow_licenses):
                     incompatible_packages.append("%s (%s)" % (pkg, ' '.join(n.to_string() for n in incompatible_licenses)))
-                elif incompatible_licenses := oe.license.license_allowed(node, bad_licenses, []):
+                elif incompatible_licenses := oe.license.license_allowed(node, pkg_bad_licenses, []):
                     oe.qa.handle_error('license-exception', "Including %s with incompatible license(s) %s into the image, because it has been allowed by exception list." %
                                        (pkg, ' '.join(n.to_string() for n in incompatible_licenses)), d)
 
             (pkg_dic[pkg]["LICENSE"], pkg_dic[pkg]["LICENSES"]) = \
                 oe.license.manifest_licenses(d, pkg_dic[pkg]["LICENSE"],
-                                             bad_licenses, pkg_allow_licenses)
+                                             pkg_bad_licenses, pkg_allow_licenses)
 
             if not "IMAGE_MANIFEST" in pkg_dic[pkg]:
                 # Rootfs manifest