1 |
commit: 0d640ada691b569aa2037e3f66f1ed4066efda3a |
2 |
Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Aug 29 05:13:47 2019 +0000 |
4 |
Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Aug 29 18:27:27 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0d640ada |
7 |
|
8 |
cargo.eclass: add cargo_live_src_unpack() |
9 |
|
10 |
This function will allow using 'cargo fetch' during src_unpack |
11 |
Since only new cargo supports vendoring, all live packages will |
12 |
have to depend on >=rust-1.37.0 |
13 |
|
14 |
This enables us to ship live rust packages, |
15 |
cargo fetch will download all crates and vendor them for offline |
16 |
phases. |
17 |
|
18 |
here's an example of src_unpack() |
19 |
|
20 |
src_unpack() { |
21 |
if [[ "${PV}" == *9999* ]]; then |
22 |
git-r3_src_unpack |
23 |
cargo_live_src_unpack |
24 |
else |
25 |
cargo_src_unpack |
26 |
fi |
27 |
} |
28 |
|
29 |
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org> |
30 |
|
31 |
eclass/cargo.eclass | 27 ++++++++++++++++++++++++++- |
32 |
1 file changed, 26 insertions(+), 1 deletion(-) |
33 |
|
34 |
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass |
35 |
index b16e0e9d633..44d11cdb838 100644 |
36 |
--- a/eclass/cargo.eclass |
37 |
+++ b/eclass/cargo.eclass |
38 |
@@ -12,7 +12,12 @@ |
39 |
if [[ -z ${_CARGO_ECLASS} ]]; then |
40 |
_CARGO_ECLASS=1 |
41 |
|
42 |
-CARGO_DEPEND="virtual/cargo" |
43 |
+if [[ ${PV} == *9999* ]]; then |
44 |
+ # we need at least this for cargo vendor subommand |
45 |
+ CARGO_DEPEND=">=virtual/cargo-1.37.0" |
46 |
+else |
47 |
+ CARGO_DEPEND="virtual/cargo" |
48 |
+fi |
49 |
|
50 |
case ${EAPI} in |
51 |
6) DEPEND="${CARGO_DEPEND}";; |
52 |
@@ -97,6 +102,26 @@ cargo_src_unpack() { |
53 |
cargo_gen_config |
54 |
} |
55 |
|
56 |
+# @FUNCTION: cargo_live_src_unpack |
57 |
+# @DESCRIPTION: |
58 |
+# Runs 'cargo fetch' and vendors downloaded crates for offline use, used in live ebuilds |
59 |
+ |
60 |
+cargo_live_src_unpack() { |
61 |
+ debug-print-function ${FUNCNAME} "$@" |
62 |
+ |
63 |
+ [[ "${PV}" == *9999* ]] || die "${FUNCNAME} only allowed in live/9999 ebuilds" |
64 |
+ [[ "${EBUILD_PHASE}" == unpack ]] || die "${FUNCNAME} only allowed in src_unpack" |
65 |
+ |
66 |
+ mkdir -p "${S}" || die |
67 |
+ |
68 |
+ pushd "${S}" > /dev/null || die |
69 |
+ CARGO_HOME="${ECARGO_HOME}" cargo fetch || die |
70 |
+ CARGO_HOME="${ECARGO_HOME}" cargo vendor "${ECARGO_VENDOR}" || die |
71 |
+ popd > /dev/null || die |
72 |
+ |
73 |
+ cargo_gen_config |
74 |
+} |
75 |
+ |
76 |
# @FUNCTION: cargo_gen_config |
77 |
# @DESCRIPTION: |
78 |
# Generate the $CARGO_HOME/config necessary to use our local registry |