From d63005ebea93b0285b437100ce8b6845746641da Mon Sep 17 00:00:00 2001 From: Johan Anderholm Date: Mon, 27 Apr 2026 15:51:23 +0200 Subject: [PATCH] bitbake: fetch2/crate: use CDN for fetching crates This avoids the 1 req/sec that the API has. Reference: https://github.com/rust-lang/crates.io/issues/13482 Reference: https://blog.rust-lang.org/2024/03/11/crates-io-download-changes/ [RP: Tweak to apply to 2.8] (Bitbake rev: b2404004135b669f8258c85c7b5aed4570a805c7) Signed-off-by: Johan Anderholm Signed-off-by: Richard Purdie Signed-off-by: Paul Barker --- bitbake/lib/bb/fetch2/crate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bitbake/lib/bb/fetch2/crate.py b/bitbake/lib/bb/fetch2/crate.py index 01d49435c3..738b8d4aad 100644 --- a/bitbake/lib/bb/fetch2/crate.py +++ b/bitbake/lib/bb/fetch2/crate.py @@ -68,8 +68,11 @@ class Crate(Wget): # if using upstream just fix it up nicely if host == 'crates.io': host = 'crates.io/api/v1/crates' + cdn_host = 'static.crates.io/crates' + else: + cdn_host = host - ud.url = "https://%s/%s/%s/download" % (host, name, version) + ud.url = "https://%s/%s/%s/download" % (cdn_host, name, version) ud.parm['downloadfilename'] = "%s-%s.crate" % (name, version) if 'name' not in ud.parm: ud.parm['name'] = '%s-%s' % (name, version)