diff options
author | Frederic Martinsons <frederic.martinsons@gmail.com> | 2023-03-17 09:19:14 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-03-30 10:51:54 +0100 |
commit | 2b12c58724d250d1faf24072128e2de75dfe2c15 (patch) | |
tree | 9982e57cac6901bf437e3f682a6eceb8a88a84c0 /bitbake/lib/bb/tests/fetch.py | |
parent | d1f3941417d4b2bb56c63e716d750596f8b151a9 (diff) | |
download | poky-2b12c58724d250d1faf24072128e2de75dfe2c15.tar.gz |
bitbake: fetch2: Add checksum capability for crate fetcher
This change brings checksum verification of each crate
in a recipe, e.g
| SRC_URI += " \
| crate://crates.io/aho-corasick/0.7.20 \
| crate://crates.io/atomic-waker/1.1.0 \
| crate://crates.io/cc/1.0.79 \
| "
|
| SRC_URI[aho-corasick.sha256sum] = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
| SRC_URI[atomic-waker.sha256sum] = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599"
| SRC_URI[cc.sha256sum] = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
That will require to move the checksum initialization
after the possible call to urldata_init method in order
for the crate fetcher to parse the url.
Another way of doing could have been implementing a decodeurl
method that would have been specific for each fetcher class.
(Bitbake rev: 4920686c13dd66f9bfa4f7dd38d6e955f153eeec)
Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 2e5b404d95..da67168900 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -2377,6 +2377,13 @@ class CrateTest(FetcherTest): | |||
2377 | d = self.d | 2377 | d = self.d |
2378 | 2378 | ||
2379 | fetcher = bb.fetch2.Fetch(uris, self.d) | 2379 | fetcher = bb.fetch2.Fetch(uris, self.d) |
2380 | ud = fetcher.ud[fetcher.urls[0]] | ||
2381 | |||
2382 | self.assertIn("name", ud.parm) | ||
2383 | self.assertEqual(ud.parm["name"], "glob") | ||
2384 | self.assertIn("downloadfilename", ud.parm) | ||
2385 | self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") | ||
2386 | |||
2380 | fetcher.download() | 2387 | fetcher.download() |
2381 | fetcher.unpack(self.tempdir) | 2388 | fetcher.unpack(self.tempdir) |
2382 | self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) | 2389 | self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) |
@@ -2418,6 +2425,19 @@ class CrateTest(FetcherTest): | |||
2418 | d = self.d | 2425 | d = self.d |
2419 | 2426 | ||
2420 | fetcher = bb.fetch2.Fetch(uris, self.d) | 2427 | fetcher = bb.fetch2.Fetch(uris, self.d) |
2428 | ud = fetcher.ud[fetcher.urls[0]] | ||
2429 | |||
2430 | self.assertIn("name", ud.parm) | ||
2431 | self.assertEqual(ud.parm["name"], "glob") | ||
2432 | self.assertIn("downloadfilename", ud.parm) | ||
2433 | self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") | ||
2434 | |||
2435 | ud = fetcher.ud[fetcher.urls[1]] | ||
2436 | self.assertIn("name", ud.parm) | ||
2437 | self.assertEqual(ud.parm["name"], "time") | ||
2438 | self.assertIn("downloadfilename", ud.parm) | ||
2439 | self.assertEqual(ud.parm["downloadfilename"], "time-0.1.35.crate") | ||
2440 | |||
2421 | fetcher.download() | 2441 | fetcher.download() |
2422 | fetcher.unpack(self.tempdir) | 2442 | fetcher.unpack(self.tempdir) |
2423 | self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) | 2443 | self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) |
@@ -2427,6 +2447,18 @@ class CrateTest(FetcherTest): | |||
2427 | self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) | 2447 | self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) |
2428 | self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) | 2448 | self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) |
2429 | 2449 | ||
2450 | @skipIfNoNetwork() | ||
2451 | def test_crate_incorrect_cksum(self): | ||
2452 | uri = "crate://crates.io/aho-corasick/0.7.20" | ||
2453 | self.d.setVar('SRC_URI', uri) | ||
2454 | self.d.setVarFlag("SRC_URI", "aho-corasick.sha256sum", hashlib.sha256("Invalid".encode("utf-8")).hexdigest()) | ||
2455 | |||
2456 | uris = self.d.getVar('SRC_URI').split() | ||
2457 | |||
2458 | fetcher = bb.fetch2.Fetch(uris, self.d) | ||
2459 | with self.assertRaisesRegexp(bb.fetch2.FetchError, "Fetcher failure for URL"): | ||
2460 | fetcher.download() | ||
2461 | |||
2430 | class NPMTest(FetcherTest): | 2462 | class NPMTest(FetcherTest): |
2431 | def skipIfNoNpm(): | 2463 | def skipIfNoNpm(): |
2432 | import shutil | 2464 | import shutil |