summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create.py
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2025-06-27 14:48:46 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-07-01 08:49:37 +0100
commit72486700fb17153bb777a1fdf4abeb6d249a2657 (patch)
tree133321c208f4211ead19d6ac34e804bb8fad4a9a /scripts/lib/recipetool/create.py
parent90cc27f8ce15f2b51de95aa3b6628516030349ee (diff)
downloadpoky-72486700fb17153bb777a1fdf4abeb6d249a2657.tar.gz
oe/licenses: move tidy_licenses from recipetool
This function, to tidy a license string, is useful outside of recipetool so move it to oe.license. (From OE-Core rev: 9d57b53169bc60b281510c49e54123941a17a8f5) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/recipetool/create.py')
-rw-r--r--scripts/lib/recipetool/create.py11
1 files changed, 1 insertions, 10 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 5d7fcbbb98..ef0ba974a9 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -18,6 +18,7 @@ from urllib.parse import urlparse, urldefrag, urlsplit
18import hashlib 18import hashlib
19import bb.fetch2 19import bb.fetch2
20logger = logging.getLogger('recipetool') 20logger = logging.getLogger('recipetool')
21from oe.license import tidy_licenses
21from oe.license_finder import find_licenses 22from oe.license_finder import find_licenses
22 23
23tinfoil = None 24tinfoil = None
@@ -950,16 +951,6 @@ def fixup_license(value):
950 return '(' + value + ')' 951 return '(' + value + ')'
951 return value 952 return value
952 953
953def tidy_licenses(value):
954 """Flat, split and sort licenses"""
955 from oe.license import flattened_licenses
956 def _choose(a, b):
957 str_a, str_b = sorted((" & ".join(a), " & ".join(b)), key=str.casefold)
958 return ["(%s | %s)" % (str_a, str_b)]
959 if not isinstance(value, str):
960 value = " & ".join(value)
961 return sorted(list(set(flattened_licenses(value, _choose))), key=str.casefold)
962
963def handle_license_vars(srctree, lines_before, handled, extravalues, d): 954def handle_license_vars(srctree, lines_before, handled, extravalues, d):
964 lichandled = [x for x in handled if x[0] == 'license'] 955 lichandled = [x for x in handled if x[0] == 'license']
965 if lichandled: 956 if lichandled: