mirror of
https://git.yoctoproject.org/poky
synced 2026-09-14 21:49:33 +02:00
recipetool: create: improve python recipe license handling
Try to ensure that for Apache, GPL and LGPL where the values extracted from the "Classifiers" field may not be version-specific, if there is a versioned license in the free-form license field then use that instead. Also insert the free-form license field as a comment in the recipe for the user's reference. (From OE-Core rev: 237f66042eedd906f654827b53bf9269738267ab) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
3a8a0bba9b
commit
9aa1cf3a28
@@ -86,8 +86,11 @@ class PythonRecipeHandler(RecipeHandler):
|
|||||||
]
|
]
|
||||||
setuparg_multi_line_values = ['Description']
|
setuparg_multi_line_values = ['Description']
|
||||||
replacements = [
|
replacements = [
|
||||||
|
('License', r' +$', ''),
|
||||||
|
('License', r'^ +', ''),
|
||||||
('License', r' ', '-'),
|
('License', r' ', '-'),
|
||||||
('License', r'-License$', ''),
|
('License', r'^GNU-', ''),
|
||||||
|
('License', r'-[Ll]icen[cs]e(,?-[Vv]ersion)?', ''),
|
||||||
('License', r'^UNKNOWN$', ''),
|
('License', r'^UNKNOWN$', ''),
|
||||||
|
|
||||||
# Remove currently unhandled version numbers from these variables
|
# Remove currently unhandled version numbers from these variables
|
||||||
@@ -216,6 +219,9 @@ class PythonRecipeHandler(RecipeHandler):
|
|||||||
else:
|
else:
|
||||||
info = self.get_setup_args_info(setupscript)
|
info = self.get_setup_args_info(setupscript)
|
||||||
|
|
||||||
|
# Grab the license value before applying replacements
|
||||||
|
license_str = info.get('License', '').strip()
|
||||||
|
|
||||||
self.apply_info_replacements(info)
|
self.apply_info_replacements(info)
|
||||||
|
|
||||||
if uses_setuptools:
|
if uses_setuptools:
|
||||||
@@ -223,17 +229,37 @@ class PythonRecipeHandler(RecipeHandler):
|
|||||||
else:
|
else:
|
||||||
classes.append('distutils')
|
classes.append('distutils')
|
||||||
|
|
||||||
|
if license_str:
|
||||||
|
for i, line in enumerate(lines_before):
|
||||||
|
if line.startswith('LICENSE = '):
|
||||||
|
lines_before.insert(i, '# NOTE: License in setup.py/PKGINFO is: %s' % license_str)
|
||||||
|
break
|
||||||
|
|
||||||
if 'Classifier' in info:
|
if 'Classifier' in info:
|
||||||
|
existing_licenses = info.get('License', '')
|
||||||
licenses = []
|
licenses = []
|
||||||
for classifier in info['Classifier']:
|
for classifier in info['Classifier']:
|
||||||
if classifier in self.classifier_license_map:
|
if classifier in self.classifier_license_map:
|
||||||
license = self.classifier_license_map[classifier]
|
license = self.classifier_license_map[classifier]
|
||||||
|
if license == 'Apache' and 'Apache-2.0' in existing_licenses:
|
||||||
|
license = 'Apache-2.0'
|
||||||
|
elif license == 'GPL':
|
||||||
|
if 'GPL-2.0' in existing_licenses or 'GPLv2' in existing_licenses:
|
||||||
|
license = 'GPL-2.0'
|
||||||
|
elif 'GPL-3.0' in existing_licenses or 'GPLv3' in existing_licenses:
|
||||||
|
license = 'GPL-3.0'
|
||||||
|
elif license == 'LGPL':
|
||||||
|
if 'LGPL-2.1' in existing_licenses or 'LGPLv2.1' in existing_licenses:
|
||||||
|
license = 'LGPL-2.1'
|
||||||
|
elif 'LGPL-2.0' in existing_licenses or 'LGPLv2' in existing_licenses:
|
||||||
|
license = 'LGPL-2.0'
|
||||||
|
elif 'LGPL-3.0' in existing_licenses or 'LGPLv3' in existing_licenses:
|
||||||
|
license = 'LGPL-3.0'
|
||||||
licenses.append(license)
|
licenses.append(license)
|
||||||
|
|
||||||
if licenses:
|
if licenses:
|
||||||
info['License'] = ' & '.join(licenses)
|
info['License'] = ' & '.join(licenses)
|
||||||
|
|
||||||
|
|
||||||
# Map PKG-INFO & setup.py fields to bitbake variables
|
# Map PKG-INFO & setup.py fields to bitbake variables
|
||||||
for field, values in info.items():
|
for field, values in info.items():
|
||||||
if field in self.excluded_fields:
|
if field in self.excluded_fields:
|
||||||
|
|||||||
Reference in New Issue
Block a user