Re: [OE-core] [PATCH 09/12] recipetool: npm: Pass README as fallback to guess_license if a license is missing
Am 07.10.2021 um 12:13 schrieb Stefan Herbrechtsmeier via lists.openembedded.org: From: Stefan Herbrechtsmeier Signed-off-by: Stefan Herbrechtsmeier --- scripts/lib/recipetool/create_npm.py | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index c939780931..27db6036fc 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py @@ -115,17 +115,36 @@ class NpmRecipeHandler(RecipeHandler): def _handle_licenses(self, srctree, shrinkwrap_file, dev): """Return the extra license files and the list of packages""" +licfiles = [] packages = {} # Handle the parent package packages["${PN}"] = "" +def _licfiles_append_fallback_readme_files(destdir): +"""Append README files as fallback to license files if a license files is missing""" + +fallback = True +readmes = [] +basedir = os.path.join(srctree, destdir) +for fn in os.listdir(basedir): +upper = fn.upper() +if upper.startswith("README"): +fullpath = os.path.join(basedir, fn) +readmes.append(fullpath) +if upper.startswith("COPYING") or "LICENCE" in upper or "LICENSE" in upper: +fallback = False +if fallback: +for readme in readmes: +licfiles.append(readme) + # Handle the dependencies def _handle_dependency(name, params, deptree): suffix = "-".join([self._npm_name(dep) for dep in deptree]) destdirs = [os.path.join("node_modules", dep) for dep in deptree] destdir = os.path.join(*destdirs) packages["${PN}-" + suffix] = destdir +_licfiles_append_fallback_readme_files(destdir) with open(shrinkwrap_file, "r") as f: shrinkwrap = json.load(f) @@ -237,7 +256,7 @@ class NpmRecipeHandler(RecipeHandler): bb.note("Handling licences ...") (licfiles, packages) = self._handle_licenses(srctree, shrinkwrap_file, dev) -split_pkg_licenses(guess_license(srctree, d), packages, lines_after, []) +split_pkg_licenses(guess_license(srctree, d, licfiles), packages, lines_after) classes.append("npm") handled.append("buildsystem") ReadMe files need to be passed to extravalues["LIC_FILES_CHKSUM"]. Will be fixed in the next version. -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#156737): https://lists.openembedded.org/g/openembedded-core/message/156737 Mute This Topic: https://lists.openembedded.org/mt/86148184/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[OE-core] [PATCH 09/12] recipetool: npm: Pass README as fallback to guess_license if a license is missing
From: Stefan Herbrechtsmeier Signed-off-by: Stefan Herbrechtsmeier --- scripts/lib/recipetool/create_npm.py | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index c939780931..27db6036fc 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py @@ -115,17 +115,36 @@ class NpmRecipeHandler(RecipeHandler): def _handle_licenses(self, srctree, shrinkwrap_file, dev): """Return the extra license files and the list of packages""" +licfiles = [] packages = {} # Handle the parent package packages["${PN}"] = "" +def _licfiles_append_fallback_readme_files(destdir): +"""Append README files as fallback to license files if a license files is missing""" + +fallback = True +readmes = [] +basedir = os.path.join(srctree, destdir) +for fn in os.listdir(basedir): +upper = fn.upper() +if upper.startswith("README"): +fullpath = os.path.join(basedir, fn) +readmes.append(fullpath) +if upper.startswith("COPYING") or "LICENCE" in upper or "LICENSE" in upper: +fallback = False +if fallback: +for readme in readmes: +licfiles.append(readme) + # Handle the dependencies def _handle_dependency(name, params, deptree): suffix = "-".join([self._npm_name(dep) for dep in deptree]) destdirs = [os.path.join("node_modules", dep) for dep in deptree] destdir = os.path.join(*destdirs) packages["${PN}-" + suffix] = destdir +_licfiles_append_fallback_readme_files(destdir) with open(shrinkwrap_file, "r") as f: shrinkwrap = json.load(f) @@ -237,7 +256,7 @@ class NpmRecipeHandler(RecipeHandler): bb.note("Handling licences ...") (licfiles, packages) = self._handle_licenses(srctree, shrinkwrap_file, dev) -split_pkg_licenses(guess_license(srctree, d), packages, lines_after, []) +split_pkg_licenses(guess_license(srctree, d, licfiles), packages, lines_after) classes.append("npm") handled.append("buildsystem") -- 2.20.1 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#156717): https://lists.openembedded.org/g/openembedded-core/message/156717 Mute This Topic: https://lists.openembedded.org/mt/86141421/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-