commit:     5716d60c4cedaf6c13757ee4742f74b92c8ded06
Author:     stefson <herrtimson <AT> yahoo <DOT> de>
AuthorDate: Wed Mar  4 15:17:45 2020 +0000
Commit:     Mikhail Pukhlikov <cynede <AT> gentoo <DOT> org>
CommitDate: Thu Mar  5 06:17:12 2020 +0000
URL:        https://gitweb.gentoo.org/repo/proj/rust.git/commit/?id=5716d60c

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 <nielson2 <AT> yandex.com>
Signed-off-by: Mikhail Pukhlikov <cynede <AT> gentoo.org>

 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=""

Reply via email to