summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2014-12-15 16:55:10 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-19 18:08:00 +0000
commit5f78cf9b4ee56937298eaa55a6fddabae8dd8bd4 (patch)
treeed6f1ec3647ddd2839cc2fcbceec0599c965ff88
parentfc518325c64040e6bbd47cfb7f40f0fd363c17d2 (diff)
downloadpoky-5f78cf9b4ee56937298eaa55a6fddabae8dd8bd4.tar.gz
base/license.bbclass: expand wildcards in INCOMPATIBLE_LICENSE
The whitelist processing in code in base.bbclass does not play well with wildcards in INCOMPATIBLE_LICENSES. The code expects bad_licenses to contain actual license names, not wildcards. Add incompatible_license_contains to replace bb.utils.contains( "INCOMPATIBLE_LICENSE", **, **, **, d) [YOCTO #5592] (From OE-Core rev: 3587653a8d8abc7cfed6a5c6ecfa72bee283e451) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/base.bbclass2
-rw-r--r--meta/classes/license.bbclass25
-rw-r--r--meta/conf/documentation.conf2
3 files changed, 27 insertions, 2 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index de81a7d687..06cfe260ac 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -443,7 +443,7 @@ python () {
443 check_license = False 443 check_license = False
444 444
445 if check_license and bad_licenses: 445 if check_license and bad_licenses:
446 bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses) 446 bad_licenses = expand_wildcard_licenses(d, bad_licenses)
447 447
448 whitelist = [] 448 whitelist = []
449 for lic in bad_licenses: 449 for lic in bad_licenses:
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 14d3107c4a..ea4c8801e9 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -285,6 +285,31 @@ def canonical_license(d, license):
285 lic += '+' 285 lic += '+'
286 return lic or license 286 return lic or license
287 287
288def expand_wildcard_licenses(d, wildcard_licenses):
289 """
290 Return actual spdx format license names if wildcard used. We expand
291 wildcards from SPDXLICENSEMAP flags and SRC_DISTRIBUTE_LICENSES values.
292 """
293 import fnmatch
294 licenses = []
295 spdxmapkeys = d.getVarFlags('SPDXLICENSEMAP').keys()
296 for wld_lic in wildcard_licenses:
297 spdxflags = fnmatch.filter(spdxmapkeys, wld_lic)
298 licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags]
299
300 spdx_lics = (d.getVar('SRC_DISTRIBUTE_LICENSES') or '').split()
301 for wld_lic in wildcard_licenses:
302 licenses += fnmatch.filter(spdx_lics, wld_lic)
303
304 licenses = list(set(licenses))
305 return licenses
306
307def incompatible_license_contains(license, truevalue, falsevalue, d):
308 license = canonical_license(d, license)
309 bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE', True) or "").split()
310 bad_licenses = expand_wildcard_licenses(d, bad_licenses)
311 return truevalue if license in bad_licenses else falsevalue
312
288def incompatible_license(d, dont_want_licenses, package=None): 313def incompatible_license(d, dont_want_licenses, package=None):
289 """ 314 """
290 This function checks if a recipe has only incompatible licenses. It also 315 This function checks if a recipe has only incompatible licenses. It also
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 5564316bb3..2ab86e1487 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -223,7 +223,7 @@ IMAGE_ROOTFS_EXTRA_SPACE[doc] = "Defines additional free disk space created in t
223IMAGE_ROOTFS_SIZE[doc] = "Defines the size in Kbytes for the generated image." 223IMAGE_ROOTFS_SIZE[doc] = "Defines the size in Kbytes for the generated image."
224IMAGE_TYPES[doc] = "Specifies the complete list of supported image types by default." 224IMAGE_TYPES[doc] = "Specifies the complete list of supported image types by default."
225INC_PR[doc] = "Helps define the recipe revision for recipes that share a common include file." 225INC_PR[doc] = "Helps define the recipe revision for recipes that share a common include file."
226INCOMPATIBLE_LICENSE[doc] = "Specifies a space-separated list of license names (as they would appear in LICENSE) that should be excluded from the build." 226INCOMPATIBLE_LICENSE[doc] = "Specifies a space-separated list of license names (as they would appear in LICENSE) that should be excluded from the build. Wildcard is supported, such as '*GPLv3'"
227INHIBIT_DEFAULT_DEPS[doc] = "Prevents the default dependencies, namely the C compiler and standard C library (libc), from being added to DEPENDS." 227INHIBIT_DEFAULT_DEPS[doc] = "Prevents the default dependencies, namely the C compiler and standard C library (libc), from being added to DEPENDS."
228INHIBIT_PACKAGE_STRIP[doc] = "If set to "1", causes the build to not strip binaries in resulting packages." 228INHIBIT_PACKAGE_STRIP[doc] = "If set to "1", causes the build to not strip binaries in resulting packages."
229INHERIT[doc] = "Causes the named class to be inherited at this point during parsing. The variable is only valid in configuration files." 229INHERIT[doc] = "Causes the named class to be inherited at this point during parsing. The variable is only valid in configuration files."