From a8d7246f7b13ef2636c325263c8bfa22552d7a57 Mon Sep 17 00:00:00 2001 From: Elizabeth Flanagan Date: Fri, 23 Mar 2012 16:51:42 -0700 Subject: INCOMPATIBLE_LICENSE: support for spdx and pkg licenses This adds a few things to the incompatible license functionality 1. INCOMPATIBLE_LICENSE was unable to distinguish any variation within LICENSE (e.g. GPLv3 v. GPLv3.0). This now utilizes the SPDXLICENSEMAP of the license indicated as INCOMPATIBLE_LICENSE 2. Given a recipe where the main LICENSE was incompatible but a package of the recipe was compatible, the entire recipe would be excluded. This allows us some finer grained control over what exactly gets excluded. Signed-off-by: Elizabeth Flanagan Signed-off-by: Richard Purdie --- meta/classes/license.bbclass | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'meta/classes/license.bbclass') diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index 4b392ceea..eab630e47 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass @@ -81,7 +81,7 @@ license_create_manifest() { INSTALLED_PKGS=`cat ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest` # list of installed packages is broken for deb for pkg in ${INSTALLED_PKGS}; do - # not the best way to do this but licenses are not arch-dependent iirc + # not the best way to do this but licenses are not arch dependant iirc files=`find ${TMPDIR}/pkgdata/*/runtime -name ${pkg}| head -1` for filename in $files; do pkged_pn="$(sed -n 's/^PN: //p' ${filename})" @@ -135,7 +135,6 @@ license_create_manifest() { } - python do_populate_lic() { """ Populate LICENSE_DIRECTORY with licenses. @@ -254,27 +253,40 @@ python do_populate_lic() { } -def incompatible_license(d,dont_want_license): +def return_spdx(d, license): + """ + This function returns the spdx mapping of a license. """ - This function checks if a package has only incompatible licenses. It also take into consideration 'or' + if d.getVarFlag('SPDXLICENSEMAP', license) != None: + return license + else: + return d.getVarFlag('SPDXLICENSEMAP', license_type) + +def incompatible_license(d, dont_want_license, package=""): + """ + This function checks if a recipe has only incompatible licenses. It also take into consideration 'or' operand. """ import re import oe.license from fnmatch import fnmatchcase as fnmatch - + pn = d.getVar('PN', True) dont_want_licenses = [] dont_want_licenses.append(d.getVar('INCOMPATIBLE_LICENSE', True)) - if d.getVarFlag('SPDXLICENSEMAP', dont_want_license): - dont_want_licenses.append(d.getVarFlag('SPDXLICENSEMAP', dont_want_license)) + recipe_license = d.getVar('LICENSE', True) + if package != "": + if d.getVar('LICENSE_' + pn + '-' + package, True): + license = d.getVar('LICENSE_' + pn + '-' + package, True) + else: + license = recipe_license + else: + license = recipe_license + spdx_license = return_spdx(d, dont_want_license) + dont_want_licenses.append(spdx_license) def include_license(license): if any(fnmatch(license, pattern) for pattern in dont_want_licenses): return False - else: - spdx_license = d.getVarFlag('SPDXLICENSEMAP', license) - if spdx_license and any(fnmatch(spdx_license, pattern) for pattern in dont_want_licenses): - return False else: return True @@ -290,16 +302,15 @@ def incompatible_license(d,dont_want_license): is not a 'X+' license. """ if not re.search(r'[+]',dont_want_license): - licenses=oe.license.flattened_licenses(re.sub(r'[+]', '', d.getVar('LICENSE', True)), choose_licenses) + licenses=oe.license.flattened_licenses(re.sub(r'[+]', '', license), choose_licenses) else: - licenses=oe.license.flattened_licenses(d.getVar('LICENSE', True), choose_licenses) + licenses=oe.license.flattened_licenses(license, choose_licenses) for onelicense in licenses: if not include_license(onelicense): return True return False - def check_license_flags(d): """ This function checks if a recipe has any LICENSE_FLAGs that -- cgit v1.2.3