commit:     2835a612827749228ca89fbd982df2bb4f072742
Author:     Craig Andrews <candrews <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  9 19:20:03 2020 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Fri Jan 10 08:33:46 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2835a612

cargo.eclass: Use a regex to fix crate name/version extraction

Closes: https://bugs.gentoo.org/705044
Signed-off-by: Craig Andrews <candrews <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/14287
Signed-off-by: Georgy Yakovlev <gyakovlev <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 b1fb237e1d2..9a583307a6a 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -39,16 +39,13 @@ 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
+               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"
                echo "${url}"
        done

Reply via email to