From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: Steve Sakoman <steve@sakoman.com>
Cc: Frederic Martinsons <frederic.martinsons@gmail.com>,
"bitbake-devel@lists.openembedded.org"
<bitbake-devel@lists.openembedded.org>
Subject: RE: [bitbake-devel][PATCH v2 3/3] crate.py: authorize crate url with parameters
Date: Thu, 6 Apr 2023 03:40:27 +0000 [thread overview]
Message-ID: <DB5PR02MB10213D211F48E6ACF5D4505BFEF919@DB5PR02MB10213.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <20230317081916.1857201-3-frederic.martinsons@gmail.com>
Please cherry-pick this to Kirkstone and Langdale so that they can read
updated recipes that use crate:// URIs with parameters.
I assume it should be ok to cherry-pick part one of this series too, as
long as you do not cherry-pick part two, as it would be a breaking change.
//Peter
> -----Original Message-----
> From: bitbake-devel@lists.openembedded.org <bitbake-devel@lists.openembedded.org> On Behalf Of Frederic Martinsons
> Sent: den 17 mars 2023 09:19
> To: bitbake-devel@lists.openembedded.org
> Cc: Frederic Martinsons <frederic.martinsons@gmail.com>
> Subject: [bitbake-devel][PATCH v2 3/3] crate.py: authorize crate url with parameters
>
> From: Frederic Martinsons <frederic.martinsons@gmail.com>
>
> This allow to have classic fetch parameters
> (like destsuffix, sha256, name ...) not being
> considered by crate fetcher itself (and so mess
> up its download)
>
> Moreover, it allow to overload the name of the downloaded
> crate (maybe usefull if there is a naming clash between
> two crates coming from different repositories)
>
> Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
> ---
> lib/bb/fetch2/crate.py | 9 ++++++---
> lib/bb/tests/fetch.py | 24 ++++++++++++++++++++++++
> 2 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/lib/bb/fetch2/crate.py b/lib/bb/fetch2/crate.py
> index f8367ed3..590dc9c1 100644
> --- a/lib/bb/fetch2/crate.py
> +++ b/lib/bb/fetch2/crate.py
> @@ -56,8 +56,10 @@ class Crate(Wget):
> if len(parts) < 5:
> raise bb.fetch2.ParameterError("Invalid URL: Must be crate://HOST/NAME/VERSION", ud.url)
>
> - # last field is version
> - version = parts[len(parts) - 1]
> + # version is expected to be the last token
> + # but ignore possible url parameters which will be used
> + # by the top fetcher class
> + version, _, _ = parts[len(parts) -1].partition(";")
> # second to last field is name
> name = parts[len(parts) - 2]
> # host (this is to allow custom crate registries to be specified
> @@ -69,7 +71,8 @@ class Crate(Wget):
>
> ud.url = "https://%s/%s/%s/download" % (host, name, version)
> ud.parm['downloadfilename'] = "%s-%s.crate" % (name, version)
> - ud.parm['name'] = name
> + if 'name' not in ud.parm:
> + ud.parm['name'] = name
>
> logger.debug2("Fetching %s to %s" % (ud.url, ud.parm['downloadfilename']))
>
> diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
> index fd089bc8..85cf25e7 100644
> --- a/lib/bb/tests/fetch.py
> +++ b/lib/bb/tests/fetch.py
> @@ -2423,6 +2423,30 @@ 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_url_params(self):
> +
> + uri = "crate://crates.io/aho-corasick/0.7.20;name=aho-corasick-renamed"
> + self.d.setVar('SRC_URI', uri)
> +
> + uris = self.d.getVar('SRC_URI').split()
> + 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"], "aho-corasick-renamed")
> + self.assertIn("downloadfilename", ud.parm)
> + self.assertEqual(ud.parm["downloadfilename"], "aho-corasick-0.7.20.crate")
> +
> + fetcher.download()
> + fetcher.unpack(self.tempdir)
> + self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked'])
> + self.assertEqual(sorted(os.listdir(self.tempdir + "/download")), ['aho-corasick-0.7.20.crate', 'aho-corasick-0.7.20.crate.done'])
> + self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/aho-corasick-0.7.20/.cargo-checksum.json"))
> + self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/aho-corasick-0.7.20/src/lib.rs"))
> +
> @skipIfNoNetwork()
> def test_crate_incorrect_cksum(self):
> uri = "crate://crates.io/aho-corasick/0.7.20"
> --
> 2.34.1
next prev parent reply other threads:[~2023-04-06 3:40 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 [this message]
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 ` [bitbake-devel][PATCH v2 1/3] fetch2: Add checksum capability for crate fetcher Frédéric Martinsons
2023-03-21 17:26 ` 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=DB5PR02MB10213D211F48E6ACF5D4505BFEF919@DB5PR02MB10213.eurprd02.prod.outlook.com \
--to=peter.kjellerstedt@axis.com \
--cc=bitbake-devel@lists.openembedded.org \
--cc=frederic.martinsons@gmail.com \
--cc=steve@sakoman.com \
/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).