* [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea
@ 2024-11-27 15:47 MYT
2024-11-27 16:14 ` Paul Zander
2024-12-03 11:39 ` Matt Jolly
0 siblings, 2 replies; 5+ messages in thread
From: MYT @ 2024-11-27 15:47 UTC (permalink / raw
To: gentoo-dev, rust; +Cc: MYT
---
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="${ECARGO_HOME}/gentoo"
# - optionally: the path to look for Cargo.toml in.
# - This will also replace the string "%commit%" with the commit's checksum.
# - 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="${ECARGO_HOME}/gentoo"
# [rustpython-parser]="https://github.com/RustPython/RustPython;4f38cb68e4a97aeea9eb19673803a0bd5f655383;RustPython-%commit%/compiler/parser"
# )
# @CODE
+#
+# Example with host defined:
+# @CODE
+# declare -A GIT_CRATES=(
+# [clapper]="https://gitlab.gnome.org/JanGernert/clapper-rs;530b6fd53a60563d8038f7a1d9d735d6dc496adb;clapper-rs-%commit%/libclapper-rs;gitlab"
+# )
+# @CODE
# @ECLASS_VARIABLE: CARGO_OPTIONAL
# @DEFAULT_UNSET
@@ -217,22 +228,38 @@ _cargo_set_crate_uris() {
if declare -p GIT_CRATES &>/dev/null; then
if [[ $(declare -p GIT_CRATES) == "declare -A"* ]]; then
- local crate commit crate_uri crate_dir repo_ext feat_expr
+ local crate commit crate_uri crate_dir host repo_ext feat_expr
for crate in "${!GIT_CRATES[@]}"; do
- IFS=';' read -r crate_uri commit crate_dir <<< "${GIT_CRATES[${crate}]}"
-
- case "${crate_uri}" in
- https://github.com/*)
+ IFS=';' read -r crate_uri commit crate_dir host <<< "${GIT_CRATES[${crate}]}"
+
+ if [[ -z ${host} ]]; then
+ case "${crate_uri}" in
+ https://github.com/*)
+ host="github"
+ ;;
+ https://gitlab.com/*)
+ host="gitlab"
+ ;;
+ esac
+ fi
+
+ case "${host}" in
+ github)
repo_ext=".gh"
repo_name="${crate_uri##*/}"
crate_uri="${crate_uri%/}/archive/%commit%.tar.gz"
;;
- https://gitlab.com/*)
+ gitlab)
repo_ext=".gl"
repo_name="${crate_uri##*/}"
crate_uri="${crate_uri%/}/-/archive/%commit%/${repo_name}-%commit%.tar.gz"
;;
+ gitea)
+ repo_ext=".gt"
+ repo_name="${crate_uri##*/}"
+ crate_uri="${crate_uri%/}/archive/%commit%.tar.gz"
+ ;;
*)
repo_ext=
repo_name="${crate}"
@@ -320,11 +347,11 @@ _cargo_gen_git_config() {
git_crates_type="$(declare -p GIT_CRATES 2>&-)"
if [[ ${git_crates_type} == "declare -A "* ]]; then
- local crate commit crate_uri crate_dir
+ local crate commit crate_uri crate_dir host
local -A crate_patches
for crate in "${!GIT_CRATES[@]}"; do
- IFS=';' read -r crate_uri commit crate_dir <<< "${GIT_CRATES[${crate}]}"
+ IFS=';' read -r crate_uri commit crate_dir host <<< "${GIT_CRATES[${crate}]}"
: "${crate_dir:=${crate}-%commit%}"
crate_patches["${crate_uri}"]+="${crate} = { path = \"${WORKDIR}/${crate_dir//%commit%/${commit}}\" };;"
done
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea
2024-11-27 15:47 [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea MYT
@ 2024-11-27 16:14 ` Paul Zander
2024-11-29 1:42 ` MYT
2024-12-03 11:39 ` Matt Jolly
1 sibling, 1 reply; 5+ messages in thread
From: Paul Zander @ 2024-11-27 16:14 UTC (permalink / raw
To: gentoo-dev
Hi,
associative arrays declared in functions are implicitly local in bash.
That means any associative array declared in global ebuild scope needs
to be declare global explicitly, as it's not guaranteed not to be
sourced within a function by a PM ( e.g. paludis does this ).
https://lists.gnu.org/archive/html/bug-bash/2011-08/msg00274.html
https://github.com/pkgcore/pkgcheck/issues/628
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea
2024-11-27 16:14 ` Paul Zander
@ 2024-11-29 1:42 ` MYT
2024-11-29 9:11 ` Ionen Wolkens
0 siblings, 1 reply; 5+ messages in thread
From: MYT @ 2024-11-29 1:42 UTC (permalink / raw
To: gentoo-dev
Hi Paul,
thanks for the reply. To be honest I'm a bit confused about your suggestion as I don't think I declared any new associative array. The patch only add new value in the string with delimeter. So I'm not sure what you expect me to change there :)
MYT
On Wednesday, 27 November 2024 at 16:14, Paul Zander <negril.nx+gentoo@gmail.com> wrote:
>
>
> Hi,
>
> associative arrays declared in functions are implicitly local in bash.
>
> That means any associative array declared in global ebuild scope needs
> to be declare global explicitly, as it's not guaranteed not to be
> sourced within a function by a PM ( e.g. paludis does this ).
>
> https://lists.gnu.org/archive/html/bug-bash/2011-08/msg00274.html
> https://github.com/pkgcore/pkgcheck/issues/628
>
> Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea
2024-11-29 1:42 ` MYT
@ 2024-11-29 9:11 ` Ionen Wolkens
0 siblings, 0 replies; 5+ messages in thread
From: Ionen Wolkens @ 2024-11-29 9:11 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1452 bytes --]
On Fri, Nov 29, 2024 at 01:42:40AM +0000, MYT wrote:
> Hi Paul,
>
> thanks for the reply. To be honest I'm a bit confused about your suggestion as I don't think I declared any new associative array. The patch only add new value in the string with delimeter. So I'm not sure what you expect me to change there :)
Probably(?) seen the new documentation bit with declare -A GIT_CRATES,
however it matches the other example and that's fine.
Also, -g should not really matter for that specific associative array
(should make no real difference if it's local or global) and we haven't
been using -g for that array across the tree in ebuilds.
If there is a problem, then it would be beyond the scope of the changes
you're proposing and it should be handled elsewhere (it'd be a
tree-wide issue).
tl;dr nothing for you to change there
>
> MYT
>
>
> On Wednesday, 27 November 2024 at 16:14, Paul Zander <negril.nx+gentoo@gmail.com> wrote:
>
> >
> >
> > Hi,
> >
> > associative arrays declared in functions are implicitly local in bash.
> >
> > That means any associative array declared in global ebuild scope needs
> > to be declare global explicitly, as it's not guaranteed not to be
> > sourced within a function by a PM ( e.g. paludis does this ).
> >
> > https://lists.gnu.org/archive/html/bug-bash/2011-08/msg00274.html
> > https://github.com/pkgcore/pkgcheck/issues/628
> >
> > Paul
>
--
ionen
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea
2024-11-27 15:47 [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea MYT
2024-11-27 16:14 ` Paul Zander
@ 2024-12-03 11:39 ` Matt Jolly
1 sibling, 0 replies; 5+ messages in thread
From: Matt Jolly @ 2024-12-03 11:39 UTC (permalink / raw
To: gentoo-dev
Hi MYT,
This looks good. I was going to merge however I encountered an issue;
there's no GCO signoff for this commit:
* https://www.gentoo.org/glep/glep-0076.html#certificate-of-origin
Please add the signoff (your pseudonym is fine) and I'm happy to merge.
Aside from that, since I already have you amending the commit message,
it would be nice if the commit message was a touch more descriptive, and
if possible had a bit of an explanation in the body.
If you're confused at all please reach out or open a Pull Request on
GitHub and we can work on it there.
Thanks for your effort on this!
Cheers,
Matt
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-03 11:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-27 15:47 [gentoo-dev] [PATCH] Add 'host' variable to GIT_CRATES to support other host like self-host gitlab or gitea MYT
2024-11-27 16:14 ` Paul Zander
2024-11-29 1:42 ` MYT
2024-11-29 9:11 ` Ionen Wolkens
2024-12-03 11:39 ` Matt Jolly
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox