From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0434D138334 for ; Thu, 29 Aug 2019 05:26:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3C4C5E0824; Thu, 29 Aug 2019 05:26:37 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DADFCE0814 for ; Thu, 29 Aug 2019 05:26:36 +0000 (UTC) Received: from hydra.local.sysdump.net (ip68-111-78-1.oc.oc.cox.net [68.111.78.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: gyakovlev) by smtp.gentoo.org (Postfix) with ESMTPSA id BCB5734A5CB; Thu, 29 Aug 2019 05:26:35 +0000 (UTC) From: Georgy Yakovlev To: gentoo-dev@lists.gentoo.org Cc: rust@gentoo.org, Georgy Yakovlev Subject: [gentoo-dev] [PATCH] cargo.eclass: add cargo_live_src_unpack() Date: Wed, 28 Aug 2019 22:26:13 -0700 Message-Id: <20190829052613.56890-1-gyakovlev@gentoo.org> X-Mailer: git-send-email 2.23.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 9d231559-6fd0-4943-9a6e-259103f1d245 X-Archives-Hash: 6f4d970a1b7de3d735fa59c168a6a707 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 --- 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