From: Joshua Watt <jpewhacker@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Joshua Watt <JPEWhacker@gmail.com>
Subject: [OE-core][PATCH v3 2/4] lib: license: Move package license skip to library
Date: Thu, 24 Oct 2024 13:03:08 -0600 [thread overview]
Message-ID: <20241024190438.3630946-3-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20241024190438.3630946-1-JPEWhacker@gmail.com>
Moves the code that skips packages with incompatible licenses to the
library code so that it can be called in other locations
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
meta/classes-global/base.bbclass | 35 ++++------------------------
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 88b932fc3f0..5b8663f454d 100644
--- a/meta/classes-global/base.bbclass
+++ b/meta/classes-global/base.bbclass
@@ -573,37 +573,10 @@ python () {
bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split()
- check_license = False if pn.startswith("nativesdk-") else True
- for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}",
- "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}",
- "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]:
- if pn.endswith(d.expand(t)):
- check_license = False
- if pn.startswith("gcc-source-"):
- check_license = False
-
- if check_license and bad_licenses:
- bad_licenses = oe.license.expand_wildcard_licenses(d, bad_licenses)
-
- exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
-
- for lic_exception in exceptions:
- if ":" in lic_exception:
- lic_exception = lic_exception.split(":")[1]
- if lic_exception in oe.license.obsolete_license_list():
- bb.fatal("Obsolete license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception)
-
- pkgs = d.getVar('PACKAGES').split()
- skipped_pkgs = {}
- unskipped_pkgs = []
- for pkg in pkgs:
- remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
-
- incompatible_lic = oe.license.incompatible_license(d, remaining_bad_licenses, pkg)
- if incompatible_lic:
- skipped_pkgs[pkg] = incompatible_lic
- else:
- unskipped_pkgs.append(pkg)
+ pkgs = d.getVar('PACKAGES').split()
+ if pkgs:
+ skipped_pkgs = oe.license.skip_incompatible_package_licenses(d, pkgs)
+ unskipped_pkgs = [p for p in pkgs if p not in skipped_pkgs]
if unskipped_pkgs:
for pkg in skipped_pkgs:
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 7739697c401..32c77fa204d 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -422,3 +422,42 @@ def check_license_format(d):
'%s: LICENSE value "%s" has an invalid separator "%s" that is not ' \
'in the valid list of separators (%s)' %
(pn, licenses, element, license_operator_chars), d)
+
+def skip_incompatible_package_licenses(d, pkgs):
+ if not pkgs:
+ return {}
+
+ pn = d.getVar("PN")
+
+ check_license = False if pn.startswith("nativesdk-") else True
+ for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}",
+ "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}",
+ "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]:
+ if pn.endswith(d.expand(t)):
+ check_license = False
+ if pn.startswith("gcc-source-"):
+ check_license = False
+
+ bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split()
+ if not check_license or not bad_licenses:
+ return {}
+
+ bad_licenses = expand_wildcard_licenses(d, bad_licenses)
+
+ exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
+
+ for lic_exception in exceptions:
+ if ":" in lic_exception:
+ lic_exception = lic_exception.split(":")[1]
+ if lic_exception in obsolete_license_list():
+ bb.fatal("Obsolete license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception)
+
+ skipped_pkgs = {}
+ for pkg in pkgs:
+ remaining_bad_licenses = apply_pkg_license_exception(pkg, bad_licenses, exceptions)
+
+ incompatible_lic = incompatible_license(d, remaining_bad_licenses, pkg)
+ if incompatible_lic:
+ skipped_pkgs[pkg] = incompatible_lic
+
+ return skipped_pkgs
--
2.46.2
next prev parent reply other threads:[~2024-10-24 19:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 21:59 [OE-core][PATCH 0/4] Incompatible license handling fixes Joshua Watt
2024-10-18 21:59 ` [OE-core][PATCH 1/4] classes-global/license: Move functions to library code Joshua Watt
2024-10-18 21:59 ` [OE-core][PATCH 2/4] lib: license: Move package license skip to library Joshua Watt
2024-10-18 21:59 ` [OE-core][PATCH 3/4] lib: package: Check for incompatible licenses in locale packages Joshua Watt
2024-10-18 21:59 ` [OE-core][PATCH 4/4] lib: package: Copy locale license Joshua Watt
2024-10-23 21:15 ` [OE-core][PATCH v2 0/4] Incompatible Licenses in Dynamic Packages Joshua Watt
2024-10-23 21:15 ` [OE-core][PATCH v2 1/4] classes-global/license: Move functions to library code Joshua Watt
2024-10-23 21:15 ` [OE-core][PATCH v2 2/4] lib: license: Move package license skip to library Joshua Watt
2024-10-23 23:38 ` Peter Kjellerstedt
[not found] ` <1801394EB093B1DD.16325@lists.openembedded.org>
2024-10-24 2:16 ` Peter Kjellerstedt
2024-10-23 21:15 ` [OE-core][PATCH v2 3/4] lib: package: Check incompatible licenses at packaging time Joshua Watt
2024-10-24 2:24 ` Peter Kjellerstedt
2024-10-24 10:02 ` Peter Kjellerstedt
2024-10-24 15:57 ` Joshua Watt
2024-10-23 21:15 ` [OE-core][PATCH v2 4/4] lib: package: Copy locale license Joshua Watt
2024-10-24 19:03 ` [OE-core][PATCH v3 0/4] Incompatible Licenses in Dynamic Packages Joshua Watt
2024-10-24 19:03 ` [OE-core][PATCH v3 1/4] classes-global/license: Move functions to library code Joshua Watt
2024-10-24 19:03 ` Joshua Watt [this message]
2024-10-24 19:03 ` [OE-core][PATCH v3 3/4] lib: package: Check incompatible licenses at packaging time Joshua Watt
2024-10-24 19:03 ` [OE-core][PATCH v3 4/4] lib: package: Copy locale license Joshua Watt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241024190438.3630946-3-JPEWhacker@gmail.com \
--to=jpewhacker@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox