diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2019-12-11 17:48:13 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-16 23:25:49 +0000 |
commit | 2a263780814e3b07d48e3812579cfe4696db8413 (patch) | |
tree | dd22977fd3e6dffa412b9507b9c36e14e31ee404 | |
parent | 15a450cd94b76787d7a15d54eca6d522a29eae49 (diff) | |
download | poky-2a263780814e3b07d48e3812579cfe4696db8413.tar.gz |
license.bbclass: Introduce AVAILABLE_LICENSES that lists all licenses
Previously, there was SRC_DISTRIBUTE_LICENSES, an undocumented
variable that contained a static list of licenses. It was used by
expand_wildcard_licenses() to expand any wildcards used in, e.g.,
INCOMPATIBLE_LICENSE. However, since this static list of licenses has
not been kept up-to-date, many licenses were missing, with the result
that if one tried to use any of those licenses with a wildcard, no
licenses would be found, effectively ignoring that they should be
marked as incompatible.
This introduces a new (documented) variable, AVAILABLE_LICENSES, that
is automatically updated to contain all licenses found in any
directories specified by ${COMMON_LICENSE_DIR} and ${LICENSE_PATH},
and uses it instead of SRC_DISTRIBUTE_LICENSES when expanding
wildcards.
(From OE-Core rev: 8c9ef587fe499c612a878a1ab42092eb79b334ef)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/license.bbclass | 27 | ||||
-rw-r--r-- | meta/conf/documentation.conf | 1 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/incompatible_lic.py | 6 |
3 files changed, 27 insertions, 7 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 | ||
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf index fca36f3cf6..0b21d1f63e 100644 --- a/meta/conf/documentation.conf +++ b/meta/conf/documentation.conf | |||
@@ -69,6 +69,7 @@ ASSUME_SHLIBS[doc] = "List of shlib:package[_version] mappings. Useful for lib p | |||
69 | AUTHOR[doc] = "Email address used to contact the original author(s) in order to send patches and forward bugs." | 69 | AUTHOR[doc] = "Email address used to contact the original author(s) in order to send patches and forward bugs." |
70 | AUTO_SYSLINUXMENU[doc] = "Enables creating an automatic menu for the syslinux bootloader." | 70 | AUTO_SYSLINUXMENU[doc] = "Enables creating an automatic menu for the syslinux bootloader." |
71 | AUTOREV[doc] = "When SRCREV is set to the value of this variable, it specifies to use the latest source revision in the repository." | 71 | AUTOREV[doc] = "When SRCREV is set to the value of this variable, it specifies to use the latest source revision in the repository." |
72 | AVAILABLE_LICENSES[doc] = "List of licenses found in the directories specified by COMMON_LICENSE_DIR and LICENSE_PATH." | ||
72 | 73 | ||
73 | #B | 74 | #B |
74 | 75 | ||
diff --git a/meta/lib/oeqa/selftest/cases/incompatible_lic.py b/meta/lib/oeqa/selftest/cases/incompatible_lic.py index 904b5b4094..ad878571b5 100644 --- a/meta/lib/oeqa/selftest/cases/incompatible_lic.py +++ b/meta/lib/oeqa/selftest/cases/incompatible_lic.py | |||
@@ -12,12 +12,12 @@ class IncompatibleLicenseTests(OESelftestTestCase): | |||
12 | if error_msg not in result.output: | 12 | if error_msg not in result.output: |
13 | raise AssertionError(result.output) | 13 | raise AssertionError(result.output) |
14 | 14 | ||
15 | # Verify that a package with an SPDX license (from SRC_DISTRIBUTE_LICENSES) | 15 | # Verify that a package with an SPDX license (from AVAILABLE_LICENSES) |
16 | # cannot be built when INCOMPATIBLE_LICENSE contains this SPDX license | 16 | # cannot be built when INCOMPATIBLE_LICENSE contains this SPDX license |
17 | def test_incompatible_spdx_license(self): | 17 | def test_incompatible_spdx_license(self): |
18 | self.lic_test('incompatible-license', 'GPL-3.0', 'GPL-3.0') | 18 | self.lic_test('incompatible-license', 'GPL-3.0', 'GPL-3.0') |
19 | 19 | ||
20 | # Verify that a package with an SPDX license (from SRC_DISTRIBUTE_LICENSES) | 20 | # Verify that a package with an SPDX license (from AVAILABLE_LICENSES) |
21 | # cannot be built when INCOMPATIBLE_LICENSE contains an alias (in | 21 | # cannot be built when INCOMPATIBLE_LICENSE contains an alias (in |
22 | # SPDXLICENSEMAP) of this SPDX license | 22 | # SPDXLICENSEMAP) of this SPDX license |
23 | def test_incompatible_alias_spdx_license(self): | 23 | def test_incompatible_alias_spdx_license(self): |
@@ -35,7 +35,7 @@ class IncompatibleLicenseTests(OESelftestTestCase): | |||
35 | self.lic_test('incompatible-license-alias', 'GPLv3', 'GPLv3') | 35 | self.lic_test('incompatible-license-alias', 'GPLv3', 'GPLv3') |
36 | 36 | ||
37 | # Verify that a package with a non-SPDX license (neither in | 37 | # Verify that a package with a non-SPDX license (neither in |
38 | # SRC_DISTRIBUTE_LICENSES nor in SPDXLICENSEMAP) cannot be built when | 38 | # AVAILABLE_LICENSES nor in SPDXLICENSEMAP) cannot be built when |
39 | # INCOMPATIBLE_LICENSE contains this license | 39 | # INCOMPATIBLE_LICENSE contains this license |
40 | def test_incompatible_nonspdx_license(self): | 40 | def test_incompatible_nonspdx_license(self): |
41 | self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense') | 41 | self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense') |