aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2015-05-08 20:41:29 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-09 22:28:14 +0100
commit8c7082de0ad2a963b5823834a83723127ddb454e (patch)
tree8d66960351cba20ebacc6544ef7a5dee14a93937
parentb971eb0313f483b0a0653189a8f56921cc242901 (diff)
downloadopenembedded-core-contrib-8c7082de0ad2a963b5823834a83723127ddb454e.tar.gz
license_class: Generalize license_ok function
Add dont_want_licenses as parameter to license_ok function and move it to oe.license module in order to use in other modules. (From OE-Core rev: 243fe3a4583a21ad6c0b2a26196ed18d41740f7a) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/license.bbclass21
-rw-r--r--meta/lib/oe/license.py14
2 files changed, 18 insertions, 17 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 975867d241..780b9d5863 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -341,36 +341,23 @@ def incompatible_license(d, dont_want_licenses, package=None):
take into consideration 'or' operand. dont_want_licenses should be passed
as canonical (SPDX) names.
"""
- import re
import oe.license
- from fnmatch import fnmatchcase as fnmatch
license = d.getVar("LICENSE_%s" % package, True) if package else None
if not license:
license = d.getVar('LICENSE', True)
- def license_ok(license):
- for dwl in dont_want_licenses:
- # If you want to exclude license named generically 'X', we
- # surely want to exclude 'X+' as well. In consequence, we
- # will exclude a trailing '+' character from LICENSE in
- # case INCOMPATIBLE_LICENSE is not a 'X+' license.
- lic = license
- if not re.search('\+$', dwl):
- lic = re.sub('\+', '', license)
- if fnmatch(lic, dwl):
- return False
- return True
-
# Handles an "or" or two license sets provided by
# flattened_licenses(), pick one that works if possible.
def choose_lic_set(a, b):
- return a if all(license_ok(lic) for lic in a) else b
+ return a if all(oe.license.license_ok(lic, dont_want_licenses) \
+ for lic in a) else b
try:
licenses = oe.license.flattened_licenses(license, choose_lic_set)
except oe.license.LicenseError as exc:
bb.fatal('%s: %s' % (d.getVar('P', True), exc))
- return any(not license_ok(canonical_license(d, l)) for l in licenses)
+ return any(not oe.license.license_ok(canonical_license(d, l), \
+ dont_want_licenses) for l in licenses)
def check_license_flags(d):
"""
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 31ca15b574..bc146a28c4 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -5,6 +5,20 @@ import ast
import re
from fnmatch import fnmatchcase as fnmatch
+def license_ok(license, dont_want_licenses):
+ """ Return False if License exist in dont_want_licenses else True """
+ for dwl in dont_want_licenses:
+ # If you want to exclude license named generically 'X', we
+ # surely want to exclude 'X+' as well. In consequence, we
+ # will exclude a trailing '+' character from LICENSE in
+ # case INCOMPATIBLE_LICENSE is not a 'X+' license.
+ lic = license
+ if not re.search('\+$', dwl):
+ lic = re.sub('\+', '', license)
+ if fnmatch(lic, dwl):
+ return False
+ return True
+
class LicenseError(Exception):
pass