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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 20A3E1581F3 for ; Wed, 27 Nov 2024 15:47:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 11472E080E; Wed, 27 Nov 2024 15:47:22 +0000 (UTC) Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0AAB9E07A7 for ; Wed, 27 Nov 2024 15:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732722438; x=1732981638; bh=zEV+UEyfUWc5tvYTH7KlW7t22OOarRDkpy1fCyGYxvI=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=UDl5c2rAyblV+I96BWxQo+ZHY1MQuW/2caAQP/z2uH1skIqUztXC9GQmVaZ5MB/P/ S4eLjItGMaxfL0j6e9chTU+AxRkwDSwyFkE4OOf8rjCST19+4/Y8kSH1yvSvq54/Pu FHiopPjd/LRBasbsVTcpII/R0CiaUh/1buyk/vastuVpkkXNF9W4UAvyMgweaoTeHb 6bhHjSCgconV9RKfSxqKMUNV7bj1dnX7Mfq2pY3kC3uJbF0nST29f9j6TBmwX/LJZ3 LsoPPuNQBTa7kAZkANWXo3XXW+5g94f/vkO1ZTlrtpTWujIvw1pLU/K4xh2FLhzKW+ paxftIhya5cKQ== Date: Wed, 27 Nov 2024 15:47:14 +0000 To: gentoo-dev@lists.gentoo.org, rust@gentoo.org From: MYT Cc: MYT Subject: [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea Message-ID: <20241127154707.39679-1-mytdragon@protonmail.com> Feedback-ID: 39378747:user:proton X-Pm-Message-ID: 7c23d9cb33e9266e04bc55df5af554b4da8444eb 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-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: fe1788fd-aa3a-46ff-90bd-59d243e4aca7 X-Archives-Hash: f22d24f05a8301479bbf509504661d36 --- eclass/cargo.eclass | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 95ff317e1f21..aa59d38d8600 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -93,6 +93,10 @@ ECARGO_VENDOR=3D"${ECARGO_HOME}/gentoo" # - optionally: the path to look for Cargo.toml in. # - This will also replace the string "%commit%" with the commit's check= sum. # - Defaults to: "${crate}-%commit%" +# - optionally: the git host so it would generate tarball download link. +# - E.g. gitlab +# - It fallbacks to detecting from URL if it's gitlab.com or github.com +# if no host provided. # # Example of a simple definition with no path to Cargo.toml: # @CODE @@ -108,6 +112,13 @@ ECARGO_VENDOR=3D"${ECARGO_HOME}/gentoo" # =09[rustpython-parser]=3D"https://github.com/RustPython/RustPython;4f38c= b68e4a97aeea9eb19673803a0bd5f655383;RustPython-%commit%/compiler/parser" # ) # @CODE +# +# Example with host defined: +# @CODE +# declare -A GIT_CRATES=3D( +#=09[clapper]=3D"https://gitlab.gnome.org/JanGernert/clapper-rs;530b6fd53a= 60563d8038f7a1d9d735d6dc496adb;clapper-rs-%commit%/libclapper-rs;gitlab" +# ) +# @CODE =20 # @ECLASS_VARIABLE: CARGO_OPTIONAL # @DEFAULT_UNSET @@ -217,22 +228,38 @@ _cargo_set_crate_uris() { =20 =09if declare -p GIT_CRATES &>/dev/null; then =09=09if [[ $(declare -p GIT_CRATES) =3D=3D "declare -A"* ]]; then -=09=09=09local crate commit crate_uri crate_dir repo_ext feat_expr +=09=09=09local crate commit crate_uri crate_dir host repo_ext feat_expr =20 =09=09=09for crate in "${!GIT_CRATES[@]}"; do -=09=09=09=09IFS=3D';' read -r crate_uri commit crate_dir <<< "${GIT_CRATES= [${crate}]}" - -=09=09=09=09case "${crate_uri}" in -=09=09=09=09=09https://github.com/*) +=09=09=09=09IFS=3D';' read -r crate_uri commit crate_dir host <<< "${GIT_C= RATES[${crate}]}" + +=09=09=09=09if [[ -z ${host} ]]; then +=09=09=09=09=09case "${crate_uri}" in +=09=09=09=09=09=09https://github.com/*) +=09=09=09=09=09=09=09host=3D"github" +=09=09=09=09=09=09;; +=09=09=09=09=09=09https://gitlab.com/*) +=09=09=09=09=09=09=09host=3D"gitlab" +=09=09=09=09=09=09;; +=09=09=09=09=09esac +=09=09=09=09fi + +=09=09=09=09case "${host}" in +=09=09=09=09=09github) =09=09=09=09=09=09repo_ext=3D".gh" =09=09=09=09=09=09repo_name=3D"${crate_uri##*/}" =09=09=09=09=09=09crate_uri=3D"${crate_uri%/}/archive/%commit%.tar.gz" =09=09=09=09=09;; -=09=09=09=09=09https://gitlab.com/*) +=09=09=09=09=09gitlab) =09=09=09=09=09=09repo_ext=3D".gl" =09=09=09=09=09=09repo_name=3D"${crate_uri##*/}" =09=09=09=09=09=09crate_uri=3D"${crate_uri%/}/-/archive/%commit%/${repo_na= me}-%commit%.tar.gz" =09=09=09=09=09;; +=09=09=09=09=09gitea) +=09=09=09=09=09=09repo_ext=3D".gt" +=09=09=09=09=09=09repo_name=3D"${crate_uri##*/}" +=09=09=09=09=09=09crate_uri=3D"${crate_uri%/}/archive/%commit%.tar.gz" +=09=09=09=09=09;; =09=09=09=09=09*) =09=09=09=09=09=09repo_ext=3D =09=09=09=09=09=09repo_name=3D"${crate}" @@ -320,11 +347,11 @@ _cargo_gen_git_config() { =09git_crates_type=3D"$(declare -p GIT_CRATES 2>&-)" =20 =09if [[ ${git_crates_type} =3D=3D "declare -A "* ]]; then -=09=09local crate commit crate_uri crate_dir +=09=09local crate commit crate_uri crate_dir host =09=09local -A crate_patches =20 =09=09for crate in "${!GIT_CRATES[@]}"; do -=09=09=09IFS=3D';' read -r crate_uri commit crate_dir <<< "${GIT_CRATES[${= crate}]}" +=09=09=09IFS=3D';' read -r crate_uri commit crate_dir host <<< "${GIT_CRAT= ES[${crate}]}" =09=09=09: "${crate_dir:=3D${crate}-%commit%}" =09=09=09crate_patches["${crate_uri}"]+=3D"${crate} =3D { path =3D \"${WOR= KDIR}/${crate_dir//%commit%/${commit}}\" };;" =09=09done --=20 2.45.2