From: "Frédéric Martinsons" <frederic.martinsons@gmail.com>
To: bitbake-devel@lists.openembedded.org
Subject: Re: [bitbake-devel][PATCH v2 1/3] fetch2: Add checksum capability for crate fetcher
Date: Tue, 21 Mar 2023 18:02:10 +0100 [thread overview]
Message-ID: <CA+cAkep0W_Jjvvpg2OEm+DE6SDUB98-OnghOyytijbU1qC1B2A@mail.gmail.com> (raw)
In-Reply-To: <20230317081916.1857201-1-frederic.martinsons@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5671 bytes --]
Hello,
Should I verify something more for this series?
I understood that it is a useful development to have in bitbake fetcher
(but will break things if series in oe-core and meta-oe are not applied
after this one) and I'm wondering if something block the review / apply ?
Please tell me, I'll do all my best to secure this.
Have a good day.
Le ven. 17 mars 2023, 09:19, <frederic.martinsons@gmail.com> a écrit :
> From: Frederic Martinsons <frederic.martinsons@gmail.com>
>
> 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.
>
> Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
> ---
> lib/bb/fetch2/__init__.py | 12 ++++++------
> lib/bb/tests/fetch.py | 32 ++++++++++++++++++++++++++++++++
> 2 files changed, 38 insertions(+), 6 deletions(-)
>
> diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
> index cf65727a..3ae83fa8 100644
> --- a/lib/bb/fetch2/__init__.py
> +++ b/lib/bb/fetch2/__init__.py
> @@ -1291,18 +1291,13 @@ class FetchData(object):
>
> if checksum_name in self.parm:
> checksum_expected = self.parm[checksum_name]
> - elif self.type not in ["http", "https", "ftp", "ftps",
> "sftp", "s3", "az"]:
> + elif self.type not in ["http", "https", "ftp", "ftps",
> "sftp", "s3", "az", "crate"]:
> checksum_expected = None
> else:
> checksum_expected = d.getVarFlag("SRC_URI", checksum_name)
>
> setattr(self, "%s_expected" % checksum_id, checksum_expected)
>
> - for checksum_id in CHECKSUM_LIST:
> - configure_checksum(checksum_id)
> -
> - self.ignore_checksums = False
> -
> self.names = self.parm.get("name",'default').split(',')
>
> self.method = None
> @@ -1324,6 +1319,11 @@ class FetchData(object):
> if hasattr(self.method, "urldata_init"):
> self.method.urldata_init(self, d)
>
> + for checksum_id in CHECKSUM_LIST:
> + configure_checksum(checksum_id)
> +
> + self.ignore_checksums = False
> +
> if "localpath" in self.parm:
> # if user sets localpath for file, use it instead.
> self.localpath = self.parm["localpath"]
> diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
> index 73eefc59..fd089bc8 100644
> --- a/lib/bb/tests/fetch.py
> +++ b/lib/bb/tests/fetch.py
> @@ -2377,6 +2377,13 @@ class CrateTest(FetcherTest):
> d = self.d
>
> fetcher = bb.fetch2.Fetch(uris, self.d)
> + ud = fetcher.ud[fetcher.urls[0]]
> +
> + self.assertIn("name", ud.parm)
> + self.assertEqual(ud.parm["name"], "glob")
> + self.assertIn("downloadfilename", ud.parm)
> + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate")
> +
> fetcher.download()
> fetcher.unpack(self.tempdir)
> self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home',
> 'download' , 'unpacked'])
> @@ -2394,6 +2401,19 @@ class CrateTest(FetcherTest):
> d = self.d
>
> fetcher = bb.fetch2.Fetch(uris, self.d)
> + ud = fetcher.ud[fetcher.urls[0]]
> +
> + self.assertIn("name", ud.parm)
> + self.assertEqual(ud.parm["name"], "glob")
> + self.assertIn("downloadfilename", ud.parm)
> + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate")
> +
> + ud = fetcher.ud[fetcher.urls[1]]
> + self.assertIn("name", ud.parm)
> + self.assertEqual(ud.parm["name"], "time")
> + self.assertIn("downloadfilename", ud.parm)
> + self.assertEqual(ud.parm["downloadfilename"], "time-0.1.35.crate")
> +
> fetcher.download()
> fetcher.unpack(self.tempdir)
> self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home',
> 'download' , 'unpacked'])
> @@ -2403,6 +2423,18 @@ class CrateTest(FetcherTest):
> self.assertTrue(os.path.exists(self.tempdir +
> "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json"))
> self.assertTrue(os.path.exists(self.tempdir +
> "/cargo_home/bitbake/time-0.1.35/src/lib.rs"))
>
> + @skipIfNoNetwork()
> + def test_crate_incorrect_cksum(self):
> + uri = "crate://crates.io/aho-corasick/0.7.20"
> + self.d.setVar('SRC_URI', uri)
> + self.d.setVarFlag("SRC_URI", "aho-corasick.sha256sum",
> hashlib.sha256("Invalid".encode("utf-8")).hexdigest())
> +
> + uris = self.d.getVar('SRC_URI').split()
> +
> + fetcher = bb.fetch2.Fetch(uris, self.d)
> + with self.assertRaisesRegexp(bb.fetch2.FetchError, "Fetcher
> failure for URL"):
> + fetcher.download()
> +
> class NPMTest(FetcherTest):
> def skipIfNoNpm():
> import shutil
> --
> 2.34.1
>
>
[-- Attachment #2: Type: text/html, Size: 7848 bytes --]
next prev parent reply other threads:[~2023-03-21 17:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 8:19 [bitbake-devel][PATCH v2 1/3] fetch2: Add checksum capability for crate fetcher frederic.martinsons
2023-03-17 8:19 ` [bitbake-devel][PATCH v2 2/3] crate.py: make checksum verification mandatory frederic.martinsons
2023-03-17 8:19 ` [bitbake-devel][PATCH v2 3/3] crate.py: authorize crate url with parameters frederic.martinsons
2023-04-06 3:40 ` Peter Kjellerstedt
2023-04-06 8:42 ` Richard Purdie
2023-04-06 10:56 ` Peter Kjellerstedt
2023-04-06 11:12 ` Richard Purdie
2023-03-21 17:02 ` Frédéric Martinsons [this message]
2023-03-21 17:26 ` [bitbake-devel][PATCH v2 1/3] fetch2: Add checksum capability for crate fetcher Frédéric Martinsons
2023-03-21 18:34 ` Alexander Kanavin
2023-03-21 19:51 ` Frédéric Martinsons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+cAkep0W_Jjvvpg2OEm+DE6SDUB98-OnghOyytijbU1qC1B2A@mail.gmail.com \
--to=frederic.martinsons@gmail.com \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).