Skip to contentSkip to conversation

meta: license: fix non-SPDX license being removed from INCOMPATIBLE_LICENSE

PATCH In review Quentin Schulz 3 participants 10 messages Jun 11, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 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
index ed91a4b4db..adca881c85 100644
@@ -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
index 6fb76be48e..2cfda81c99 100644
@@ -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
#1 lore raw

PATCH v4 2/2 selftests: add tests for INCOMPATIBLE_LICENSE

One bug went unnoticed without these selftests: an INCOMPATIBLE_LICENSE with a non-SPDX license for a package with that non-SPDX license wasn't enforcing the denial of build for said package.

While adding a test for that particular case, let's add a few more so that we cover a handful more use cases of INCOMPATIBLE_LICENSE.

---

added in v4

 .../license/incompatible-license-alias.bb     |  3 ++
 .../license/incompatible-license.bb           |  3 ++
 .../license/incompatible-nonspdx-license.bb   |  3 ++
 .../oeqa/selftest/cases/incompatible_lic.py   | 42 +++++++++++++++++++
 4 files changed, 51 insertions(+)
 create mode 100644 meta-selftest/recipes-test/license/incompatible-license-alias.bb
 create mode 100644 meta-selftest/recipes-test/license/incompatible-license.bb
 create mode 100644 meta-selftest/recipes-test/license/incompatible-nonspdx-license.bb
 create mode 100644 meta/lib/oeqa/selftest/cases/incompatible_lic.py
meta-selftest/recipes-test/license/incompatible-license-alias.bb new file +3 -0
new file mode 100644
index 0000000000..e0b4e13c26
@@ -0,0 +1,3 @@
+SUMMARY = "Recipe with an alias of an SPDX license"
+DESCRIPTION = "Is licensed with an alias of an SPDX license to be used for testing"
+LICENSE = "GPLv3"
meta-selftest/recipes-test/license/incompatible-license.bb new file +3 -0
new file mode 100644
index 0000000000..1728ad76b7
@@ -0,0 +1,3 @@
+SUMMARY = "Recipe with an SPDX license"
+DESCRIPTION = "Is licensed with an SPDX license to be used for testing"
+LICENSE = "GPL-3.0"
meta-selftest/recipes-test/license/incompatible-nonspdx-license.bb new file +3 -0
new file mode 100644
index 0000000000..35af0966ef
@@ -0,0 +1,3 @@
+SUMMARY = "Recipe with a non-SPDX license"
+DESCRIPTION = "Is licensed with a non-SPDX license to be used for testing"
+LICENSE = "FooLicense"
meta/lib/oeqa/selftest/cases/incompatible_lic.py new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v4 2/2] selftests: add tests for INCOMPATIBLE_LICENSE

Quoted 1 line · Quentin Schulz

+from oeqa.core.decorator.oeid import OETestID

This was removed a while ago, can you rebase the patches on top of master please?

In this case you can just remove the import, but please verify the behaviour with master.

Ross

#3 lore raw

Re: [PATCH v4 2/2] selftests: add tests for INCOMPATIBLE_LICENSE

Hi Ross,

Quoted 10 lines · Ross
Quoted 1 line · Quentin Schulz

+from oeqa.core.decorator.oeid import OETestID

This was removed a while ago, can you rebase the patches on top of master please?

In this case you can just remove the import, but please verify the behaviour with master.

Sorry for the noise, apparently forgot to pull master and didn't even see my patch was already there *sigh*.

I'll remove the import and test on master with and without the patch you already merged.

Do you want me to send a v5 or a separate patch series is better for you?

Quentin

Signature · 3 lines
StreamUnlimited Engineering GmbH
High Tech Campus Vienna, Gutheil-Schoder-Gasse 10, 1100 Vienna, Austria
[email protected], www.streamunlimited.com
#4 lore raw

Re: [PATCH v4 2/2] selftests: add tests for INCOMPATIBLE_LICENSE

Quoted 8 lines · Quentin Schulz

Sorry for the noise, apparently forgot to pull master and didn't even see my patch was already there *sigh*.

I'll remove the import and test on master with and without the patch you already merged.

Do you want me to send a v5 or a separate patch series is better for you?

Either is fine. Note that in the broken case - where the recipe isn't skipped - the test goes ahead and compiles stuff. Can you also try using --dry-run to see if that results in the same test behaviour, but without attempting compilation.

Ross

#5 lore raw

Re: [PATCH v4 2/2] selftests: add tests for INCOMPATIBLE_LICENSE

Quoted 4 lines · Ross

Either is fine. Note that in the broken case - where the recipe isn't skipped - the test goes ahead and compiles stuff. Can you also try using --dry-run to see if that results in the same test behaviour, but without attempting compilation.

FWIW:

- result = bitbake(pn, ignore_status=True)
+ result = bitbake("%s --dry-run" % pn, ignore_status=True)

Still results in the nonspdx case failing as expected without the fix, but without any compilation attempted.

Ross

#6 lore raw

Re: [PATCH v4 2/2] selftests: add tests for INCOMPATIBLE_LICENSE

In reply to Quentin Schulz
Quoted 14 lines · Quentin Schulz

Hi Ross,

Quoted 10 lines · Ross
Quoted 1 line · Quentin Schulz

+from oeqa.core.decorator.oeid import OETestID

This was removed a while ago, can you rebase the patches on top of master please?

In this case you can just remove the import, but please verify the behaviour with master.

Quoted 9 lines

Sorry for the noise, apparently forgot to pull master and didn't even see my patch was already there *sigh*.

I'll remove the import and test on master with and without the patch you already merged.

Do you want me to send a v5 or a separate patch series is better for you?

Also, I factored out everything into a function that shouldn't be run as a test but when doing:
oe-selftest --run-tests incompatible_lic.IncompatibleLicenseTests it tries to run the function and thus fails the test. Is that okay? if not, how do you usually proceed?

Quentin

#7 lore raw

Re: [PATCH v4 2/2] selftests: add tests for INCOMPATIBLE_LICENSE

Quoted 5 lines · Quentin Schulz

Also, I factored out everything into a function that shouldn't be run as a test but when doing:
oe-selftest --run-tests incompatible_lic.IncompatibleLicenseTests it tries to run the function and thus fails the test. Is that okay? if not, how do you usually proceed?

So Python unittest's behaviour is that any function called test_*() is a test case and is executed, so just don't name any helper functions like this test_*.

Ross

#8 lore raw

Re: [PATCH v4 2/2] selftests: add tests for INCOMPATIBLE_LICENSE

Quoted 8 lines · Ross
Quoted 5 lines · Quentin Schulz

Also, I factored out everything into a function that shouldn't be run as a test but when doing:
oe-selftest --run-tests incompatible_lic.IncompatibleLicenseTests it tries to run the function and thus fails the test. Is that okay? if not, how do you usually proceed?

Quoted 4 lines

So Python unittest's behaviour is that any function called test_*() is a test case and is executed, so just don't name any helper functions like this test_*.

Ah, that's what I was missing. Thanks.

Quentin

Signature · 3 lines
StreamUnlimited Engineering GmbH
High Tech Campus Vienna, Gutheil-Schoder-Gasse 10, 1100 Vienna, Austria
[email protected], www.streamunlimited.com
#9 lore raw

✗ patchtest: failure for "[v4] meta: license: fix non-SP..." and 1 more

In reply to Quentin Schulz

== Series Details ==

Series: "[v4] meta: license: fix non-SP..." and 1 more
Revision: 1
URL : https://patchwork.openembedded.org/series/18087/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at f79c95f6a8)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe