bitbake: fetch2: npmsw: Add support for local tarball and link sources

(Bitbake rev: 4f983dc419a1a6f635a5d333f253d49244cec374)

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Stefan Herbrechtsmeier
2021-10-06 16:35:54 +02:00
committed by Richard Purdie
parent 00f2b6d0b7
commit fb437d6db1

View File

@@ -24,6 +24,7 @@ import bb
from bb.fetch2 import Fetch from bb.fetch2 import Fetch
from bb.fetch2 import FetchMethod from bb.fetch2 import FetchMethod
from bb.fetch2 import ParameterError from bb.fetch2 import ParameterError
from bb.fetch2 import runfetchcmd
from bb.fetch2 import URI from bb.fetch2 import URI
from bb.fetch2.npm import npm_integrity from bb.fetch2.npm import npm_integrity
from bb.fetch2.npm import npm_localfile from bb.fetch2.npm import npm_localfile
@@ -78,6 +79,7 @@ class NpmShrinkWrap(FetchMethod):
extrapaths = [] extrapaths = []
destsubdirs = [os.path.join("node_modules", dep) for dep in deptree] destsubdirs = [os.path.join("node_modules", dep) for dep in deptree]
destsuffix = os.path.join(*destsubdirs) destsuffix = os.path.join(*destsubdirs)
unpack = True
integrity = params.get("integrity", None) integrity = params.get("integrity", None)
resolved = params.get("resolved", None) resolved = params.get("resolved", None)
@@ -148,7 +150,12 @@ class NpmShrinkWrap(FetchMethod):
url = str(uri) url = str(uri)
# local tarball sources and local link sources are unsupported # Handle local tarball and link sources
elif version.startswith("file"):
localpath = version[5:]
if not version.endswith(".tgz"):
unpack = False
else: else:
raise ParameterError("Unsupported dependency: %s" % name, ud.url) raise ParameterError("Unsupported dependency: %s" % name, ud.url)
@@ -157,6 +164,7 @@ class NpmShrinkWrap(FetchMethod):
"localpath": localpath, "localpath": localpath,
"extrapaths": extrapaths, "extrapaths": extrapaths,
"destsuffix": destsuffix, "destsuffix": destsuffix,
"unpack": unpack,
}) })
try: try:
@@ -177,7 +185,7 @@ class NpmShrinkWrap(FetchMethod):
# This fetcher resolves multiple URIs from a shrinkwrap file and then # This fetcher resolves multiple URIs from a shrinkwrap file and then
# forwards it to a proxy fetcher. The management of the donestamp file, # forwards it to a proxy fetcher. The management of the donestamp file,
# the lockfile and the checksums are forwarded to the proxy fetcher. # the lockfile and the checksums are forwarded to the proxy fetcher.
ud.proxy = Fetch([dep["url"] for dep in ud.deps], data) ud.proxy = Fetch([dep["url"] for dep in ud.deps if dep["url"]], data)
ud.needdonestamp = False ud.needdonestamp = False
@staticmethod @staticmethod
@@ -237,7 +245,16 @@ class NpmShrinkWrap(FetchMethod):
for dep in manual: for dep in manual:
depdestdir = os.path.join(destdir, dep["destsuffix"]) depdestdir = os.path.join(destdir, dep["destsuffix"])
npm_unpack(dep["localpath"], depdestdir, d) if dep["url"]:
npm_unpack(dep["localpath"], depdestdir, d)
else:
depsrcdir= os.path.join(destdir, dep["localpath"])
if dep["unpack"]:
npm_unpack(depsrcdir, depdestdir, d)
else:
bb.utils.mkdirhier(depdestdir)
cmd = 'cp -fpPRH "%s/." .' % (depsrcdir)
runfetchcmd(cmd, d, workdir=depdestdir)
def clean(self, ud, d): def clean(self, ud, d):
"""Clean any existing full or partial download""" """Clean any existing full or partial download"""