tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] Fix rust cargo distfiles with embedded + subversions



Currently, for CARGO_CRATE_DEPENDS+= curl-sys-0.4.72+curl-8.6.0,
lang/rust/cargo.mk will derive the following sites for
SITES.curl-sys-0.4.72+curl-8.6.0.crate:

https://static.crates.io/crates/curl-sys/ -https://crates.io/api/v1/crates/curl-sys/8.6.0/download

The first entry will work, but the second one will fail with 403
because that's the wrong version for the curl-sys crate -- it's not
8.6.0 but 0.4.72+curl-8.6.0.  This should instead be:

https://static.crates.io/crates/curl-sys/ -https://crates.io/api/v1/crates/curl-sys/0.4.72+curl-8.6.0/download

The attached patch fixes this for any CARGO_CRATE_DEPENDS entries with
an embedded + subversion.  The logic is unchanged for entries without
any embedded + subversion; the new logic is conditional on that.

This is infrastructure that affects a lot of packages but I think it
is relatively low risk because (a) there is a working static.crates.io
entry, and (b) the new logic only affects cases that were broken
already.  I have been running with this patch since January with no
adverse consequences that I've seen.  Without this patch, I sometimes
saw fetch failures.

OK to commit before branch?
From 4486cb43ce35fe9f9c6700a6c10c0a68c14d8982 Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
Date: Mon, 20 Jan 2025 23:58:02 +0000
Subject: [PATCH] lang/rust/cargo.mk: Fix distfile URLs for `+' sub-versions.

For example, with curl-sys-0.4.75+curl-8.10.0, the URL should be

https://crates.io/api/v1/crates/curl-sys/0.4.75+curl-8.10.0/download

but the current logic instead produces

https://crates.io/api/v1/crates/curl-sys/8.10.0/download

which goes nowhere.
---
 lang/rust/cargo.mk | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lang/rust/cargo.mk b/lang/rust/cargo.mk
index 5a3ed0cf8306..71ae945cd42e 100644
--- a/lang/rust/cargo.mk
+++ b/lang/rust/cargo.mk
@@ -33,7 +33,13 @@ CARGO_WRKSRC?=		${WRKSRC}
 DISTFILES?=			${DEFAULT_DISTFILES}
 .for crate in ${CARGO_CRATE_DEPENDS}
 DISTFILES+=			${crate}.crate
+.  if ${crate:M*+*}
+# E.g., for `curl-sys-0.4.75+curl-8.10.0', we use the URL:
+# https://crates.io/api/v1/crates/curl-sys/0.4.77+curl-8.10.1/download
+SITES.${crate}.crate+=		-${MASTER_SITE_CRATESIO}${crate:C/-[0-9]+\.[0-9.]+.*$//}/${crate:C/^.*-([0-9]+\.[0-9.]+.*\+.*-[0-9]+\.[0-9]+.*)$/\1/}/download
+.  else
 SITES.${crate}.crate+=		-${MASTER_SITE_CRATESIO}${crate:C/-[0-9]+\.[0-9.]+.*$//}/${crate:C/^.*-([0-9]+\.[0-9.]+.*)$/\1/}/download
+.  endif
 EXTRACT_DIR.${crate}.crate?=	${CARGO_VENDOR_DIR}
 .endfor
 


Home | Main Index | Thread Index | Old Index