Re: [PATCH 2/2] cargo.eclass: use direct CDN urls for crates.io

James Le Cuirot <[email protected]> Thu, 28 May 2026 23:01:33 +0100
Newsgroups gmane.linux.gentoo.devel
Message-ID <[email protected]>
On Thu, 2026-05-28 at 17:56 -0400, Eli Schwartz wrote:
> 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

Ack. Thanks for acting quickly here.
signature.asc (application/pgp-signature, 423 B)
-----BEGIN PGP SIGNATURE-----

iQEDBAAWCgCrFiEE6qETVs4yu3Lfuc3XsNCJZ6jP87QFAmoYuz0bFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRFQUExMTM1NkNFMzJCQjcyREZCOUNE
RDdCMEQwODk2N0E4Q0ZGM0I0ERxjaGV3aUBnZW50b28ub3JnAAoJELDQiWeoz/O0
tmIA/3cGdTNayRF3QLuy96C1YUoeA5y9b6J0JKkeXYwXxdw1AQDRU4PH8pFqV55e
GxtVRz4HpglEKCzrem8SBVqrz7qcCA==
=LzSm
-----END PGP SIGNATURE-----