commit:     89e3c1416372bd56bd6c8de7b5352c61b9f826f4
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 11 12:30:06 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jan 16 14:06:07 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=89e3c141

cargo.eclass: Emit a warning if the package uses 300+ crates

Emit a QA warning suggesting the use of crate tarball, when the package
in question uses 300 crates or more.  Such a long crate lists cause
ebuilds and Manifests to grow very fast, causing significant space
consumption on end user systems (including users who are not using
the package in question) and git history growth.  On top of that,
fetching that many crates takes significant time.

The number of 300 is pretty arbitrary, chosen approximately to match
Manifests that are over 100 KiB in size.  We should probably look into
lowering in the future, as more packages are transitioned.

Closes: https://github.com/gentoo/gentoo/pull/40096
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/cargo.eclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index b1285e13a5b2..0bc24feea222 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: cargo.eclass
@@ -527,6 +527,12 @@ cargo_src_unpack() {
                done < <(sha256sum -z "${crates[@]}" || die)
 
                popd >/dev/null || die
+
+               if [[ ${#crates[@]} -ge 300 ]]; then
+                       eqawarn "This package uses a very large number of 
CRATES.  Please provide"
+                       eqawarn "a crate tarball instead and fetch it via 
SRC_URI.  You can use"
+                       eqawarn "'pycargoebuild --crate-tarball' to create one."
+               fi
        fi
 
        cargo_gen_config

Reply via email to