All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Peter Kjellerstedt" <peter.kjellerstedt@axis.com>
To: Meh Mbeh Ida Delphine <idadelm@gmail.com>,
	"openembedded-core@lists.openembedded.org"
	<openembedded-core@lists.openembedded.org>
Subject: Re: [OE-core] [poky-contrib][PATCH 4/4] Moved logic to get filelics from package.bbclass to license.py
Date: Fri, 12 Mar 2021 16:18:30 +0000	[thread overview]
Message-ID: <8bb63481eacc4f7cac51e5f88ab856dd@XBOX03.axis.com> (raw)
In-Reply-To: <20210309233130.104839-4-idadelm@gmail.com>

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-
> core@lists.openembedded.org> On Behalf Of Meh Mbeh Ida Delphine
> Sent: den 10 mars 2021 00:32
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [poky-contrib][PATCH 4/4] Moved logic to get filelics
> from package.bbclass to license.py
> 
> The logic to obtain filelics is moved from package.bbclass to license.py
> as a standalone function.
> Also, the check in package.bbclass after obtaining filelics ensures
> licenses with * WITH Linux-syscall-note" are ignored, as long as they're
> only in header files.
> 
> Signed-off-by: Ida Delphine <idadelm@gmail.com>
> ---
>  meta/classes/package.bbclass | 24 ++++++------------------
>  meta/lib/oe/license.py       | 29 ++++++++++++++++++++++++++++-
>  2 files changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index 8c0a49ad76..a2e0eab848 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -1721,25 +1721,13 @@ fi
>              with open(data_file + ".srclist", 'w') as f:
>                  f.write(json.dumps(sources, sort_keys=True))
> 
> +            flics = oe.license.get_filelics([d.getVar('PKGD'),
> d.getVar('STAGING_DIR_TARGET')])
>              filelics = {}
> -            for dirent in [d.getVar('PKGD'),
> d.getVar('STAGING_DIR_TARGET')]:
> -                p = subprocess.Popen(["grep", 'SPDX-License-Identifier:',
> '-R', '-I'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=dirent)
> -                out, err = p.communicate()
> -                if p.returncode == 0:
> -                    for l in out.decode("utf-8").split("\n"):
> -                        l = l.strip()
> -                        if not l:
> -                            continue
> -                        l = l.split(":")
> -                        if len(l) < 3:
> -                            bb.warn(str(l))
> -                            continue
> -                        fn = "/" + l[0]
> -                        lic = l[2].strip()
> -                        if lic.endswith("*/"):
> -                            lic = lic[:-2]
> -                        lic = lic.strip()
> -                        filelics[fn] = lic
> +            for k, v in flics.items():
> +                if k.endswith(".h") and v.endswith("WITH Linux-syscall-note"):

What about .hh files, or .hpp files, or header files from some 
other language than C/C++? At the least, this if statement should 
have a comment explaining what is going on.

> +                    continue
> +                else:
> +                    filelics[k] = v
>              with open(data_file + ".filelics", 'w') as f:
>                  f.write(json.dumps(filelics, sort_keys=True))
> 
> diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
> index 9e9957be1d..3c40fa73eb 100644
> --- a/meta/lib/oe/license.py
> +++ b/meta/lib/oe/license.py
> @@ -3,6 +3,8 @@
>  #
>  """Code for parsing OpenEmbedded license strings"""
> 
> +import subprocess
> +import bb
>  import ast
>  import re
>  from fnmatch import fnmatchcase as fnmatch
> @@ -258,4 +260,29 @@ def split_spdx_lic(licensestr,d):
>      """
>      split_lic = list_licenses(licensestr)
>      spdx_lic = set([canonical_license(l, d) for l in split_lic])
> -    return spdx_lic
> \ No newline at end of file
> +    return spdx_lic
> +
> +def get_filelics(dirs):
> +    """"
> +    This function returns a dictionary of file paths (keys) and their
> corresponding SPDX header identifiers (values).
> +    """
> +    filelics = {}
> +    for dirent in dirs:
> +        p = subprocess.Popen(["grep", 'SPDX-License-Identifier:', '-R','-
> I'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=dirent)
> +        out, err = p.communicate()
> +        if p.returncode == 0:
> +            for l in out.decode("utf-8").split("\n"):
> +                l = l.strip()
> +                if not l:
> +                    continue
> +                l = l.split(":")
> +                if len(l) < 3:
> +                    bb.warn(str(l))
> +                    continue
> +                fn = "/" + l[0]
> +                lic = l[2].strip()
> +                if lic.endswith("*/"):
> +                    lic = lic[:-2]
> +                lic = lic.strip()
> +                filelics[fn] = lic
> +    return filelics
> \ No newline at end of file
> --
> 2.25.1

//Peter


  reply	other threads:[~2021-03-12 16:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 23:31 [poky-contrib][PATCH 1/4] oe.license: Add functions to split and canonicalise license strings Meh Mbeh Ida Delphine
2021-03-09 23:31 ` [poky-contrib][PATCH 2/4] package.bbclass: Displays warnings for just licences in recipes Meh Mbeh Ida Delphine
2021-03-12 16:57   ` [OE-core] " Peter Kjellerstedt
2021-03-09 23:31 ` [poky-contrib][PATCH 3/4] package.bbclass: Add handle_qa_error check Meh Mbeh Ida Delphine
2021-03-12 16:44   ` [OE-core] " Peter Kjellerstedt
2021-03-12 16:54     ` Christopher Larson
2021-03-12 16:59       ` Richard Purdie
2021-03-12 17:29         ` Meh Mbeh Ida Delphine
2021-03-09 23:31 ` [poky-contrib][PATCH 4/4] Moved logic to get filelics from package.bbclass to license.py Meh Mbeh Ida Delphine
2021-03-12 16:18   ` Peter Kjellerstedt [this message]
2021-03-12 17:38     ` [OE-core] " Meh Mbeh Ida Delphine
2021-03-12 15:59 ` [OE-core] [poky-contrib][PATCH 1/4] oe.license: Add functions to split and canonicalise license strings Peter Kjellerstedt

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=8bb63481eacc4f7cac51e5f88ab856dd@XBOX03.axis.com \
    --to=peter.kjellerstedt@axis.com \
    --cc=idadelm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.