1 |
commit: 2835a612827749228ca89fbd982df2bb4f072742 |
2 |
Author: Craig Andrews <candrews <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 9 19:20:03 2020 +0000 |
4 |
Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jan 10 08:33:46 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2835a612 |
7 |
|
8 |
cargo.eclass: Use a regex to fix crate name/version extraction |
9 |
|
10 |
Closes: https://bugs.gentoo.org/705044 |
11 |
Signed-off-by: Craig Andrews <candrews <AT> gentoo.org> |
12 |
Closes: https://github.com/gentoo/gentoo/pull/14287 |
13 |
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org> |
14 |
|
15 |
eclass/cargo.eclass | 13 +++++-------- |
16 |
1 file changed, 5 insertions(+), 8 deletions(-) |
17 |
|
18 |
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass |
19 |
index b1fb237e1d2..9a583307a6a 100644 |
20 |
--- a/eclass/cargo.eclass |
21 |
+++ b/eclass/cargo.eclass |
22 |
@@ -39,16 +39,13 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" |
23 |
# @DESCRIPTION: |
24 |
# Generates the URIs to put in SRC_URI to help fetch dependencies. |
25 |
cargo_crate_uris() { |
26 |
+ readonly regex='^(.*)-([0-9]+\.[0-9]+\.[0-9]+.*)$' |
27 |
local crate |
28 |
for crate in "$@"; do |
29 |
- local name version url pretag |
30 |
- name="${crate%-*}" |
31 |
- version="${crate##*-}" |
32 |
- pretag="^[a-zA-Z]+" |
33 |
- if [[ $version =~ $pretag ]]; then |
34 |
- version="${name##*-}-${version}" |
35 |
- name="${name%-*}" |
36 |
- fi |
37 |
+ local name version url |
38 |
+ [[ $crate =~ $regex ]] || die "Could not parse name and version from crate: $crate" |
39 |
+ name="${BASH_REMATCH[1]}" |
40 |
+ version="${BASH_REMATCH[2]}" |
41 |
url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate" |
42 |
echo "${url}" |
43 |
done |