diff options
| author | Joshua Watt <JPEWhacker@gmail.com> | 2025-11-07 14:14:39 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-11-14 06:45:29 -0800 |
| commit | 8f0eab43edc4f2a3e74cd30903c5e5718cc1186c (patch) | |
| tree | 70355c622d7e9bcd30347bc9b9e36063cf9a82ec /meta | |
| parent | 2cab0b98338b09daf3baf35dc30bfb232a85c4c8 (diff) | |
| download | poky-8f0eab43edc4f2a3e74cd30903c5e5718cc1186c.tar.gz | |
lib/license: Move package license skip to library
Moves the code that skips packages with incompatible licenses to the
library code so that it can be called in other locations
(From OE-Core rev: 4f7a047c4a1e14bbb3bf593764aace1e25bcd4a4)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 86eb409e3c1b30110869ec5a0027ae2d48bbfe7f)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/classes-global/base.bbclass | 35 | ||||
| -rw-r--r-- | meta/lib/oe/license.py | 39 |
2 files changed, 43 insertions, 31 deletions
diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass index f764f3ee2f..ecf0fd711f 100644 --- a/meta/classes-global/base.bbclass +++ b/meta/classes-global/base.bbclass | |||
| @@ -565,37 +565,10 @@ python () { | |||
| 565 | 565 | ||
| 566 | bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split() | 566 | bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split() |
| 567 | 567 | ||
| 568 | check_license = False if pn.startswith("nativesdk-") else True | 568 | pkgs = d.getVar('PACKAGES').split() |
| 569 | for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}", | 569 | if pkgs: |
| 570 | "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}", | 570 | skipped_pkgs = oe.license.skip_incompatible_package_licenses(d, pkgs) |
| 571 | "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]: | 571 | unskipped_pkgs = [p for p in pkgs if p not in skipped_pkgs] |
| 572 | if pn.endswith(d.expand(t)): | ||
| 573 | check_license = False | ||
| 574 | if pn.startswith("gcc-source-"): | ||
| 575 | check_license = False | ||
| 576 | |||
| 577 | if check_license and bad_licenses: | ||
| 578 | bad_licenses = oe.license.expand_wildcard_licenses(d, bad_licenses) | ||
| 579 | |||
| 580 | exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split() | ||
| 581 | |||
| 582 | for lic_exception in exceptions: | ||
| 583 | if ":" in lic_exception: | ||
| 584 | lic_exception = lic_exception.split(":")[1] | ||
| 585 | if lic_exception in oe.license.obsolete_license_list(): | ||
| 586 | bb.fatal("Obsolete license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception) | ||
| 587 | |||
| 588 | pkgs = d.getVar('PACKAGES').split() | ||
| 589 | skipped_pkgs = {} | ||
| 590 | unskipped_pkgs = [] | ||
| 591 | for pkg in pkgs: | ||
| 592 | remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions) | ||
| 593 | |||
| 594 | incompatible_lic = oe.license.incompatible_license(d, remaining_bad_licenses, pkg) | ||
| 595 | if incompatible_lic: | ||
| 596 | skipped_pkgs[pkg] = incompatible_lic | ||
| 597 | else: | ||
| 598 | unskipped_pkgs.append(pkg) | ||
| 599 | 572 | ||
| 600 | if unskipped_pkgs: | 573 | if unskipped_pkgs: |
| 601 | for pkg in skipped_pkgs: | 574 | for pkg in skipped_pkgs: |
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py index 83c2e47766..c1ae103b54 100644 --- a/meta/lib/oe/license.py +++ b/meta/lib/oe/license.py | |||
| @@ -422,3 +422,42 @@ def check_license_format(d): | |||
| 422 | '%s: LICENSE value "%s" has an invalid separator "%s" that is not ' \ | 422 | '%s: LICENSE value "%s" has an invalid separator "%s" that is not ' \ |
| 423 | 'in the valid list of separators (%s)' % | 423 | 'in the valid list of separators (%s)' % |
| 424 | (pn, licenses, element, license_operator_chars), d) | 424 | (pn, licenses, element, license_operator_chars), d) |
| 425 | |||
| 426 | def skip_incompatible_package_licenses(d, pkgs): | ||
| 427 | if not pkgs: | ||
| 428 | return {} | ||
| 429 | |||
| 430 | pn = d.getVar("PN") | ||
| 431 | |||
| 432 | check_license = False if pn.startswith("nativesdk-") else True | ||
| 433 | for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}", | ||
| 434 | "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}", | ||
| 435 | "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]: | ||
| 436 | if pn.endswith(d.expand(t)): | ||
| 437 | check_license = False | ||
| 438 | if pn.startswith("gcc-source-"): | ||
| 439 | check_license = False | ||
| 440 | |||
| 441 | bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split() | ||
| 442 | if not check_license or not bad_licenses: | ||
| 443 | return {} | ||
| 444 | |||
| 445 | bad_licenses = expand_wildcard_licenses(d, bad_licenses) | ||
| 446 | |||
| 447 | exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split() | ||
| 448 | |||
| 449 | for lic_exception in exceptions: | ||
| 450 | if ":" in lic_exception: | ||
| 451 | lic_exception = lic_exception.split(":")[1] | ||
| 452 | if lic_exception in obsolete_license_list(): | ||
| 453 | bb.fatal("Obsolete license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception) | ||
| 454 | |||
| 455 | skipped_pkgs = {} | ||
| 456 | for pkg in pkgs: | ||
| 457 | remaining_bad_licenses = apply_pkg_license_exception(pkg, bad_licenses, exceptions) | ||
| 458 | |||
| 459 | incompatible_lic = incompatible_license(d, remaining_bad_licenses, pkg) | ||
| 460 | if incompatible_lic: | ||
| 461 | skipped_pkgs[pkg] = incompatible_lic | ||
| 462 | |||
| 463 | return skipped_pkgs | ||
