Patchwork [1/2] license.bbclass: canonicalise licenses when dealing with INCOMPATIBLE_LICENSE

login
register
mail settings
Submitter Ross Burton
Date July 16, 2014, 9:08 p.m.
Message ID <630fae1a4789305e375dc7897b9bbb71a240e250.1405542583.git.ross.burton@intel.com>
Download mbox | patch
Permalink /patch/75829/
State New
Headers show

Comments

Ross Burton - July 16, 2014, 9:08 p.m.
If INCOMPATIBLE_LICENSE=GPLv3.0 but the recipe sets LICENSE=GPLv3, the current
code won't trigger because they're different strings.

Fix this by attempting to canonicalise every license name to a SPDX name, so
both names in this example become GPL-3.0.

[ YOCTO #5622 ]

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/base.bbclass    |    2 ++
 meta/classes/license.bbclass |   14 +++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
Paul Eggleton - July 17, 2014, 2:28 p.m.
On Wednesday 16 July 2014 22:08:13 Ross Burton wrote:
> If INCOMPATIBLE_LICENSE=GPLv3.0 but the recipe sets LICENSE=GPLv3, the

Pedantic, but INCOMPATIBLE_LICENSE = "GPL-3.0" surely?

Cheers,
Paul
Ross Burton - July 17, 2014, 2:39 p.m.
On 17 July 2014 15:28, Paul Eggleton <paul.eggleton@linux.intel.com> wrote:
> On Wednesday 16 July 2014 22:08:13 Ross Burton wrote:
>> If INCOMPATIBLE_LICENSE=GPLv3.0 but the recipe sets LICENSE=GPLv3, the
>
> Pedantic, but INCOMPATIBLE_LICENSE = "GPL-3.0" surely?

Yes, sigh.

Ross

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index c0d2c8ec8..8114cf6 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -540,6 +540,8 @@  python () {
                 check_license = False
 
         if check_license and bad_licenses:
+            bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses)
+
             whitelist = []
             for lic in bad_licenses:
                 for w in ["HOSTTOOLS_WHITELIST_", "LGPLv2_WHITELIST_", "WHITELIST_"]:
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 08f0665..973a95b 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -264,10 +264,18 @@  def return_spdx(d, license):
      """
     return d.getVarFlag('SPDXLICENSEMAP', license, True)
 
+def canonical_license(d, license):
+    """
+    Return the canonical (SPDX) form of the license if available (so GPLv3
+    becomes GPL-3.0), or the passed license if there is no canonical form.
+    """
+    return d.getVarFlag('SPDXLICENSEMAP', license, True) or license
+
 def incompatible_license(d, dont_want_licenses, package=None):
     """
-    This function checks if a recipe has only incompatible licenses. It also take into consideration 'or'
-    operand.
+    This function checks if a recipe has only incompatible licenses. It also
+    take into consideration 'or' operand.  dont_want_licenses should be passed
+    as canonical (SPDX) names.
     """
     import re
     import oe.license
@@ -298,7 +306,7 @@  def incompatible_license(d, dont_want_licenses, package=None):
         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(l) for l in licenses)
+    return any(not license_ok(canonical_license(d, l)) for l in licenses)
 
 def check_license_flags(d):
     """