[PATCH 2/2] cargo.eclass: use direct CDN urls for crates.io
Eli Schwartz <[email protected]> Thu, 28 May 2026 17:56:26 -0400
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <[email protected]> |
There are four reasons for doing this: - it is the destination of a redirect at the urls we previously used, so less work - per https://blog.rust-lang.org/2024/03/11/crates-io-download-changes/ the API is "slow and expensive" and cargo now uses the CDN directly, too; all third-party "build systems" are recommended to do so as well - crates.io/api has started banning download agents that don't suitably identify themselves, and curl/wget without --user-agent fail. This will also be fixed by https://github.com/gentoo/portage/pull/1585 however that depends on users not manually setting FETCHCOMMAND with naive (no user-agent) values, nor using pk pkg env and copy/pasting. - shorter urls *plus* lack of need for arrow renaming will nontrivially reduce the size of SRC_URI Signed-off-by: Eli Schwartz <[email protected]> --- eclass/cargo.eclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 18cb2156cc8f..9ce135b5ef4b 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -296,7 +296,7 @@ _cargo_set_crate_uris() { name="${BASH_REMATCH[1]}" version="${BASH_REMATCH[2]}" fi - url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${name}-${version}.crate" + url="https://static.crates.io/crates/${name}/${nam}-${version}.crate" CARGO_CRATE_URIS+="${url} " # when invoked by pkgbump, avoid fetching all the crates -- 2.53.0