diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2019-12-11 17:48:17 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-16 23:25:50 +0000 |
commit | 5560c50316a8b2d47c4fcb51cf12ef473079ff54 (patch) | |
tree | 04b167f8ec722197083d92cdd53d477bee93bf4f | |
parent | 4028227713e5453860f0918c64388357f71d0456 (diff) | |
download | poky-5560c50316a8b2d47c4fcb51cf12ef473079ff54.tar.gz |
base.bbclass: Report only the licenses that are incompatible for a package
Instead of reporting ${LICENSE} when a package is identified as using
an incompatible license, report the license(s) that are actually
incompatible.
(From OE-Core rev: fb3405fac7b933a3f9d23e5faf6a3cf2d1990982)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/base.bbclass | 26 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/incompatible_lic.py | 6 |
2 files changed, 19 insertions, 13 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index a3170d219c..145daea3ec 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass | |||
@@ -542,24 +542,30 @@ python () { | |||
542 | bb.note("Including %s as buildable despite it having an incompatible license because it has been whitelisted" % pn) | 542 | bb.note("Including %s as buildable despite it having an incompatible license because it has been whitelisted" % pn) |
543 | else: | 543 | else: |
544 | pkgs = d.getVar('PACKAGES').split() | 544 | pkgs = d.getVar('PACKAGES').split() |
545 | skipped_pkgs = [] | 545 | skipped_pkgs = {} |
546 | unskipped_pkgs = [] | 546 | unskipped_pkgs = [] |
547 | for pkg in pkgs: | 547 | for pkg in pkgs: |
548 | if incompatible_license(d, bad_licenses, pkg): | 548 | incompatible_lic = incompatible_license(d, bad_licenses, pkg) |
549 | skipped_pkgs.append(pkg) | 549 | if incompatible_lic: |
550 | skipped_pkgs[pkg] = incompatible_lic | ||
550 | else: | 551 | else: |
551 | unskipped_pkgs.append(pkg) | 552 | unskipped_pkgs.append(pkg) |
552 | all_skipped = skipped_pkgs and not unskipped_pkgs | ||
553 | if unskipped_pkgs: | 553 | if unskipped_pkgs: |
554 | for pkg in skipped_pkgs: | 554 | for pkg in skipped_pkgs: |
555 | bb.debug(1, "SKIPPING the package " + pkg + " at do_rootfs because it's " + license) | 555 | bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg]))) |
556 | mlprefix = d.getVar('MLPREFIX') | 556 | mlprefix = d.getVar('MLPREFIX') |
557 | d.setVar('LICENSE_EXCLUSION-' + mlprefix + pkg, 1) | 557 | d.setVar('LICENSE_EXCLUSION-' + mlprefix + pkg, ' '.join(skipped_pkgs[pkg])) |
558 | for pkg in unskipped_pkgs: | 558 | for pkg in unskipped_pkgs: |
559 | bb.debug(1, "INCLUDING the package " + pkg) | 559 | bb.debug(1, "Including the package %s" % pkg) |
560 | elif all_skipped or incompatible_license(d, bad_licenses): | 560 | else: |
561 | bb.debug(1, "SKIPPING recipe %s because it's %s" % (pn, license)) | 561 | incompatible_lic = incompatible_license(d, bad_licenses) |
562 | raise bb.parse.SkipRecipe("it has an incompatible license: %s" % license) | 562 | for pkg in skipped_pkgs: |
563 | incompatible_lic += skipped_pkgs[pkg] | ||
564 | incompatible_lic = sorted(list(set(incompatible_lic))) | ||
565 | |||
566 | if incompatible_lic: | ||
567 | bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic))) | ||
568 | raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic)) | ||
563 | 569 | ||
564 | # Try to verify per-package (LICENSE_<pkg>) values. LICENSE should be a | 570 | # Try to verify per-package (LICENSE_<pkg>) values. LICENSE should be a |
565 | # superset of all per-package licenses. We do not do advanced (pattern) | 571 | # superset of all per-package licenses. We do not do advanced (pattern) |
diff --git a/meta/lib/oeqa/selftest/cases/incompatible_lic.py b/meta/lib/oeqa/selftest/cases/incompatible_lic.py index ad878571b5..9d1e801117 100644 --- a/meta/lib/oeqa/selftest/cases/incompatible_lic.py +++ b/meta/lib/oeqa/selftest/cases/incompatible_lic.py | |||
@@ -4,7 +4,7 @@ from oeqa.utils.commands import bitbake | |||
4 | class IncompatibleLicenseTests(OESelftestTestCase): | 4 | class IncompatibleLicenseTests(OESelftestTestCase): |
5 | 5 | ||
6 | def lic_test(self, pn, pn_lic, lic): | 6 | def lic_test(self, pn, pn_lic, lic): |
7 | error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has an incompatible license: %s' % (pn, pn, pn_lic) | 7 | error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has incompatible license(s): %s' % (pn, pn, pn_lic) |
8 | 8 | ||
9 | self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic)) | 9 | self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic)) |
10 | 10 | ||
@@ -27,12 +27,12 @@ class IncompatibleLicenseTests(OESelftestTestCase): | |||
27 | # license cannot be built when INCOMPATIBLE_LICENSE contains this SPDX | 27 | # license cannot be built when INCOMPATIBLE_LICENSE contains this SPDX |
28 | # license | 28 | # license |
29 | def test_incompatible_spdx_license_alias(self): | 29 | def test_incompatible_spdx_license_alias(self): |
30 | self.lic_test('incompatible-license-alias', 'GPLv3', 'GPL-3.0') | 30 | self.lic_test('incompatible-license-alias', 'GPL-3.0', 'GPL-3.0') |
31 | 31 | ||
32 | # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX | 32 | # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX |
33 | # license cannot be built when INCOMPATIBLE_LICENSE contains this alias | 33 | # license cannot be built when INCOMPATIBLE_LICENSE contains this alias |
34 | def test_incompatible_alias_spdx_license_alias(self): | 34 | def test_incompatible_alias_spdx_license_alias(self): |
35 | self.lic_test('incompatible-license-alias', 'GPLv3', 'GPLv3') | 35 | self.lic_test('incompatible-license-alias', 'GPL-3.0', 'GPLv3') |
36 | 36 | ||
37 | # Verify that a package with a non-SPDX license (neither in | 37 | # Verify that a package with a non-SPDX license (neither in |
38 | # AVAILABLE_LICENSES nor in SPDXLICENSEMAP) cannot be built when | 38 | # AVAILABLE_LICENSES nor in SPDXLICENSEMAP) cannot be built when |