diff options
author | 2020-03-04 16:17:45 +0100 | |
---|---|---|
committer | 2020-03-05 10:17:12 +0400 | |
commit | 5716d60c4cedaf6c13757ee4742f74b92c8ded06 (patch) | |
tree | 5044f608fcefe419526da692861605fca3420a97 | |
parent | bump rust (diff) | |
download | rust-5716d60c4cedaf6c13757ee4742f74b92c8ded06.tar.gz rust-5716d60c4cedaf6c13757ee4742f74b92c8ded06.tar.bz2 rust-5716d60c4cedaf6c13757ee4742f74b92c8ded06.zip |
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@yandex.com>
Signed-off-by: Mikhail Pukhlikov <cynede@gentoo.org>
-rw-r--r-- | eclass/cargo.eclass | 13 |
1 files 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="" |