Okay. I will fix that.
> -----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