summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/selftest/cases/recipetool.py4
-rw-r--r--scripts/lib/recipetool/create.py39
2 files changed, 32 insertions, 11 deletions
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index 439e41597c..95e4753976 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -426,7 +426,7 @@ class RecipetoolCreateTests(RecipetoolBase):
426 checkvars = {} 426 checkvars = {}
427 checkvars['SUMMARY'] = 'Node Server Example' 427 checkvars['SUMMARY'] = 'Node Server Example'
428 checkvars['HOMEPAGE'] = 'https://github.com/savoirfairelinux/node-server-example#readme' 428 checkvars['HOMEPAGE'] = 'https://github.com/savoirfairelinux/node-server-example#readme'
429 checkvars['LICENSE'] = set(['MIT', 'ISC', 'Unknown']) 429 checkvars['LICENSE'] = 'BSD-3-Clause & ISC & MIT & Unknown'
430 urls = [] 430 urls = []
431 urls.append('npm://registry.npmjs.org/;package=@savoirfairelinux/node-server-example;version=${PV}') 431 urls.append('npm://registry.npmjs.org/;package=@savoirfairelinux/node-server-example;version=${PV}')
432 urls.append('npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json') 432 urls.append('npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json')
@@ -483,7 +483,7 @@ class RecipetoolCreateTests(RecipetoolBase):
483 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri)) 483 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
484 self.assertTrue(os.path.isfile(recipefile)) 484 self.assertTrue(os.path.isfile(recipefile))
485 checkvars = {} 485 checkvars = {}
486 checkvars['LICENSE'] = set(['PSF', '&', 'BSD-3-Clause', 'GPL']) 486 checkvars['LICENSE'] = 'BSD-3-Clause & GPL & PSF'
487 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.txt;md5=35a23d42b615470583563132872c97d6' 487 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.txt;md5=35a23d42b615470583563132872c97d6'
488 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-${PV}.tar.gz' 488 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-${PV}.tar.gz'
489 checkvars['SRC_URI[md5sum]'] = 'c53768d63db3873b7d452833553469de' 489 checkvars['SRC_URI[md5sum]'] = 'c53768d63db3873b7d452833553469de'
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 28224dbc24..507a230511 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -919,6 +919,22 @@ def split_value(value):
919 else: 919 else:
920 return value 920 return value
921 921
922def fixup_license(value):
923 # Ensure licenses with OR starts and ends with brackets
924 if '|' in value:
925 return '(' + value + ')'
926 return value
927
928def tidy_licenses(value):
929 """Flat, split and sort licenses"""
930 from oe.license import flattened_licenses
931 def _choose(a, b):
932 str_a, str_b = sorted((" & ".join(a), " & ".join(b)), key=str.casefold)
933 return ["(%s | %s)" % (str_a, str_b)]
934 if not isinstance(value, str):
935 value = " & ".join(value)
936 return sorted(list(set(flattened_licenses(value, _choose))), key=str.casefold)
937
922def handle_license_vars(srctree, lines_before, handled, extravalues, d): 938def handle_license_vars(srctree, lines_before, handled, extravalues, d):
923 lichandled = [x for x in handled if x[0] == 'license'] 939 lichandled = [x for x in handled if x[0] == 'license']
924 if lichandled: 940 if lichandled:
@@ -932,10 +948,13 @@ def handle_license_vars(srctree, lines_before, handled, extravalues, d):
932 lines = [] 948 lines = []
933 if licvalues: 949 if licvalues:
934 for licvalue in licvalues: 950 for licvalue in licvalues:
935 if not licvalue[0] in licenses: 951 license = licvalue[0]
936 licenses.append(licvalue[0]) 952 lics = tidy_licenses(fixup_license(license))
953 lics = [lic for lic in lics if lic not in licenses]
954 if len(lics):
955 licenses.extend(lics)
937 lic_files_chksum.append('file://%s;md5=%s' % (licvalue[1], licvalue[2])) 956 lic_files_chksum.append('file://%s;md5=%s' % (licvalue[1], licvalue[2]))
938 if licvalue[0] == 'Unknown': 957 if license == 'Unknown':
939 lic_unknown.append(licvalue[1]) 958 lic_unknown.append(licvalue[1])
940 if lic_unknown: 959 if lic_unknown:
941 lines.append('#') 960 lines.append('#')
@@ -944,9 +963,7 @@ def handle_license_vars(srctree, lines_before, handled, extravalues, d):
944 for licfile in lic_unknown: 963 for licfile in lic_unknown:
945 lines.append('# %s' % licfile) 964 lines.append('# %s' % licfile)
946 965
947 extra_license = split_value(extravalues.pop('LICENSE', [])) 966 extra_license = tidy_licenses(extravalues.pop('LICENSE', ''))
948 if '&' in extra_license:
949 extra_license.remove('&')
950 if extra_license: 967 if extra_license:
951 if licenses == ['Unknown']: 968 if licenses == ['Unknown']:
952 licenses = extra_license 969 licenses = extra_license
@@ -987,7 +1004,7 @@ def handle_license_vars(srctree, lines_before, handled, extravalues, d):
987 lines.append('# instead of &. If there is any doubt, check the accompanying documentation') 1004 lines.append('# instead of &. If there is any doubt, check the accompanying documentation')
988 lines.append('# to determine which situation is applicable.') 1005 lines.append('# to determine which situation is applicable.')
989 1006
990 lines.append('LICENSE = "%s"' % ' & '.join(licenses)) 1007 lines.append('LICENSE = "%s"' % ' & '.join(sorted(licenses, key=str.casefold)))
991 lines.append('LIC_FILES_CHKSUM = "%s"' % ' \\\n '.join(lic_files_chksum)) 1008 lines.append('LIC_FILES_CHKSUM = "%s"' % ' \\\n '.join(lic_files_chksum))
992 lines.append('') 1009 lines.append('')
993 1010
@@ -1226,6 +1243,7 @@ def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=[], pn='
1226 """ 1243 """
1227 pkglicenses = {pn: []} 1244 pkglicenses = {pn: []}
1228 for license, licpath, _ in licvalues: 1245 for license, licpath, _ in licvalues:
1246 license = fixup_license(license)
1229 for pkgname, pkgpath in packages.items(): 1247 for pkgname, pkgpath in packages.items():
1230 if licpath.startswith(pkgpath + '/'): 1248 if licpath.startswith(pkgpath + '/'):
1231 if pkgname in pkglicenses: 1249 if pkgname in pkglicenses:
@@ -1238,11 +1256,14 @@ def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=[], pn='
1238 pkglicenses[pn].append(license) 1256 pkglicenses[pn].append(license)
1239 outlicenses = {} 1257 outlicenses = {}
1240 for pkgname in packages: 1258 for pkgname in packages:
1241 license = ' '.join(list(set(pkglicenses.get(pkgname, ['Unknown'])))) or 'Unknown' 1259 # Assume AND operator between license files
1260 license = ' & '.join(list(set(pkglicenses.get(pkgname, ['Unknown'])))) or 'Unknown'
1242 if license == 'Unknown' and pkgname in fallback_licenses: 1261 if license == 'Unknown' and pkgname in fallback_licenses:
1243 license = fallback_licenses[pkgname] 1262 license = fallback_licenses[pkgname]
1263 licenses = tidy_licenses(license)
1264 license = ' & '.join(licenses)
1244 outlines.append('LICENSE:%s = "%s"' % (pkgname, license)) 1265 outlines.append('LICENSE:%s = "%s"' % (pkgname, license))
1245 outlicenses[pkgname] = license.split() 1266 outlicenses[pkgname] = licenses
1246 return outlicenses 1267 return outlicenses
1247 1268
1248def read_pkgconfig_provides(d): 1269def read_pkgconfig_provides(d):