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 40E3613933E for ; Sat, 3 Jul 2021 07:03:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 602C9E084E; Sat, 3 Jul 2021 07:03:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (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 86ECCE084E for ; Sat, 3 Jul 2021 07:03:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AC30534085A for ; Sat, 3 Jul 2021 07:03:08 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 24A157C1 for ; Sat, 3 Jul 2021 07:03:07 +0000 (UTC) From: "Georgy Yakovlev" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Georgy Yakovlev" Message-ID: <1625295550.772ae1adf22085b5bdb61566c420839525fc7feb.gyakovlev@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/cargo.eclass X-VCS-Directories: eclass/ X-VCS-Committer: gyakovlev X-VCS-Committer-Name: Georgy Yakovlev X-VCS-Revision: 772ae1adf22085b5bdb61566c420839525fc7feb X-VCS-Branch: master Date: Sat, 3 Jul 2021 07:03:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 7c9b0b86-0509-4c13-8055-52d1fa7611ea X-Archives-Hash: 72f7a7b3d180186dc74bcc497188f806 commit: 772ae1adf22085b5bdb61566c420839525fc7feb Author: Georgy Yakovlev gentoo org> AuthorDate: Sat Jul 3 05:51:54 2021 +0000 Commit: Georgy Yakovlev gentoo org> CommitDate: Sat Jul 3 06:59:10 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=772ae1ad cargo.eclass: make CRATES pre-inherit also make first arg to cargo_crate_uris optional die if CRATES variable is not defined in EAPI=8 Signed-off-by: Georgy Yakovlev gentoo.org> eclass/cargo.eclass | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 50237d302ce..938511e410f 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -34,6 +34,11 @@ case "${EAPI:-0}" in # 1.52 may need setting RUSTC_BOOTSTRAP envvar for some crates # 1.53 added cargo update --offline, can be used to update vulnerable crates from pre-fetched registry without editing toml RUST_DEPEND=">=virtual/rust-1.53" + + if [[ -z ${CRATES} && "${PV}" != *9999* ]]; then + eerror "undefined CRATES variable in non-live EAPI=8 ebuild" + die "CRATES variable not defined" + fi ;; *) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" @@ -54,6 +59,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # @ECLASS-VARIABLE: CRATES # @DEFAULT_UNSET +# @PRE_INHERIT # @DESCRIPTION: # bash string containing all crates package wants to download # used by cargo_crate_uris() @@ -66,7 +72,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # " # inherit cargo # ... -# SRC_URI="$(cargo_crate_uris ${CRATES})" +# SRC_URI="$(cargo_crate_uris)" # @CODE # @ECLASS-VARIABLE: CARGO_OPTIONAL @@ -131,10 +137,22 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # @FUNCTION: cargo_crate_uris # @DESCRIPTION: # Generates the URIs to put in SRC_URI to help fetch dependencies. +# Uses first argument as crate list. +# If no argument provided, uses CRATES variable. cargo_crate_uris() { local -r regex='^([a-zA-Z0-9_\-]+)-([0-9]+\.[0-9]+\.[0-9]+.*)$' - local crate - for crate in "$@"; do + local crate crates + + if [[ -n ${@} ]]; then + crates="$@" + elif [[ -n ${CRATES} ]]; then + crates="${CRATES}" + else + eerror "CRATES variable is not defined and nothing passed as argument" + die "Can't generate SRC_URI from empty input" + fi + + for crate in ${crates}; do local name version url [[ $crate =~ $regex ]] || die "Could not parse name and version from crate: $crate" name="${BASH_REMATCH[1]}"