diff options
Diffstat (limited to 'meta/classes/license.bbclass')
| -rw-r--r-- | meta/classes/license.bbclass | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index 648a4d7892..c388740003 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass | |||
| @@ -252,7 +252,7 @@ def canonical_license(d, license): | |||
| 252 | """ | 252 | """ |
| 253 | Return the canonical (SPDX) form of the license if available (so GPLv3 | 253 | Return the canonical (SPDX) form of the license if available (so GPLv3 |
| 254 | becomes GPL-3.0), for the license named 'X+', return canonical form of | 254 | becomes GPL-3.0), for the license named 'X+', return canonical form of |
| 255 | 'X' if availabel and the tailing '+' (so GPLv3+ becomes GPL-3.0+), | 255 | 'X' if available and the tailing '+' (so GPLv3+ becomes GPL-3.0+), |
| 256 | or the passed license if there is no canonical form. | 256 | or the passed license if there is no canonical form. |
| 257 | """ | 257 | """ |
| 258 | lic = d.getVarFlag('SPDXLICENSEMAP', license) or "" | 258 | lic = d.getVarFlag('SPDXLICENSEMAP', license) or "" |
| @@ -262,10 +262,29 @@ def canonical_license(d, license): | |||
| 262 | lic += '+' | 262 | lic += '+' |
| 263 | return lic or license | 263 | return lic or license |
| 264 | 264 | ||
| 265 | def available_licenses(d): | ||
| 266 | """ | ||
| 267 | Return the available licenses by searching the directories specified by | ||
| 268 | COMMON_LICENSE_DIR and LICENSE_PATH. | ||
| 269 | """ | ||
| 270 | lic_dirs = ((d.getVar('COMMON_LICENSE_DIR') or '') + ' ' + | ||
| 271 | (d.getVar('LICENSE_PATH') or '')).split() | ||
| 272 | |||
| 273 | licenses = [] | ||
| 274 | for lic_dir in lic_dirs: | ||
| 275 | licenses += os.listdir(lic_dir) | ||
| 276 | |||
| 277 | licenses = sorted(licenses) | ||
| 278 | return licenses | ||
| 279 | |||
| 280 | # Only determine the list of all available licenses once. This assumes that any | ||
| 281 | # additions to LICENSE_PATH have been done before this file is parsed. | ||
| 282 | AVAILABLE_LICENSES := "${@' '.join(available_licenses(d))}" | ||
| 283 | |||
| 265 | def expand_wildcard_licenses(d, wildcard_licenses): | 284 | def expand_wildcard_licenses(d, wildcard_licenses): |
| 266 | """ | 285 | """ |
| 267 | Return actual spdx format license names if wildcard used. We expand | 286 | Return actual spdx format license names if wildcards are used. We expand |
| 268 | wildcards from SPDXLICENSEMAP flags and SRC_DISTRIBUTE_LICENSES values. | 287 | wildcards from SPDXLICENSEMAP flags and AVAILABLE_LICENSES. |
| 269 | """ | 288 | """ |
| 270 | import fnmatch | 289 | import fnmatch |
| 271 | licenses = wildcard_licenses[:] | 290 | licenses = wildcard_licenses[:] |
| @@ -274,7 +293,7 @@ def expand_wildcard_licenses(d, wildcard_licenses): | |||
| 274 | spdxflags = fnmatch.filter(spdxmapkeys, wld_lic) | 293 | spdxflags = fnmatch.filter(spdxmapkeys, wld_lic) |
| 275 | licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags] | 294 | licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags] |
| 276 | 295 | ||
| 277 | spdx_lics = (d.getVar('SRC_DISTRIBUTE_LICENSES', False) or '').split() | 296 | spdx_lics = d.getVar('AVAILABLE_LICENSES').split() |
| 278 | for wld_lic in wildcard_licenses: | 297 | for wld_lic in wildcard_licenses: |
| 279 | licenses += fnmatch.filter(spdx_lics, wld_lic) | 298 | licenses += fnmatch.filter(spdx_lics, wld_lic) |
| 280 | 299 | ||
