summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorCraig Andrews <candrews@gentoo.org>2020-01-09 14:20:03 -0500
committerGeorgy Yakovlev <gyakovlev@gentoo.org>2020-01-10 00:33:46 -0800
commit2835a612827749228ca89fbd982df2bb4f072742 (patch)
treedefa407c856c0491e3b16b11c67dbcf2f1ab211b /eclass
parentx11-terms/alacritty: update live ebuild (diff)
downloadgentoo-2835a612827749228ca89fbd982df2bb4f072742.tar.gz
gentoo-2835a612827749228ca89fbd982df2bb4f072742.tar.bz2
gentoo-2835a612827749228ca89fbd982df2bb4f072742.zip
cargo.eclass: Use a regex to fix crate name/version extraction
Closes: https://bugs.gentoo.org/705044 Signed-off-by: Craig Andrews <candrews@gentoo.org> Closes: https://github.com/gentoo/gentoo/pull/14287 Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/cargo.eclass13
1 files changed, 5 insertions, 8 deletions
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index b1fb237e1d25..9a583307a6ab 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