From 5716d60c4cedaf6c13757ee4742f74b92c8ded06 Mon Sep 17 00:00:00 2001 From: stefson Date: Wed, 4 Mar 2020 16:17:45 +0100 Subject: cargo eclass: backport patch to use regex for name/version extraction taken from https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2835a612827749228ca89fbd982df2bb4f072742 original bug: https://bugs.gentoo.org/705044 Signed-off-by: Steffen Kuhn Signed-off-by: Mikhail Pukhlikov --- eclass/cargo.eclass | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 4e874f0..eacad3e 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -36,17 +36,14 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # @DESCRIPTION: # Generates the URIs to put in SRC_URI to help fetch dependencies. cargo_crate_uris() { + readonly regex='^(.*)-([0-9]+\.[0-9]+\.[0-9]+.*)$' local crate for crate in "$@"; do - local name version url pretag - name="${crate%-*}" - version="${crate##*-}" - pretag="[a-zA-Z]+" - if [[ $version =~ $pretag ]]; then - version="${name##*-}-${version}" - name="${name%-*}" - fi if [[ "${CARGO_FETCH_CRATES}" == "not" ]]; then + local name version url + [[ $crate =~ $regex ]] || die "Could not parse name and version from crate: $crate" + name="${BASH_REMATCH[1]}" + version="${BASH_REMATCH[2]}" url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate" else url="" -- cgit v1.2.3-65-gdbad