diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2022-01-29 03:29:39 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-05 17:46:27 +0000 |
commit | 73fa376d6502ab6f2cccfb25a1193d9b1c3c3bc8 (patch) | |
tree | e227897db9485f6f3500076135b76674d3a88660 | |
parent | 5924c6f007519cd8ea6cc8b316814d17b43048ca (diff) | |
download | bitbake-73fa376d6502ab6f2cccfb25a1193d9b1c3c3bc8.tar.gz |
fetch2: npm: Put all downloaded files in the npm2 directory
Previously npm files that specify downloadfilename= in the SRC_URI
would be downloaded to the root of ${DL_DIR} rather than in the
${DL_DIR}/npm2 directory where all other npm files are downloaded.
This should make it simpler when setting up and configuring a
premirror with the downloaded npm packages.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/fetch2/npm.py | 10 | ||||
-rw-r--r-- | lib/bb/fetch2/npmsw.py | 2 | ||||
-rw-r--r-- | lib/bb/tests/fetch.py | 2 |
3 files changed, 9 insertions, 5 deletions
diff --git a/lib/bb/fetch2/npm.py b/lib/bb/fetch2/npm.py index b3a3a444e..8f7c10ac9 100644 --- a/lib/bb/fetch2/npm.py +++ b/lib/bb/fetch2/npm.py @@ -52,9 +52,13 @@ def npm_filename(package, version): """Get the filename of a npm package""" return npm_package(package) + "-" + version + ".tgz" -def npm_localfile(package, version): +def npm_localfile(package, version=None): """Get the local filename of a npm package""" - return os.path.join("npm2", npm_filename(package, version)) + if version is not None: + filename = npm_filename(package, version) + else: + filename = package + return os.path.join("npm2", filename) def npm_integrity(integrity): """ @@ -157,7 +161,7 @@ class Npm(FetchMethod): # Using the 'downloadfilename' parameter as local filename # or the npm package name. if "downloadfilename" in ud.parm: - ud.localfile = d.expand(ud.parm["downloadfilename"]) + ud.localfile = npm_localfile(d.expand(ud.parm["downloadfilename"])) else: ud.localfile = npm_localfile(ud.package, ud.version) diff --git a/lib/bb/fetch2/npmsw.py b/lib/bb/fetch2/npmsw.py index 879ba5de0..a8c4d3528 100644 --- a/lib/bb/fetch2/npmsw.py +++ b/lib/bb/fetch2/npmsw.py @@ -117,7 +117,7 @@ class NpmShrinkWrap(FetchMethod): # Handle http tarball sources elif version.startswith("http") and integrity: - localfile = os.path.join("npm2", os.path.basename(version)) + localfile = npm_localfile(os.path.basename(version)) uri = URI(version) uri.params["downloadfilename"] = localfile diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index 8b13e178e..3fd8fac22 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -2399,7 +2399,7 @@ class NPMTest(FetcherTest): url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0;destsuffix=foo/bar;downloadfilename=foo-bar.tgz' fetcher = bb.fetch.Fetch([url], self.d) fetcher.download() - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'foo-bar.tgz'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'foo-bar.tgz'))) fetcher.unpack(self.unpackdir) unpackdir = os.path.join(self.unpackdir, 'foo', 'bar') self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json'))) |