diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2016-08-03 16:32:15 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-08-25 22:54:44 +0100 |
commit | 0f4163a12ea431d0ba6265880ee1e557333d3211 (patch) | |
tree | fb608ccfb524b96e93fa321996ed955b2beeeb0c /meta/lib/oe | |
parent | d7229489c7dfd35164fd107d7944f3c273776118 (diff) | |
download | openembedded-core-0f4163a12ea431d0ba6265880ee1e557333d3211.tar.gz openembedded-core-0f4163a12ea431d0ba6265880ee1e557333d3211.tar.bz2 openembedded-core-0f4163a12ea431d0ba6265880ee1e557333d3211.zip |
license: simple verification of LICENSE_<pkg> values
LICENSE should be a superset of all LICENSE_<pkg> values. That is,
LICENSE should contain all licenses and LICENSE_<pkg> can be used to
"filter" this on a per-package basis. LICENSE_<pkg> shouldn't contain
anything that isn't specified in LICENSE.
This patch implements simple checking of LICENSE_<pkg> values. It does
do not do advanced parsing/matching of license expressions, but,
checks that all licenses mentioned in LICENSE_<pkg> are also specified in
LICENSE. A warning is printed if problems are found.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r-- | meta/lib/oe/license.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py index 39ef9654fc..8d2fd1709c 100644 --- a/meta/lib/oe/license.py +++ b/meta/lib/oe/license.py @@ -215,3 +215,21 @@ def manifest_licenses(licensestr, dont_want_licenses, canonical_license, d): manifest.licensestr = manifest.licensestr.replace('[', '(').replace(']', ')') return (manifest.licensestr, manifest.licenses) + +class ListVisitor(LicenseVisitor): + """Record all different licenses found in the license string""" + def __init__(self): + self.licenses = set() + + def visit_Str(self, node): + self.licenses.add(node.s) + +def list_licenses(licensestr): + """Simply get a list of all licenses mentioned in a license string. + Binary operators are not applied or taken into account in any way""" + visitor = ListVisitor() + try: + visitor.visit_string(licensestr) + except SyntaxError as exc: + raise LicenseSyntaxError(licensestr, exc) + return visitor.licenses |