crate.py: authorize crate url with parameters
Hello, note that this one will become mandatory for checksum verification of crates.
I didn't foresee that but it seems that having multiple version of crate in the same
project is common (I have that with zbus based project) and we can see also that for uutils-coreutils (e.g here
<https://github.com/openembedded/meta-openembedded/blob/master/meta-oe/recipes-core/uutils-coreutils/uutils-coreutils_0.0.17.bb#L146>
or here
<https://github.com/openembedded/meta-openembedded/blob/master/meta-oe/recipes-core/uutils-coreutils/uutils-coreutils_0.0.17.bb#L204>
)
So we must be able to rename the package via its url, to retake the example above, we
will have something like:
SRC_URI = " \
crate://crates.io/memoffset/0.6.5;name=remove_dir_all-0.6.5 \
crate://crates.io/memoffset/0.7.1;name=remove_dir_all-0.7.1 \
crate://crates.io/remove_dir_all/0.5.3;name=remove_dir_all-0.5.3 \
crate://crates.io/remove_dir_all/0.7.0;name=remove_dir_all-0.7.0 \
"
SRC_URI[memoffset-0.6.5.sha256sum] = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" SRC_URI[memoffset-0.7.1.sha256sum] = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" SRC_URI[remove_dir_all-0.5.3.sha256sum] = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" SRC_URI[remove_dir_all-0.7.0.sha256sum] = "882f368737489ea543bc5c340e6f3d34a28c39980bd9a979e47322b26f60ac40"
Quoted 104 lines · Frederic Martinsons via lists.openembedded.org
From: Frederic Martinsons <[email protected]>
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 <[email protected]>--- lib/bb/fetch2/crate.py | 9 ++++++--- lib/bb/tests/fetch.py | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-)lib/bb/fetch2/crate.py +4
-2@@ -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 specifiedlib/bb/fetch2/crate.py +2
-1@@ -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']))lib/bb/tests/fetch.py +4
-0@@ -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"
lib/bb/tests/fetch.py +12
-0+ 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")
lib/bb/tests/fetch.py +4
-0+ + 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-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#14564):
https://lists.openembedded.org/g/bitbake-devel/message/14564
Mute This Topic: https://lists.openembedded.org/mt/97627476/6213388
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-