summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorBELOUARGA Mohamed <m.belouarga@technologyandstrategy.com>2023-06-04 03:39:17 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-29 11:10:39 +0100
commitd988d3157886e044358547bf1f504b86c9f560c7 (patch)
tree1da9721a9d421df37ac300cd3c16e5ff0d058586 /bitbake
parenta825e136fe3fb39ef08323437c74e2cb0b24200c (diff)
downloadpoky-d988d3157886e044358547bf1f504b86c9f560c7.tar.gz
bitbake: fetch2/npmsw: Add support for the new format of the shrinkwrap file
Npm is a package manager that has its own manner to handle installation of packages. But it is not yocto friendly, for instance NPM fetch dependencies in the middle of compilation. The shrinkwrap file changed its format over npm versions, but npm does not version this file, so we can use it properly. The actual changes make NPM depencies work with the actual shrinkwrap format. (Bitbake rev: 19b9f7f0f451a636f3fdcdc1bb283ab431ede612) Signed-off-by: BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/npmsw.py25
1 files changed, 9 insertions, 16 deletions
diff --git a/bitbake/lib/bb/fetch2/npmsw.py b/bitbake/lib/bb/fetch2/npmsw.py
index cc81100b3a..359192a29e 100644
--- a/bitbake/lib/bb/fetch2/npmsw.py
+++ b/bitbake/lib/bb/fetch2/npmsw.py
@@ -41,20 +41,15 @@ def foreach_dependencies(shrinkwrap, callback=None, dev=False):
41 with: 41 with:
42 name = the package name (string) 42 name = the package name (string)
43 params = the package parameters (dictionary) 43 params = the package parameters (dictionary)
44 deptree = the package dependency tree (array of strings) 44 destdir = the destination of the package (string)
45 """ 45 """
46 def _walk_deps(deps, deptree): 46 packages = shrinkwrap.get("packages", {})
47 for name in deps: 47
48 subtree = [*deptree, name] 48 for package in packages:
49 _walk_deps(deps[name].get("dependencies", {}), subtree) 49 if package != "":
50 if callback is not None: 50 name = package.split('node_modules/')[-1]
51 if deps[name].get("dev", False) and not dev: 51 package_infos = packages.get(package, {})
52 continue 52 callback(name, package_infos, package)
53 elif deps[name].get("bundled", False):
54 continue
55 callback(name, deps[name], subtree)
56
57 _walk_deps(shrinkwrap.get("dependencies", {}), [])
58 53
59class NpmShrinkWrap(FetchMethod): 54class NpmShrinkWrap(FetchMethod):
60 """Class to fetch all package from a shrinkwrap file""" 55 """Class to fetch all package from a shrinkwrap file"""
@@ -75,12 +70,10 @@ class NpmShrinkWrap(FetchMethod):
75 # Resolve the dependencies 70 # Resolve the dependencies
76 ud.deps = [] 71 ud.deps = []
77 72
78 def _resolve_dependency(name, params, deptree): 73 def _resolve_dependency(name, params, destsuffix):
79 url = None 74 url = None
80 localpath = None 75 localpath = None
81 extrapaths = [] 76 extrapaths = []
82 destsubdirs = [os.path.join("node_modules", dep) for dep in deptree]
83 destsuffix = os.path.join(*destsubdirs)
84 unpack = True 77 unpack = True
85 78
86 integrity = params.get("integrity", None) 79 integrity = params.get("integrity", None)