[PATCH] cargo.eclass: separates crate unpacking logic in cargo_src_unpack into a separate function
"ingenarel (NeoJesus)" <[email protected]>
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <[email protected]> |
cargo_src_unpack currently does this:
goes through ${A}:
if it sees something without the .crate extension, unpack it instantly
if it sees a crate, then put it in an array of crates
Unpacks the list of crates
Calls cargo_gen_config
Which is fine, but what if the ebuild needs its own unpacking logic?
But also requires some crates unpacking too?
This is what I encountered in an ebuild of mine when I was working on a
npm eclass, and trying to package cinny-desktop, which needs both npm
stuff, and rust stuff
My simple fix was to just copy paste the crates unpacking logic from the
eclass itself:
https://codeberg.org/ingenarel-NeoJesus/nodejs-test-overlay/src/commit/06c9493756593a7b8427c7f8c7dd1a1402ed2559/net-im-tarball-mode/cinny-desktop/cinny-desktop-4.11.2.ebuild#L694
However, we can also change the cargo.eclass itself a little bit to
properly separate the logic of unpacking the tarballs into a separate
function while also not changing how cargo_src_unpack will behave in the
end
This patch does this:
cargo_src_unpack goes through ${A}:
if it sees something without the .crate extension, unpack it instantly
if it sees a crate, do nothing
calls cargo_crates_unpack
Calls cargo_gen_config
And cargo_crates_unpack does this:
goes through ${A}:
if it sees a crate, unpack it
I do acknowledge that gentoo is trying to use dep tarballs more now,
with the recent gentoo-crate-dist and gentoo-golang-dist accepting
tarballs for ::guru packages now
However, the logic for individual crates unpacking is still in the
eclass, and IMHO, I think it could be a bit better if the logic was
handled step by step in a way that it doesn't break existing ebuilds,
but also adds a bit more flexibility for ebuild maintainers
Signed-off-by: ingenarel (NeoJesus) <[email protected]>
---
eclass/cargo.eclass | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 185531490a..e9a4b5853f 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -518,10 +518,10 @@ cargo_update_crates () {
cargo_env "${@}" || die "Failed to update crates"
}
-# @FUNCTION: cargo_src_unpack
+# @FUNCTION: cargo_crates_unpack
# @DESCRIPTION:
-# Unpacks the package and the cargo registry.
-cargo_src_unpack() {
+# Unpacks the cargo crates only
+cargo_crates_unpack() {
debug-print-function ${FUNCNAME} "$@"
mkdir -p "${ECARGO_VENDOR}" "${S}" || die
@@ -533,9 +533,6 @@ cargo_src_unpack() {
*.crate)
crates+=( "${archive}" )
;;
- *)
- unpack "${archive}"
- ;;
esac
done
@@ -572,7 +569,27 @@ cargo_src_unpack() {
eqawarn "'pycargoebuild --crate-tarball' to create one."
fi
fi
+}
+
+# @FUNCTION: cargo_src_unpack
+# @DESCRIPTION:
+# Unpacks the package and the cargo registry.
+cargo_src_unpack() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ mkdir -p "${ECARGO_VENDOR}" "${S}" || die
+ local archive
+ for archive in ${A}; do
+ case "${archive}" in
+ *.crate)
+ ;;
+ *)
+ unpack "${archive}"
+ ;;
+ esac
+ done
+ cargo_crates_unpack
cargo_gen_config
}
--
2.55.0