diff options
author | Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com> | 2024-08-22 09:53:14 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-08-23 09:48:48 +0100 |
commit | 524e6b65a64c0310918cda9eaf5c1b6dd819dd0f (patch) | |
tree | 93f3b4f04cb3c635874700c586ac0b613ef40bee | |
parent | 18b37cc518b6fbb1a157b1afe84607313467aea2 (diff) | |
download | poky-524e6b65a64c0310918cda9eaf5c1b6dd819dd0f.tar.gz |
bitbake: fetch2/npmsw: fix fetching git revisions not on master
The NPM package.json documentation[1] states that git URLs may contain
a commit-ish suffix to specify a specific revision. When running
`npm install`, this revision will be looked for on any branch of the
repository.
The bitbake implementation however translates the URL stored in
package.json into a git URL to be fetch by the bitbake git fetcher. The
bitbake fetcher git.py, enforces the branch to be master by default. If
the revision specified in the package.json is not on the master branch,
the fetch will fail while the package.json is valid.
To fix this, append the ";nobranch=1" suffix to the revision in the git
URL to be fetched. This will make the bitbake git fetcher ignore the
branch and respect the behavior of `npm install``.
This can be tested with the following command:
$ devtool add --npm-dev https://github.com/seapath/cockpit-cluster-dashboard.git -B version
Which points to a project which has a package.json with a git URL:
```json
"devDependencies": {
"cockpit-repo": "git+https://github.com/cockpit-project/cockpit.git#d34cabacb8e5e1e028c7eea3d6e3b606d862b8ac"
}
```
In this repo, the specified revision is on the "main" branch, which
would fail without this fix.
[1] https://docs.npmjs.com/cli/v10/configuring-npm/package-json#git-urls-as-dependencies
Co-authored-by: Tanguy Raufflet <tanguy.raufflet@savoirfairelinux.com>
(Bitbake rev: 37a35adf7882f231c13643dbf9168497c6a242a1)
Signed-off-by: Tanguy Raufflet <tanguy.raufflet@savoirfairelinux.com>
Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/npmsw.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/npmsw.py b/bitbake/lib/bb/fetch2/npmsw.py index b55e885d7b..d8ed9df327 100644 --- a/bitbake/lib/bb/fetch2/npmsw.py +++ b/bitbake/lib/bb/fetch2/npmsw.py | |||
@@ -184,6 +184,7 @@ class NpmShrinkWrap(FetchMethod): | |||
184 | uri = URI("git://" + str(groups["url"])) | 184 | uri = URI("git://" + str(groups["url"])) |
185 | uri.params["protocol"] = str(groups["protocol"]) | 185 | uri.params["protocol"] = str(groups["protocol"]) |
186 | uri.params["rev"] = str(groups["rev"]) | 186 | uri.params["rev"] = str(groups["rev"]) |
187 | uri.params["nobranch"] = "1" | ||
187 | uri.params["destsuffix"] = destsuffix | 188 | uri.params["destsuffix"] = destsuffix |
188 | 189 | ||
189 | url = str(uri) | 190 | url = str(uri) |