meta: license: fix non-SPDX license being removed from INCOMPATIBLE_LICENSE
PATCH v3 1/1 meta: license: fix non-SPDX license being removed from INCOMPATIBLE_LICENSE
A non-SPDX license (which is not an alias to an SPDX license) cannot currently be marked as incompatible in INCOMPATIBLE_LICENSE. In the current state, we take all INCOMPATIBLE_LICENSE and pass them through expand_wildcard_licenses which is only adding SPDX licenses that match the glob regexp of what is in INCOMPATIBLE_LICENSE (be it a direct match to an SPDX license or via an alias).
This does not work well with custom licenses.
E.g.:
foo.bb:
LICENSE = "FooLicense"
conf/local.conf:INCOMPATIBLE_LICENSE = "FooLicense"
bitbake foo
Gives no warning, no error, builds and packages successfully, because INCOMPATIBLE_LICENSE is basically empty since FooLicense is neither in SPDXLICENSEMAP nor in SRC_DISTRIBUTE_LICENSES.
Let's add the original licenses to the list returned by expand_wildcard_licenses to be able to handle the aforementioned case.
INCOMPATIBLE_LICENSE = "FooLicense GPLv2 GPLv3+" used to "resolve" to "GPLv2 GPLv3". It now resolves to "FooLicense GPLv2 GPLv3 GPLv3+" which fixes the issue with custom licenses not being in SPDXLICENSEMAP or SRC_DISTRIBUTE_LICENSES and thus being left out of the blacklisted licenses.
I needed to pass a list to expand_wildcard_licenses from the license_image class instead of the current output of map() because the operator [:] does not work on this kind of type, and list(map()) or anything that iterates over map() actually moves the iterator and breaks the forloop right after in expand_wildcard_licenses.
---
v3:
- fix git context from v2, patch cleanly applies on master branch now,
v2:
- fixed image building by replacing map(lambda) by a comprehensive list so
that we have a consistent input type for expand_wildcard_licenses,
meta/classes/license.bbclass | 2 +- meta/classes/license_image.bbclass | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
meta/classes/license.bbclass +1 -1
@@ -268,7 +268,7 @@ def expand_wildcard_licenses(d, wildcard_licenses): wildcards from SPDXLICENSEMAP flags and SRC_DISTRIBUTE_LICENSES values. """ import fnmatch - licenses = [] + licenses = wildcard_licenses[:] spdxmapkeys = d.getVarFlags('SPDXLICENSEMAP').keys() for wld_lic in wildcard_licenses: spdxflags = fnmatch.filter(spdxmapkeys, wld_lic)
meta/classes/license_image.bbclass +1 -1
@@ -40,7 +40,7 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs=True): import stat bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split() - bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses) + bad_licenses = [canonical_license(d, l) for l in bad_licenses] bad_licenses = expand_wildcard_licenses(d, bad_licenses) with open(license_manifest, "w") as license_file:
Signature · 1 line
2.17.1
What would be really useful is a small selftest (meta/lib/oeqa/selftest/cases) to exercise this codepath. Have a test that should work but doesn't before the fix, so the bug is demonstrated and verified.
Ross
Quoted 87 lines · Quentin Schulz
A non-SPDX license (which is not an alias to an SPDX license) cannot currently be marked as incompatible in
INCOMPATIBLE_LICENSE. In the current state, we take allINCOMPATIBLE_LICENSEand pass them throughexpand_wildcard_licenseswhich is only adding SPDX licenses that match the glob regexp of what is inINCOMPATIBLE_LICENSE(be it a direct match to an SPDX license or via an alias).This does not work well with custom licenses.
E.g.:
foo.bb:
LICENSE = "FooLicense"
conf/local.conf:INCOMPATIBLE_LICENSE= "FooLicense"
bitbake fooGives no warning, no error, builds and packages successfully, because
INCOMPATIBLE_LICENSEis basically empty since FooLicense is neither in SPDXLICENSEMAP nor inSRC_DISTRIBUTE_LICENSES.Let's add the original licenses to the list returned by
expand_wildcard_licensesto be able to handle the aforementioned case.
INCOMPATIBLE_LICENSE= "FooLicense GPLv2 GPLv3+" used to "resolve" to "GPLv2 GPLv3". It now resolves to "FooLicense GPLv2 GPLv3 GPLv3+" which fixes the issue with custom licenses not being in SPDXLICENSEMAP orSRC_DISTRIBUTE_LICENSESand thus being left out of the blacklisted licenses.I needed to pass a list to
expand_wildcard_licensesfrom thelicense_imageclass instead of the current output ofmap()because the operator [:] does not work on this kind of type, and list(map()) or anything that iterates overmap()actually moves the iterator and breaks the forloop right after inexpand_wildcard_licenses.Signed-off-by Quentin Schulz <[email protected]>---
v3:
- fix git context from v2, patch cleanly applies on master branch now,v2:
- fixed image building by replacing map(lambda) by a comprehensive list so
that we have a consistent input type forexpand_wildcard_licenses,meta/classes/license.bbclass | 2 +- meta/classes/license_image.bbclass | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)meta/classes/license.bbclass +1
-1@@ -268,7 +268,7 @@ def expand_wildcard_licenses(d, wildcard_licenses): wildcards from SPDXLICENSEMAP flags and SRC_DISTRIBUTE_LICENSES values. """ import fnmatch - licenses = [] + licenses = wildcard_licenses[:] spdxmapkeys = d.getVarFlags('SPDXLICENSEMAP').keys() for wld_lic in wildcard_licenses: spdxflags = fnmatch.filter(spdxmapkeys, wld_lic)meta/classes/license_image.bbclass +1
-2@@ -40,7 +40,7 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs=True): import stat bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split() - bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses) + bad_licenses = [canonical_license(d, l) for l in bad_licenses] bad_licenses = expand_wildcard_licenses(d, bad_licenses) with open(license_manifest, "w") as license_file: --2.17.1
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core