Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Saul Wold <sgw@linux.intel.com>
To: Patches and discussions about the oe-core layer
	<openembedded-core@lists.openembedded.org>
Cc: flocirel@gmail.com, Andrei Gherzan <andrei.gherzan@windriver.com>
Subject: Re: [PATCH] license.bbclass base.bbclass: support for 'or' operand in LICENSE and for SPDX license names
Date: Wed, 11 Jan 2012 22:44:59 -0800	[thread overview]
Message-ID: <4F0E816B.2080705@linux.intel.com> (raw)
In-Reply-To: <1326208678-17244-1-git-send-email-andrei@gherzan.ro>

On 01/10/2012 07:17 AM, Andrei Gherzan wrote:
> From: Andrei Gherzan<andrei.gherzan@windriver.com>
>
> A new function was defined in license.bbclass in order to correctly exclude packages where OE-Style licence naming
> is used. In this way licenses as GPL-3, GPLv3, GPLv3.0 etc will be excluded from a non-GPLv3 build. This function
> takes into consideration if 'or' operand is used.
> The function defined in license.bbclass is called in base.bbclass where packages are excluded based on
> INCOMPATIBLE_LICENSE variable.
>
> [YOCTO #1884]
> [YOCTO #1844]
>
> Signed-off-by: Andrei Gherzan<andrei at gherzan.ro>
> ---
>   meta/classes/base.bbclass    |    3 +-
>   meta/classes/license.bbclass |   45 ++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 46 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index e65a722..f0c358e 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -398,9 +398,8 @@ python () {
>               dont_want_whitelist = (d.getVar('WHITELIST_%s' % dont_want_license, 1) or "").split()
>               if pn not in hosttools_whitelist and pn not in lgplv2_whitelist and pn not in dont_want_whitelist:
>
> -                import re
>                   this_license = d.getVar('LICENSE', 1)
> -                if this_license and re.search(dont_want_license, this_license):
> +                if incompatible_license(d,dont_want_license):
>                       bb.note("SKIPPING %s because it's %s" % (pn, this_license))
>                       raise bb.parse.SkipPackage("incompatible with license %s" % this_license)
>
> diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
> index d351b5a..4b98e29 100644
> --- a/meta/classes/license.bbclass
> +++ b/meta/classes/license.bbclass
> @@ -237,6 +237,51 @@ python do_populate_lic() {
>
>   }
>
> +def incompatible_license(d,dont_want_license):
> +    """
> +    This function checks if a package has only incompatible licenses. It also take into consideration 'or'
> +    operand.
> +    """
> +    import re
> +    import oe.license
> +    from fnmatch import fnmatchcase as fnmatch
> +
> +    dont_want_licenses = []
> +    dont_want_licenses.append(d.getVar('INCOMPATIBLE_LICENSE', 1))
> +    if d.getVarFlag('SPDXLICENSEMAP', dont_want_license):
> +	dont_want_licenses.append(d.getVarFlag('SPDXLICENSEMAP', dont_want_license))
> +
> +    def include_license(license):
> +	if any(fnmatch(license, pattern) for pattern in dont_want_licenses):
> +	    return False
> +	else:
> +	    spdx_license = d.getVarFlag('SPDXLICENSEMAP', license)
> +	    if spdx_license and any(fnmatch(spdx_license, pattern) for pattern in dont_want_licenses):
> +		return False
> +	    else:
> +		return True
> +
> +    def choose_licenses(a, b):
> +        if all(include_license(lic) for lic in a):
> +		return a
> +        else:
> +		return b
> +
> +    """
> +    If you want to exlude license named generically 'X', we surely want to exlude 'X+' as well.
> +    In consequence, we will exclude the '+' character from LICENSE in case INCOMPATIBLE_LICENSE
> +    is not a 'X+' license.
> +    """
> +    if not re.search(r'[+]',dont_want_license):
> +	licenses=oe.license.flattened_licenses(re.sub(r'[+]', '', d.getVar('LICENSE', True)), choose_licenses)
> +    else:
> +	licenses=oe.license.flattened_licenses(d.getVar('LICENSE', True), choose_licenses)
> +
> +    for onelicense in licenses:
> +	if not include_license(onelicense):
> +		return True
> +    return False
> +
>   SSTATETASKS += "do_populate_lic"
>   do_populate_lic[sstate-name] = "populate-lic"
>   do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}"

Andrei, thanks for your persistence with this one, there are clearly 
some issues in this area that need work, this is a great start down that 
line.

Merged into OE-Core

Sau!



      parent reply	other threads:[~2012-01-12  6:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-10 15:17 [PATCH] license.bbclass base.bbclass: support for 'or' operand in LICENSE and for SPDX license names Andrei Gherzan
2012-01-10 15:34 ` Chris Larson
2012-01-10 16:07   ` Andrei Gherzan
2012-01-10 16:10     ` Chris Larson
2012-01-10 16:12       ` Andrei Gherzan
2012-01-10 16:34         ` Chris Larson
2012-01-10 16:55           ` Flanagan, Elizabeth
2012-01-10 17:05             ` Chris Larson
2012-01-10 18:13           ` Andrei Gherzan
2012-01-10 18:54             ` Chris Larson
2012-01-12  6:44 ` Saul Wold [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F0E816B.2080705@linux.intel.com \
    --to=sgw@linux.intel.com \
    --cc=andrei.gherzan@windriver.com \
    --cc=flocirel@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox