diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-09-19 08:08:05 +1200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-09-20 15:11:07 +0100 |
| commit | 9aa1cf3a28eab3420e15f14daba7cf3b8c484a6d (patch) | |
| tree | d4b24000a58717b247034fc4dc5f6cd1e6aca208 /scripts/lib/recipetool/create_buildsys_python.py | |
| parent | 3a8a0bba9b8bdacb73cbc17e88aa0df888217322 (diff) | |
| download | poky-9aa1cf3a28eab3420e15f14daba7cf3b8c484a6d.tar.gz | |
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>
Diffstat (limited to 'scripts/lib/recipetool/create_buildsys_python.py')
| -rw-r--r-- | scripts/lib/recipetool/create_buildsys_python.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/scripts/lib/recipetool/create_buildsys_python.py b/scripts/lib/recipetool/create_buildsys_python.py index 354af0cb96..e41d81a317 100644 --- a/scripts/lib/recipetool/create_buildsys_python.py +++ b/scripts/lib/recipetool/create_buildsys_python.py | |||
| @@ -86,8 +86,11 @@ class PythonRecipeHandler(RecipeHandler): | |||
| 86 | ] | 86 | ] |
| 87 | setuparg_multi_line_values = ['Description'] | 87 | setuparg_multi_line_values = ['Description'] |
| 88 | replacements = [ | 88 | replacements = [ |
| 89 | ('License', r' +$', ''), | ||
| 90 | ('License', r'^ +', ''), | ||
| 89 | ('License', r' ', '-'), | 91 | ('License', r' ', '-'), |
| 90 | ('License', r'-License$', ''), | 92 | ('License', r'^GNU-', ''), |
| 93 | ('License', r'-[Ll]icen[cs]e(,?-[Vv]ersion)?', ''), | ||
| 91 | ('License', r'^UNKNOWN$', ''), | 94 | ('License', r'^UNKNOWN$', ''), |
| 92 | 95 | ||
| 93 | # Remove currently unhandled version numbers from these variables | 96 | # Remove currently unhandled version numbers from these variables |
| @@ -216,6 +219,9 @@ class PythonRecipeHandler(RecipeHandler): | |||
| 216 | else: | 219 | else: |
| 217 | info = self.get_setup_args_info(setupscript) | 220 | info = self.get_setup_args_info(setupscript) |
| 218 | 221 | ||
| 222 | # Grab the license value before applying replacements | ||
| 223 | license_str = info.get('License', '').strip() | ||
| 224 | |||
| 219 | self.apply_info_replacements(info) | 225 | self.apply_info_replacements(info) |
| 220 | 226 | ||
| 221 | if uses_setuptools: | 227 | if uses_setuptools: |
| @@ -223,17 +229,37 @@ class PythonRecipeHandler(RecipeHandler): | |||
| 223 | else: | 229 | else: |
| 224 | classes.append('distutils') | 230 | classes.append('distutils') |
| 225 | 231 | ||
| 232 | if license_str: | ||
| 233 | for i, line in enumerate(lines_before): | ||
| 234 | if line.startswith('LICENSE = '): | ||
| 235 | lines_before.insert(i, '# NOTE: License in setup.py/PKGINFO is: %s' % license_str) | ||
| 236 | break | ||
| 237 | |||
| 226 | if 'Classifier' in info: | 238 | if 'Classifier' in info: |
| 239 | existing_licenses = info.get('License', '') | ||
| 227 | licenses = [] | 240 | licenses = [] |
| 228 | for classifier in info['Classifier']: | 241 | for classifier in info['Classifier']: |
| 229 | if classifier in self.classifier_license_map: | 242 | if classifier in self.classifier_license_map: |
| 230 | license = self.classifier_license_map[classifier] | 243 | license = self.classifier_license_map[classifier] |
| 244 | if license == 'Apache' and 'Apache-2.0' in existing_licenses: | ||
| 245 | license = 'Apache-2.0' | ||
| 246 | elif license == 'GPL': | ||
| 247 | if 'GPL-2.0' in existing_licenses or 'GPLv2' in existing_licenses: | ||
| 248 | license = 'GPL-2.0' | ||
| 249 | elif 'GPL-3.0' in existing_licenses or 'GPLv3' in existing_licenses: | ||
| 250 | license = 'GPL-3.0' | ||
| 251 | elif license == 'LGPL': | ||
| 252 | if 'LGPL-2.1' in existing_licenses or 'LGPLv2.1' in existing_licenses: | ||
| 253 | license = 'LGPL-2.1' | ||
| 254 | elif 'LGPL-2.0' in existing_licenses or 'LGPLv2' in existing_licenses: | ||
| 255 | license = 'LGPL-2.0' | ||
| 256 | elif 'LGPL-3.0' in existing_licenses or 'LGPLv3' in existing_licenses: | ||
| 257 | license = 'LGPL-3.0' | ||
| 231 | licenses.append(license) | 258 | licenses.append(license) |
| 232 | 259 | ||
| 233 | if licenses: | 260 | if licenses: |
| 234 | info['License'] = ' & '.join(licenses) | 261 | info['License'] = ' & '.join(licenses) |
| 235 | 262 | ||
| 236 | |||
| 237 | # Map PKG-INFO & setup.py fields to bitbake variables | 263 | # Map PKG-INFO & setup.py fields to bitbake variables |
| 238 | for field, values in info.items(): | 264 | for field, values in info.items(): |
| 239 | if field in self.excluded_fields: | 265 | if field in self.excluded_fields: |
