mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
bitbake: fetch2: npmsw: remove old lockfile format support
Remove support for the old lockfile format. The old lockfile format is required by npm 6 / Node.js 14 which is out of maintenance [2]. [1] https://docs.npmjs.com/cli/v6/configuring-npm/package-lock-json [2] https://nodejs.org/en/about/previous-releases (Bitbake rev: 7824e19483d9b60a259d6e3a4c7068fade94f2bf) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
c691d4d53f
commit
eb0c87fa4c
|
@ -37,40 +37,26 @@ def foreach_dependencies(shrinkwrap, callback=None, dev=False):
|
||||||
"""
|
"""
|
||||||
Run a callback for each dependencies of a shrinkwrap file.
|
Run a callback for each dependencies of a shrinkwrap file.
|
||||||
The callback is using the format:
|
The callback is using the format:
|
||||||
callback(name, params, deptree)
|
callback(name, data, location)
|
||||||
with:
|
with:
|
||||||
name = the package name (string)
|
name = the package name (string)
|
||||||
params = the package parameters (dictionary)
|
data = the package data (dictionary)
|
||||||
destdir = the destination of the package (string)
|
location = the location of the package (string)
|
||||||
"""
|
"""
|
||||||
# For handling old style dependencies entries in shinkwrap files
|
packages = shrinkwrap.get("packages")
|
||||||
def _walk_deps(deps, deptree):
|
if not packages:
|
||||||
for name in deps:
|
raise FetchError("Invalid shrinkwrap file format")
|
||||||
subtree = [*deptree, name]
|
|
||||||
_walk_deps(deps[name].get("dependencies", {}), subtree)
|
|
||||||
if callback is not None:
|
|
||||||
if deps[name].get("dev", False) and not dev:
|
|
||||||
continue
|
|
||||||
elif deps[name].get("bundled", False):
|
|
||||||
continue
|
|
||||||
destsubdirs = [os.path.join("node_modules", dep) for dep in subtree]
|
|
||||||
destsuffix = os.path.join(*destsubdirs)
|
|
||||||
callback(name, deps[name], destsuffix)
|
|
||||||
|
|
||||||
# packages entry means new style shrinkwrap file, else use dependencies
|
for location, data in packages.items():
|
||||||
packages = shrinkwrap.get("packages", None)
|
# Skip empty main and local link target packages
|
||||||
if packages is not None:
|
if not location.startswith('node_modules/'):
|
||||||
for package in packages:
|
continue
|
||||||
if package != "":
|
elif not dev and data.get("dev", False):
|
||||||
name = package.split('node_modules/')[-1]
|
continue
|
||||||
package_infos = packages.get(package, {})
|
elif data.get("inBundle", False):
|
||||||
if dev == False and package_infos.get("dev", False):
|
continue
|
||||||
continue
|
name = location.split('node_modules/')[-1]
|
||||||
elif package_infos.get("inBundle", False):
|
callback(name, data, location)
|
||||||
continue
|
|
||||||
callback(name, package_infos, package)
|
|
||||||
else:
|
|
||||||
_walk_deps(shrinkwrap.get("dependencies", {}), [])
|
|
||||||
|
|
||||||
class NpmShrinkWrap(FetchMethod):
|
class NpmShrinkWrap(FetchMethod):
|
||||||
"""Class to fetch all package from a shrinkwrap file"""
|
"""Class to fetch all package from a shrinkwrap file"""
|
||||||
|
@ -97,12 +83,18 @@ class NpmShrinkWrap(FetchMethod):
|
||||||
extrapaths = []
|
extrapaths = []
|
||||||
unpack = True
|
unpack = True
|
||||||
|
|
||||||
integrity = params.get("integrity", None)
|
integrity = params.get("integrity")
|
||||||
resolved = params.get("resolved", None)
|
resolved = params.get("resolved")
|
||||||
version = params.get("version", resolved)
|
version = params.get("version")
|
||||||
|
link = params.get("link", False)
|
||||||
|
|
||||||
|
# Handle link sources
|
||||||
|
if link:
|
||||||
|
localpath = resolved
|
||||||
|
unpack = False
|
||||||
|
|
||||||
# Handle registry sources
|
# Handle registry sources
|
||||||
if is_semver(version) and integrity:
|
elif version and is_semver(version) and integrity:
|
||||||
# Handle duplicate dependencies without url
|
# Handle duplicate dependencies without url
|
||||||
if not resolved:
|
if not resolved:
|
||||||
return
|
return
|
||||||
|
@ -130,10 +122,10 @@ class NpmShrinkWrap(FetchMethod):
|
||||||
extrapaths.append(resolvefile)
|
extrapaths.append(resolvefile)
|
||||||
|
|
||||||
# Handle http tarball sources
|
# Handle http tarball sources
|
||||||
elif version.startswith("http") and integrity:
|
elif resolved.startswith("http") and integrity:
|
||||||
localfile = npm_localfile(os.path.basename(version))
|
localfile = npm_localfile(os.path.basename(resolved))
|
||||||
|
|
||||||
uri = URI(version)
|
uri = URI(resolved)
|
||||||
uri.params["downloadfilename"] = localfile
|
uri.params["downloadfilename"] = localfile
|
||||||
|
|
||||||
checksum_name, checksum_expected = npm_integrity(integrity)
|
checksum_name, checksum_expected = npm_integrity(integrity)
|
||||||
|
@ -143,28 +135,12 @@ class NpmShrinkWrap(FetchMethod):
|
||||||
|
|
||||||
localpath = os.path.join(d.getVar("DL_DIR"), localfile)
|
localpath = os.path.join(d.getVar("DL_DIR"), localfile)
|
||||||
|
|
||||||
# Handle local tarball and link sources
|
# Handle local tarball sources
|
||||||
elif version.startswith("file"):
|
elif resolved.startswith("file"):
|
||||||
localpath = version[5:]
|
localpath = resolved[5:]
|
||||||
if not version.endswith(".tgz"):
|
|
||||||
unpack = False
|
|
||||||
|
|
||||||
# Handle git sources
|
# Handle git sources
|
||||||
elif version.startswith(("git", "bitbucket","gist")) or (
|
elif resolved.startswith("git"):
|
||||||
not version.endswith((".tgz", ".tar", ".tar.gz"))
|
|
||||||
and not version.startswith((".", "@", "/"))
|
|
||||||
and "/" in version
|
|
||||||
):
|
|
||||||
if version.startswith("github:"):
|
|
||||||
version = "git+https://github.com/" + version[len("github:"):]
|
|
||||||
elif version.startswith("gist:"):
|
|
||||||
version = "git+https://gist.github.com/" + version[len("gist:"):]
|
|
||||||
elif version.startswith("bitbucket:"):
|
|
||||||
version = "git+https://bitbucket.org/" + version[len("bitbucket:"):]
|
|
||||||
elif version.startswith("gitlab:"):
|
|
||||||
version = "git+https://gitlab.com/" + version[len("gitlab:"):]
|
|
||||||
elif not version.startswith(("git+","git:")):
|
|
||||||
version = "git+https://github.com/" + version
|
|
||||||
regex = re.compile(r"""
|
regex = re.compile(r"""
|
||||||
^
|
^
|
||||||
git\+
|
git\+
|
||||||
|
@ -176,10 +152,9 @@ class NpmShrinkWrap(FetchMethod):
|
||||||
$
|
$
|
||||||
""", re.VERBOSE)
|
""", re.VERBOSE)
|
||||||
|
|
||||||
match = regex.match(version)
|
match = regex.match(resolved)
|
||||||
|
|
||||||
if not match:
|
if not match:
|
||||||
raise ParameterError("Invalid git url: %s" % version, ud.url)
|
raise ParameterError("Invalid git url: %s" % resolved, ud.url)
|
||||||
|
|
||||||
groups = match.groupdict()
|
groups = match.groupdict()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user