summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-30 09:49:04 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-30 09:50:46 +0100
commit8ee607b9729b6bf0bcfce71d5072f4b0386ede4d (patch)
tree82705f8c5c7e289d883c0e1be5c39e1e02d90abf /bitbake/lib/bb/fetch2
parent6f6c79029bc2020907295858449c725952d560a1 (diff)
downloadpoky-8ee607b9729b6bf0bcfce71d5072f4b0386ede4d.tar.gz
bitbake: fetch2/npmsw: Support old and new shrinkwrap formats
"fetch2/npmsw: Add support for the new format of the shrinkwrap file" added support for the new format shrinkwrap files but this regressed our tests which still use the old format. Similar to how npm handles this, support both for now until we can migrate our tests. (Bitbake rev: 9941b480a0e2a8b57f2ed069cd583f2784394a2b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/npmsw.py35
1 files changed, 26 insertions, 9 deletions
diff --git a/bitbake/lib/bb/fetch2/npmsw.py b/bitbake/lib/bb/fetch2/npmsw.py
index d89be10caf..971ccc9050 100644
--- a/bitbake/lib/bb/fetch2/npmsw.py
+++ b/bitbake/lib/bb/fetch2/npmsw.py
@@ -43,15 +43,32 @@ def foreach_dependencies(shrinkwrap, callback=None, dev=False):
43 params = the package parameters (dictionary) 43 params = the package parameters (dictionary)
44 destdir = the destination of the package (string) 44 destdir = the destination of the package (string)
45 """ 45 """
46 packages = shrinkwrap.get("packages", {}) 46 # For handling old style dependencies entries in shinkwrap files
47 47 def _walk_deps(deps, deptree):
48 for package in packages: 48 for name in deps:
49 if package != "": 49 subtree = [*deptree, name]
50 name = package.split('node_modules/')[-1] 50 _walk_deps(deps[name].get("dependencies", {}), subtree)
51 package_infos = packages.get(package, {}) 51 if callback is not None:
52 if dev == False and package_infos.get("dev", False): 52 if deps[name].get("dev", False) and not dev:
53 continue 53 continue
54 callback(name, package_infos, package) 54 elif deps[name].get("bundled", False):
55 continue
56 destsubdirs = [os.path.join("node_modules", dep) for dep in subtree]
57 destsuffix = os.path.join(*destsubdirs)
58 callback(name, deps[name], destsuffix)
59
60 # packages entry means new style shrinkwrap file, else use dependencies
61 packages = shrinkwrap.get("packages", None)
62 if packages is not None:
63 for package in packages:
64 if package != "":
65 name = package.split('node_modules/')[-1]
66 package_infos = packages.get(package, {})
67 if dev == False and package_infos.get("dev", False):
68 continue
69 callback(name, package_infos, package)
70 else:
71 _walk_deps(shrinkwrap.get("dependencies", {}), [])
55 72
56class NpmShrinkWrap(FetchMethod): 73class NpmShrinkWrap(FetchMethod):
57 """Class to fetch all package from a shrinkwrap file""" 74 """Class to fetch all package from a shrinkwrap file"""