Skip to contentSkip to conversation

base/license.bbclass: handle multiple INCOMPATIBLE_LICENSEs

PATCH In review Andy Ross 3 participants 7 messages Nov 1, 2012 – Nov 29, 2012

lore
Share & tools
lore

Andy Ross

author
#0 lore raw

cover base/license.bbclass: handle multiple INCOMPATIBLE_LICENSEs

We hit a problem trying to exclude L/GPLv3 recipes where INCOMPATIBLE_LICENSE could only match exactly one license. The older wildcard syntax had been broken by a more recent SPDX change (specifying a string without a SPDXLICENSEMAP entry could crash), so "*GPLv3" wouldn't work.

This fixes that, and extends INCOMPATIBLE_LICENSE to handle a whitespace-separated list of license strings to exclude (e.g "GPLv3 LGPLv3"). This is compatible with existing usage because the LICENSE parsing is already done on whitespace: a pre-existing INCOMPATIBLE_LICENSE value with whitespace could not have matched anything in practice.

All other behavior should be unaffected. Note specifically that the LGPLv2_WHITELIST_${license} variables are used as whitelists for all licenses (i.e. identically to WHITELIST_... and HOSTTOOLS_WHITELIST_...). That sounds wrong, but seems to have been the preexisting behavior. Ideas?

Andy

author
#1 lore raw

PATCH 1/1 base/license.bbclass: handle multiple INCOMPATIBLE_LICENSEs

Allow INCOMPATIBLE_LICENSE to be a whitespace-separated list of incompatible license strings and/or glob patterns.

Also fix wildcarding: the string in INCOMPATIBLE_LICENSE was clearly intended to match with wildcards (e.g. "*GPLv3" to match both GPLv3 and LGPLv3), but this was broken because of a bug in return_spdx() which would die with a runtime error when there was no SPDXLICENSEMAP entry for the string.

---
 meta/classes/base.bbclass    | 67 ++++++++++++++++++++++--------------------
 meta/classes/license.bbclass | 69 +++++++++++++++++---------------------------
 2 files changed, 61 insertions(+), 75 deletions(-)
meta/classes/base.bbclass +35 -32
index 783b64d..f53b59c 100644
@@ -524,41 +524,44 @@ python () {
                     raise bb.parse.SkipPackage("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % this_machine)
 
 
-        dont_want_license = d.getVar('INCOMPATIBLE_LICENSE', True)
-
-        if dont_want_license and not pn.endswith("-native") and not pn.endswith("-cross") and not pn.endswith("-cross-initial") and not pn.endswith("-cross-intermediate") and not pn.endswith("-crosssdk-intermediate") and not pn.endswith("-crosssdk") and not pn.endswith("-crosssdk-initial") and not pn.endswith("-cross-canadian-%s" % d.getVar('TRANSLATED_TARGET_ARCH', True)) and not pn.startswith("nativesdk-"):
-        # Internally, we'll use the license mapping. This way INCOMPATIBLE_LICENSE = "GPLv2" and
-        # INCOMPATIBLE_LICENSE = "GPLv2.0" will pick up all variations of GPL-2.0
-            spdx_license = return_spdx(d, dont_want_license)
-            hosttools_whitelist = (d.getVar('HOSTTOOLS_WHITELIST_%s' % dont_want_license, True) or d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split()
-            lgplv2_whitelist = (d.getVar('LGPLv2_WHITELIST_%s' % dont_want_license, True) or d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split()
-            dont_want_whitelist = (d.getVar('WHITELIST_%s' % dont_want_license, True) or d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split()
-            if pn not in hosttools_whitelist and pn not in lgplv2_whitelist and pn not in dont_want_whitelist:
-                this_license = d.getVar('LICENSE', True)
-                # At this point we know the recipe contains an INCOMPATIBLE_LICENSE, however it may contain packages that do not.
-                packages = d.getVar('PACKAGES', True).split()
-                dont_skip_recipe = False
-                skipped_packages = {}
-                unskipped_packages = []
-                for pkg in packages:
-                    if incompatible_license(d, dont_want_license, pkg):
-                            skipped_packages[pkg] = this_license
-                            dont_skip_recipe = True
+        bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE', True) or "").split()
+
+        check_license = True
+        for t in ["-native", "-cross", "-cross-initial", "-cross-intermediate", "-crosssdk-intermediate", "-crosssdk", "-crosssdk-initial", "-nativesdk"]:
+            if pn.endswith(t):
+                check_license = False
+
+        if check_license and bad_licenses:
+            whitelist = []
+            for lic in bad_licenses:
+                for w in ["HOSTTOOLS_WHITELIST_", "LGPLv2_WHITELIST_", "WHITELIST_"]:
+                    whitelist.extend((d.getVar(w + lic, True) or "").split())
+                spdx_license = return_spdx(d, lic)
+                if spdx_license:
+                    whitelist.extend((d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split())
+            if not pn in whitelist:
+                recipe_license = d.getVar('LICENSE', True)
+                pkgs = d.getVar('PACKAGES', True).split()
+                skipped_pkgs = []
+                unskipped_pkgs = []
+                for pkg in pkgs:
+                    if incompatible_license(d, bad_licenses, pkg):
+                        skipped_pkgs.append(pkg)
                     else:
-                        unskipped_packages.append(pkg)
-                if not unskipped_packages:
-                    # if we hit here and have excluded all packages, then we can just exclude the recipe
-                    dont_skip_recipe = False
-                elif skipped_packages and unskipped_packages:
-                    for pkg, license in skipped_packages.iteritems():
-                        bb.note("SKIPPING the package " + pkg + " at do_rootfs because it's " + this_license)
+                        unskipped_pkgs.append(pkg)
+
+                some_skipped = skipped_pkgs and unskipped_pkgs
+                all_skipped = skipped_pkgs and not unskipped_pkgs
+
+                if some_skipped:
+                    for pkg in skipped_pkgs:
+                        bb.note("SKIPPING the package " + pkg + " at do_rootfs because it's " + recipe_license)
                         d.setVar('LICENSE_EXCLUSION-' + pkg, 1)
-                    for index, pkg in enumerate(unskipped_packages):
+                    for pkg in unskipped_pkgs:
                         bb.note("INCLUDING the package " + pkg)
-
-                if dont_skip_recipe is False and incompatible_license(d, dont_want_license):
-                    bb.note("SKIPPING recipe %s because it's %s" % (pn, this_license))
-                    raise bb.parse.SkipPackage("incompatible with license %s" % this_license)
+                elif all_skipped or incompatible_license(d, bad_licenses):
+                    bb.note("SKIPPING recipe %s because it's %s" % (pn, recipe_license))
+                    raise bb.parse.SkipPackage("incompatible with license %s" % recipe_license)
 
 
 
meta/classes/license.bbclass +26 -43

86 lines not on this page · raw message

Signature · 1 line
1.7.11.4
author
#2 lore raw
In reply to Andy Ross
Quoted 5 lines · Andy Ross

We hit a problem trying to exclude L/GPLv3 recipes where INCOMPATIBLE_LICENSE could only match exactly one license. The older wildcard syntax had been broken by a more recent SPDX change (specifying a string without a SPDXLICENSEMAP entry could crash), so "*GPLv3" wouldn't work.

Ping

#3 lore raw
Quoted 8 lines · Andy Ross
Quoted 5 lines · Andy Ross

We hit a problem trying to exclude L/GPLv3 recipes where INCOMPATIBLE_LICENSE could only match exactly one license. The older wildcard syntax had been broken by a more recent SPDX change (specifying a string without a SPDXLICENSEMAP entry could crash), so "*GPLv3" wouldn't work.

Ping

I'd like Beth to comment on this patch and she was out last week. I'm not 100% if she is back this week :/.

Cheers,

Richard

#4 lore raw
Quoted 8 lines · Richard Purdie
Quoted 7 lines · Andy Ross
Quoted 5 lines · Andy Ross

We hit a problem trying to exclude L/GPLv3 recipes where INCOMPATIBLE_LICENSE could only match exactly one license. The older wildcard syntax had been broken by a more recent SPDX change (specifying a string without a SPDXLICENSEMAP entry could crash), so "*GPLv3" wouldn't work.

Quoted 4 lines
Quoted 1 line

Ping

I'd like Beth to comment on this patch and she was out last week. I'm not 100% if she is back this week :/.

Sorry about the absence (ELCE/Vacation/Thanksgiving had me out for a while).

This patch needs a rebase and a minor bit of whitespace work. I've done some work to make it apply to the current master head and tested it out and it does improve the utility of INCOMPATIBLE_LICENSE quite a bit.

I was able to not-create an image with:

INCOMPATIBLE_LICENSE += "*BSD*"
INCOMPATIBLE_LICENSE += "*GPL*"

Obviously this would fail, however this does end up excluding all *GPL* and *BSD* licenses.

If it's ok with you, Andy, I'll just submit my modifications to your patch.

-b

Quoted 8 lines

Richard

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Signature · 3 lines
Elizabeth Flanagan
Yocto Project
Build and Release
author
#5 lore raw
Quoted 4 lines · Elizabeth

This patch needs a rebase and a minor bit of whitespace work. I've done some work to make it apply to the current master head and tested it out and it does improve the utility of INCOMPATIBLE_LICENSE quite a bit.

Hm... AFAICT the content of the patch still seems to apply cleanly with git am on a just-pulled poky (don't have an oe-core tree on this machine) master HEAD. Am I looking at a wrong branch?

Quoted 1 line

If it's ok with you, Andy, I'll just submit my modifications to your patch.

Fine with me.

Andy

#6 lore raw
Quoted 8 lines · Andy Ross
Quoted 5 lines · Elizabeth

This patch needs a rebase and a minor bit of whitespace work. I've done some work to make it apply to the current master head and tested it out and it does improve the utility of INCOMPATIBLE_LICENSE quite a bit.

Quoted 4 lines

Hm... AFAICT the content of the patch still seems to apply cleanly with git am on a just-pulled poky (don't have an oe-core tree on this machine) master HEAD. Am I looking at a wrong branch?

Let me recheck. It wasn't applying clean for me but it may be on my end.

-b

Quoted 10 lines
Quoted 3 lines

If it's ok with you, Andy, I'll just submit my modifications to your patch.

Fine with me.

Andy

Signature · 3 lines
Elizabeth Flanagan
Yocto Project
Build and Release