Mailing List Archive

[PATCH v2 1/2] check-reqs.eclass: runtime disk checks for any path.
Allow checking any runtime path for installing ever-larger packages.

CHECKREQS_DISK_RUNTIME=( /boot:40M /:350M /opt:500M )

Recent example of large packages:

gentoo-kernel-bin:
/ >=350MB/version (in /lib/modules)
/boot >=40MB/version

rust-bin:
/opt >=450MB/version

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
---
eclass/check-reqs.eclass | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
index fac2f4553d74..1c59c69489a9 100644
--- a/eclass/check-reqs.eclass
+++ b/eclass/check-reqs.eclass
@@ -30,6 +30,13 @@
# # install will need this much space in /var
# CHECKREQS_DISK_VAR="1024M"
#
+# # install will need this much space in listed paths.
+# CHECKREQS_DISK_RUNTIME=(
+# /var:1G
+# /boot/efi:32M
+# /opt/giant-package-with-dedicated-disk:100G
+# )
+#
# @CODE
#
# If you don't specify a value for, say, CHECKREQS_MEMORY, then the test is not
@@ -66,6 +73,11 @@ _CHECK_REQS_ECLASS=1
# @DESCRIPTION:
# How much space is needed in /var? Eg.: CHECKREQS_DISK_VAR=3000M

+# @ECLASS_VARIABLE: CHECKREQS_DISK_RUNTIME
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# How much space is needed in paths? Eg.: CHECKREQS_DISK_RUNTIME=( /:1G /var:5G )
+
# @ECLASS_VARIABLE: CHECKREQS_DONOTHING
# @USER_VARIABLE
# @DEFAULT_UNSET
@@ -120,6 +132,7 @@ _check-reqs_prepare() {
debug-print-function ${FUNCNAME} "$@"

if [[ -z ${CHECKREQS_MEMORY} &&
+ "${#CHECKREQS_DISK_RUNTIME[@]}" -eq 0 &&
-z ${CHECKREQS_DISK_BUILD} &&
-z ${CHECKREQS_DISK_USR} &&
-z ${CHECKREQS_DISK_VAR} ]]; then
@@ -161,6 +174,16 @@ _check-reqs_run() {
fi

if [[ ${MERGE_TYPE} != buildonly ]]; then
+ if [[ "${#CHECKREQS_DISK_RUNTIME[@]}" -gt 0 ]]; then
+ for _path_size in "${CHECKREQS_DISK_RUNTIME[@]}"; do
+ _path=${_path_size/:*}
+ _size=${_path_size/*:}
+ _check-reqs_disk \
+ "${EROOT%/}${_path}" "${_size}"
+ done
+ unset _path_size _path _size
+ fi
+
[[ -n ${CHECKREQS_DISK_USR} ]] && \
_check-reqs_disk \
"${EROOT%/}/usr" \
--
2.43.0
Re: [PATCH v2 1/2] check-reqs.eclass: runtime disk checks for any path. [ In reply to ]
Am 26.02.24 um 07:31 schrieb Robin H. Johnson:
> Allow checking any runtime path for installing ever-larger packages.
>
> CHECKREQS_DISK_RUNTIME=( /boot:40M /:350M /opt:500M )

In the example case: Shouldn't the eclass check for 850M on / if /opt is
not a separate partition?
I am not sure how often it really happens that multiple large
requirements for different folders exist.

>
> Recent example of large packages:
>
> gentoo-kernel-bin:
> / >=350MB/version (in /lib/modules)
> /boot >=40MB/version
>
> rust-bin:
> /opt >=450MB/version
>
> Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
> ---
> eclass/check-reqs.eclass | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
> index fac2f4553d74..1c59c69489a9 100644
> --- a/eclass/check-reqs.eclass
> +++ b/eclass/check-reqs.eclass
> @@ -30,6 +30,13 @@
> # # install will need this much space in /var
> # CHECKREQS_DISK_VAR="1024M"
> #
> +# # install will need this much space in listed paths.
> +# CHECKREQS_DISK_RUNTIME=(
> +# /var:1G
> +# /boot/efi:32M
> +# /opt/giant-package-with-dedicated-disk:100G
> +# )
> +#
> # @CODE
> #
> # If you don't specify a value for, say, CHECKREQS_MEMORY, then the test is not
> @@ -66,6 +73,11 @@ _CHECK_REQS_ECLASS=1
> # @DESCRIPTION:
> # How much space is needed in /var? Eg.: CHECKREQS_DISK_VAR=3000M
>
> +# @ECLASS_VARIABLE: CHECKREQS_DISK_RUNTIME
> +# @DEFAULT_UNSET
> +# @DESCRIPTION:
> +# How much space is needed in paths? Eg.: CHECKREQS_DISK_RUNTIME=( /:1G /var:5G )
> +
> # @ECLASS_VARIABLE: CHECKREQS_DONOTHING
> # @USER_VARIABLE
> # @DEFAULT_UNSET
> @@ -120,6 +132,7 @@ _check-reqs_prepare() {
> debug-print-function ${FUNCNAME} "$@"
>
> if [[ -z ${CHECKREQS_MEMORY} &&
> + "${#CHECKREQS_DISK_RUNTIME[@]}" -eq 0 &&
> -z ${CHECKREQS_DISK_BUILD} &&
> -z ${CHECKREQS_DISK_USR} &&
> -z ${CHECKREQS_DISK_VAR} ]]; then
> @@ -161,6 +174,16 @@ _check-reqs_run() {
> fi
>
> if [[ ${MERGE_TYPE} != buildonly ]]; then
> + if [[ "${#CHECKREQS_DISK_RUNTIME[@]}" -gt 0 ]]; then
> + for _path_size in "${CHECKREQS_DISK_RUNTIME[@]}"; do
> + _path=${_path_size/:*}
> + _size=${_path_size/*:}
> + _check-reqs_disk \
> + "${EROOT%/}${_path}" "${_size}"
> + done
> + unset _path_size _path _size
> + fi
> +
> [[ -n ${CHECKREQS_DISK_USR} ]] && \
> _check-reqs_disk \
> "${EROOT%/}/usr" \
Re: [PATCH v2 1/2] check-reqs.eclass: runtime disk checks for any path. [ In reply to ]
On Mon, Feb 26, 2024 at 08:01:28AM +0100, zzam@gentoo.org wrote:
> Am 26.02.24 um 07:31 schrieb Robin H. Johnson:
> > Allow checking any runtime path for installing ever-larger packages.
> >
> > CHECKREQS_DISK_RUNTIME=( /boot:40M /:350M /opt:500M )
>
> In the example case: Shouldn't the eclass check for 850M on / if /opt is
> not a separate partition?
> I am not sure how often it really happens that multiple large
> requirements for different folders exist.
I just summed up the 2 example packages here.

I do see your concern about the filesystem/mountpoint layout.

If it's a single /: that needs 850M
If it's split / and /opt: then it's the listed space in each location.

Correctly processing this would require converting each of the listed
check locations to their common mounts, summing the needs, and then
validating.

This should be possible with "stat --printf=%m" to resolve any directory
into it's mountpoint.

I'll see if it can be done trivially enough for the eclass.

--
Robin Hugh Johnson
Gentoo Linux: Dev, Infra Lead, Foundation President & Treasurer
E-Mail : robbat2@gentoo.org
GnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85
GnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136
Re: [PATCH v2 1/2] check-reqs.eclass: runtime disk checks for any path. [ In reply to ]
On Sun, 2024-02-25 at 22:31 -0800, Robin H. Johnson wrote:
> Allow checking any runtime path for installing ever-larger packages.
>
> CHECKREQS_DISK_RUNTIME=( /boot:40M /:350M /opt:500M )
>
> Recent example of large packages:
>
> gentoo-kernel-bin:
> / >=350MB/version (in /lib/modules)
> /boot >=40MB/version
>
> rust-bin:
> /opt >=450MB/version
>
> Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
> ---
> eclass/check-reqs.eclass | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
> index fac2f4553d74..1c59c69489a9 100644
> --- a/eclass/check-reqs.eclass
> +++ b/eclass/check-reqs.eclass
> @@ -30,6 +30,13 @@
> # # install will need this much space in /var
> # CHECKREQS_DISK_VAR="1024M"
> #
> +# # install will need this much space in listed paths.
> +# CHECKREQS_DISK_RUNTIME=(
> +# /var:1G
> +# /boot/efi:32M

I'd avoid listing /boot/efi as an example, as /boot is a bit special
and might need special handling in the eclass. In particular,
on the system here I have EFI mounted at /boot, so there
is no /boot/efi.

A possible generic solution would be to "fall back" from non-existing
locations to a "higher" directory, assuming they would normally be
created as subdirectories.

> +# /opt/giant-package-with-dedicated-disk:100G
> +# )
> +#
> # @CODE
> #
> # If you don't specify a value for, say, CHECKREQS_MEMORY, then the test is not
> @@ -66,6 +73,11 @@ _CHECK_REQS_ECLASS=1
> # @DESCRIPTION:
> # How much space is needed in /var? Eg.: CHECKREQS_DISK_VAR=3000M
>
> +# @ECLASS_VARIABLE: CHECKREQS_DISK_RUNTIME
> +# @DEFAULT_UNSET
> +# @DESCRIPTION:
> +# How much space is needed in paths? Eg.: CHECKREQS_DISK_RUNTIME=( /:1G /var:5G )
> +
> # @ECLASS_VARIABLE: CHECKREQS_DONOTHING
> # @USER_VARIABLE
> # @DEFAULT_UNSET
> @@ -120,6 +132,7 @@ _check-reqs_prepare() {
> debug-print-function ${FUNCNAME} "$@"
>
> if [[ -z ${CHECKREQS_MEMORY} &&
> + "${#CHECKREQS_DISK_RUNTIME[@]}" -eq 0 &&
> -z ${CHECKREQS_DISK_BUILD} &&
> -z ${CHECKREQS_DISK_USR} &&
> -z ${CHECKREQS_DISK_VAR} ]]; then

Considering all the extra logic discussed in this thread, it might be
reasonable to implicitly convert CHECKREQS_DISK_* into
CHECKREQS_DISK_RUNTIME, so they'd share all the solutions discussed.

So ideally the logic would be something like:

1. Append CHECKREQS_DISK_* into CHECKREQS_DISK_RUNTIME.

2. Replace missing paths with the first parent directory that exists.

3. Replace paths with their respective mount points.

4. Sum the values corresponding to the same mount point.

> @@ -161,6 +174,16 @@ _check-reqs_run() {
> fi
>
> if [[ ${MERGE_TYPE} != buildonly ]]; then
> + if [[ "${#CHECKREQS_DISK_RUNTIME[@]}" -gt 0 ]]; then
> + for _path_size in "${CHECKREQS_DISK_RUNTIME[@]}"; do
> + _path=${_path_size/:*}
> + _size=${_path_size/*:}
> + _check-reqs_disk \
> + "${EROOT%/}${_path}" "${_size}"
> + done
> + unset _path_size _path _size

Instead of setting them globally, then unsetting, you should use local
variables.

> + fi
> +
> [[ -n ${CHECKREQS_DISK_USR} ]] && \
> _check-reqs_disk \
> "${EROOT%/}/usr" \

--
Best regards,
Micha? Górny