From: Georgy Yakovlev <gyakovlev@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: rust@gentoo.org, Georgy Yakovlev <gyakovlev@gentoo.org>
Subject: [gentoo-dev] [PATCH] cargo.eclass: add cargo_live_src_unpack()
Date: Wed, 28 Aug 2019 22:26:13 -0700 [thread overview]
Message-ID: <20190829052613.56890-1-gyakovlev@gentoo.org> (raw)
This function will allow using 'cargo fetch' during src_fetch
Since only new cargo supports that, all live packages will
have to depend on >=rust-1.37.0
This enables us to ship live rust packages,
cargo fetch will download all crates and vendor them for offline
phases.
here's an example of src_unpack()
src_unpack() {
if [[ "${PV}" == *9999* ]]; then
git-r3_src_unpack
cargo_live_src_unpack
else
cargo_src_unpack
fi
}
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
---
eclass/cargo.eclass | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index b16e0e9d633..44d11cdb838 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -12,7 +12,12 @@
if [[ -z ${_CARGO_ECLASS} ]]; then
_CARGO_ECLASS=1
-CARGO_DEPEND="virtual/cargo"
+if [[ ${PV} == *9999* ]]; then
+ # we need at least this for cargo vendor subommand
+ CARGO_DEPEND=">=virtual/cargo-1.37.0"
+else
+ CARGO_DEPEND="virtual/cargo"
+fi
case ${EAPI} in
6) DEPEND="${CARGO_DEPEND}";;
@@ -97,6 +102,26 @@ cargo_src_unpack() {
cargo_gen_config
}
+# @FUNCTION: cargo_live_src_unpack
+# @DESCRIPTION:
+# Runs 'cargo fetch' and vendors downloaded crates for offline use, used in live ebuilds
+
+cargo_live_src_unpack() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ [[ "${PV}" == *9999* ]] || die "${FUNCNAME} only allowed in live/9999 ebuilds"
+ [[ "${EBUILD_PHASE}" == unpack ]] || die "${FUNCNAME} only allowed in src_unpack"
+
+ mkdir -p "${S}" || die
+
+ pushd "${S}" > /dev/null || die
+ CARGO_HOME="${ECARGO_HOME}" cargo fetch || die
+ CARGO_HOME="${ECARGO_HOME}" cargo vendor "${ECARGO_VENDOR}" || die
+ popd > /dev/null || die
+
+ cargo_gen_config
+}
+
# @FUNCTION: cargo_gen_config
# @DESCRIPTION:
# Generate the $CARGO_HOME/config necessary to use our local registry
--
2.23.0
next reply other threads:[~2019-08-29 5:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 5:26 Georgy Yakovlev [this message]
2019-08-29 13:16 ` [gentoo-dev] Re: [PATCH] cargo.eclass: add cargo_live_src_unpack() Dirkjan Ochtman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190829052613.56890-1-gyakovlev@gentoo.org \
--to=gyakovlev@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=rust@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox