Patchwork base.bbclass: support for or operand in LICENSE and for SPDX license names

login
register
mail settings
Submitter Andrei Gherzan
Date Jan. 9, 2012, 3:43 p.m.
Message ID <1326123824-11738-1-git-send-email-andrei@gherzan.ro>
Download mbox | patch
Permalink /patch/18797/
State New
Headers show

Comments

Andrei Gherzan - Jan. 9, 2012, 3:43 p.m.
From: Andrei Gherzan <andrei.gherzan@windriver.com>

base.bblass modfied in order to correctly exlude packages where OE-Style licence naming
is used. In this way licenses as GPL-3, GPLv3, GPLv3.0 will be exluded from a non-GPLv3
build.
The second modification was to include in a non-GPLv3 build packages where LICENSE is
GPLv3 or "something else". For example, qt4-embedded has LICENSE = "LGPLv2.1 | GPLv3".
This package should be included in a non-GPLv3 build as it is LGPLv2.1 or GPLv3.

[YOCTO #1884]
[YOCTO #1844]

Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
---
 meta/classes/base.bbclass |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
Elizabeth Flanagan - Jan. 9, 2012, 9:12 p.m.
On Mon, Jan 9, 2012 at 7:43 AM, Andrei Gherzan <andrei@gherzan.ro> wrote:
> From: Andrei Gherzan <andrei.gherzan@windriver.com>
>
> base.bblass modfied in order to correctly exlude packages where OE-Style licence naming
> is used. In this way licenses as GPL-3, GPLv3, GPLv3.0 will be exluded from a non-GPLv3
> build.
> The second modification was to include in a non-GPLv3 build packages where LICENSE is
> GPLv3 or "something else". For example, qt4-embedded has LICENSE = "LGPLv2.1 | GPLv3".
> This package should be included in a non-GPLv3 build as it is LGPLv2.1 or GPLv3.
>
> [YOCTO #1884]
> [YOCTO #1844]
>
> Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
> ---
>  meta/classes/base.bbclass |   22 ++++++++++++++++++----
>  1 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index e65a722..568c5dd 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -392,6 +392,8 @@ python () {
>
>
>         dont_want_license = d.getVar('INCOMPATIBLE_LICENSE', 1)
> +        spdx_dont_want_license = d.getVarFlag('SPDXLICENSEMAP', dont_want_license)
> +
>         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"):
>             hosttools_whitelist = (d.getVar('HOSTTOOLS_WHITELIST_%s' % dont_want_license, 1) or "").split()
>             lgplv2_whitelist = (d.getVar('LGPLv2_WHITELIST_%s' % dont_want_license, 1) or "").split()
> @@ -400,10 +402,22 @@ python () {
>
>                 import re
>                 this_license = d.getVar('LICENSE', 1)
> -                if this_license and re.search(dont_want_license, this_license):
> -                    bb.note("SKIPPING %s because it's %s" % (pn, this_license))
> -                    raise bb.parse.SkipPackage("incompatible with license %s" % this_license)
> -
> +                this_license_clean=re.sub(r'[+&()*]', '', this_license)
> +                or_licenses = re.split('[|]', this_license_clean)
> +
> +                for one_or_license in or_licenses:
> +                   licenses = re.split('[ ]', one_or_license)
> +                   good_license=one_or_license
> +                   for onelicense in licenses:

A few notes:

I would use the oe.license here
Have a look at meta/classes/copyleft_compliance.bbclass and
license.bbclass to see how we're doing this.

> +                       spdx_onelicense = d.getVarFlag('SPDXLICENSEMAP', onelicense)
> +                       if ( onelicense and re.search(dont_want_license, onelicense) ) or ( onelicense and re.search(spdx_dont_want_license, onelicense) ) or ( spdx_onelicense and re.search(dont_want_license, spdx_onelicense) ) or ( spdx_onelicense and re.search(spdx_dont_want_license, spdx_onelicense) ):
> +                               good_license = ""
> +                               break
> +                   if good_license != "":
> +                       break
> +               if good_license == "":
> +                   bb.note("SKIPPING %s because it's %s" % (pn, this_license))
> +                   raise bb.parse.SkipPackage("incompatible with license %s" % this_license)
>     srcuri = d.getVar('SRC_URI', 1)
>     # Svn packages should DEPEND on subversion-native
>     if "svn://" in srcuri:
> --
> 1.7.5.4
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

I would also look at pulling this into license.bbclass as a generic
function as I can see a few anticipated uses for it.
Andrei Gherzan - Jan. 10, 2012, 1:14 p.m.
Elizabeth,

Thank you very much for you ideas upon base.bbclass: support for or 
operand in LICENSE and for SPDX license names.
I recoded this after your advices. Actually i didn't know about 
oe.license and the idea of having it as a function in license.bbclass 
sounds good to me.

So i will upload this change soon.

ag

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index e65a722..568c5dd 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -392,6 +392,8 @@  python () {
 
 
         dont_want_license = d.getVar('INCOMPATIBLE_LICENSE', 1)
+        spdx_dont_want_license = d.getVarFlag('SPDXLICENSEMAP', dont_want_license)
+
         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"):
             hosttools_whitelist = (d.getVar('HOSTTOOLS_WHITELIST_%s' % dont_want_license, 1) or "").split()
             lgplv2_whitelist = (d.getVar('LGPLv2_WHITELIST_%s' % dont_want_license, 1) or "").split()
@@ -400,10 +402,22 @@  python () {
 
                 import re
                 this_license = d.getVar('LICENSE', 1)
-                if this_license and re.search(dont_want_license, this_license):
-                    bb.note("SKIPPING %s because it's %s" % (pn, this_license))
-                    raise bb.parse.SkipPackage("incompatible with license %s" % this_license)
-
+                this_license_clean=re.sub(r'[+&()*]', '', this_license)
+                or_licenses = re.split('[|]', this_license_clean)
+
+                for one_or_license in or_licenses:
+		    licenses = re.split('[ ]', one_or_license)
+		    good_license=one_or_license
+		    for onelicense in licenses:
+			spdx_onelicense = d.getVarFlag('SPDXLICENSEMAP', onelicense)
+			if ( onelicense and re.search(dont_want_license, onelicense) ) or ( onelicense and re.search(spdx_dont_want_license, onelicense) ) or ( spdx_onelicense and re.search(dont_want_license, spdx_onelicense) ) or ( spdx_onelicense and re.search(spdx_dont_want_license, spdx_onelicense) ):
+				good_license = ""
+				break
+		    if good_license != "":
+			break
+		if good_license == "":
+		    bb.note("SKIPPING %s because it's %s" % (pn, this_license))
+		    raise bb.parse.SkipPackage("incompatible with license %s" % this_license)
     srcuri = d.getVar('SRC_URI', 1)
     # Svn packages should DEPEND on subversion-native
     if "svn://" in srcuri: