]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
license_image.bbclass: report all packages with incompatible license
authorMartin Jansa <martin.jansa@gmail.com>
Thu, 5 Mar 2026 22:30:31 +0000 (23:30 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 9 Mar 2026 17:29:24 +0000 (17:29 +0000)
When multiple packages cannot be installed it shows only first one it
finds, because of bb.fatal use. It might require many iterations to find
all packages to avoid.

e.g. with ptest enabled and GPL-3.0-or-later, GPL-3.0-only set as
incompatible licenses you might get list like this for relatively small
image:

ERROR: image-1.0-r0 do_rootfs: Some packages cannot be installed into the image because they have incompatible licenses:
        bzip2-ptest (GPL-3.0-or-later)
        coreutils (GPL-3.0-or-later)
        coreutils-stdbuf (GPL-3.0-or-later)
        diffutils (GPL-3.0-or-later)
        findutils (GPL-3.0-or-later)
        gawk (GPL-3.0-or-later)
        gnutls-openssl (GPL-3.0-or-later)
        gnutls-ptest (GPL-3.0-or-later)
        grep (GPL-3.0-only)
        make (GPL-3.0-only)
        mpfr (LGPL-3.0-or-later)
        python3-dbusmock (GPL-3.0-only)
        readline (GPL-3.0-or-later)
        sed (GPL-3.0-or-later)

Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/license_image.bbclass
meta/lib/oeqa/selftest/cases/incompatible_lic.py

index 8332905da5ad9e3257b885016f2c573007cf3a7d..95e0a9ba2e04971fd8416567363af7077d9517e5 100644 (file)
@@ -116,6 +116,7 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs):
     bad_licenses = oe.license.expand_wildcard_licenses(d, bad_licenses)
     pkgarchs = d.getVar("SSTATE_ARCHS").split()
     pkgarchs.reverse()
+    incompatible_packages = []
 
     exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
     with open(license_manifest, "w") as license_file:
@@ -123,7 +124,7 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs):
             remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
             incompatible_licenses = oe.license.incompatible_pkg_license(d, remaining_bad_licenses, pkg_dic[pkg]["LICENSE"])
             if incompatible_licenses:
-                bb.fatal("Package %s cannot be installed into the image because it has incompatible license(s): %s" %(pkg, ' '.join(incompatible_licenses)))
+                incompatible_packages.append("%s (%s)" % (pkg, ' '.join(incompatible_licenses)))
             else:
                 incompatible_licenses = oe.license.incompatible_pkg_license(d, bad_licenses, pkg_dic[pkg]["LICENSE"])
                 if incompatible_licenses:
@@ -171,6 +172,9 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs):
                                        "The license listed %s was not in the "\
                                        "licenses collected for recipe %s"
                                        % (lic, pkg_dic[pkg]["PN"]), d)
+    if incompatible_packages:
+        bb.fatal("Some packages cannot be installed into the image because they have incompatible licenses:\n\t%s" % ("\n\t".join(incompatible_packages)))
+
     oe.qa.exit_if_errors(d)
 
     # Two options here:
index 93884f573193564f61ed60e045675d886e7934df..1395e5d13765bd9f86c08b3331202038d3138143 100644 (file)
@@ -107,7 +107,7 @@ MACHINE_ESSENTIAL_EXTRA_RDEPENDS:remove = "tar"
 
     def test_bash_default(self):
         self.write_config(self.default_config())
-        error_msg = "ERROR: core-image-minimal-1.0-r0 do_rootfs: Package bash cannot be installed into the image because it has incompatible license(s): GPL-3.0-or-later"
+        error_msg = "ERROR: core-image-minimal-1.0-r0 do_rootfs: Some packages cannot be installed into the image because they have incompatible licenses:\n\tbash (GPL-3.0-or-later)"
 
         result = bitbake('core-image-minimal', ignore_status=True)
         if error_msg not in result.output:
@@ -116,7 +116,7 @@ MACHINE_ESSENTIAL_EXTRA_RDEPENDS:remove = "tar"
     def test_bash_and_license(self):
         self.disable_class("create-spdx")
         self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " & SomeLicense"\nERROR_QA:remove:pn-bash = "license-exists"')
-        error_msg = "ERROR: core-image-minimal-1.0-r0 do_rootfs: Package bash cannot be installed into the image because it has incompatible license(s): GPL-3.0-or-later"
+        error_msg = "ERROR: core-image-minimal-1.0-r0 do_rootfs: Some packages cannot be installed into the image because they have incompatible licenses:\n\tbash (GPL-3.0-or-later)"
 
         result = bitbake('core-image-minimal', ignore_status=True)
         if error_msg not in result.output: