diff mbox series

[RFC,1/2] license.py: Add available_licenses()

Message ID 20240210111451.2112513-1-pkj@axis.com
State New
Headers show
Series [RFC,1/2] license.py: Add available_licenses() | expand

Commit Message

Peter Kjellerstedt Feb. 10, 2024, 11:14 a.m. UTC
This function returns the available licenses by searching the
directories specified by COMMON_LICENSE_DIR and LICENSE_PATH.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---

This is the same function that was removed from OE-Core in commit
aa662aae352c65cb5d13172bf98ed4ae3cb46c26 as there were no longer any
users of it then.

 meta/lib/oe/license.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index d9c8d94da4..7683bed624 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -259,3 +259,17 @@  def apply_pkg_license_exception(pkg, bad_licenses, exceptions):
     """Return remaining bad licenses after removing any package exceptions"""
 
     return [lic for lic in bad_licenses if pkg + ':' + lic not in exceptions]
+
+def available_licenses(d):
+    """
+    Return the available licenses by searching the directories specified by
+    COMMON_LICENSE_DIR and LICENSE_PATH.
+    """
+    lic_dirs = ((d.getVar('COMMON_LICENSE_DIR') or '') + ' ' +
+                (d.getVar('LICENSE_PATH') or '')).split()
+
+    licenses = set()
+    for lic_dir in lic_dirs:
+        licenses.update(os.listdir(lic_dir))
+
+    return licenses