From 596014f014a09dd267bdfcbeece80f6c54057b93 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Mon, 19 Jul 2021 22:31:12 +0200 Subject: check-reqs.eclass: Make check-reqs_get_kibibytes internal Signed-off-by: Andreas Sturmlechner --- eclass/check-reqs.eclass | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'eclass') diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass index b22cca79047c..470f52756b78 100644 --- a/eclass/check-reqs.eclass +++ b/eclass/check-reqs.eclass @@ -167,6 +167,17 @@ _check-reqs_run() { # Internal function that returns number in KiB. # Returns 1024**2 for 1G or 1024**3 for 1T. check-reqs_get_kibibytes() { + [[ ${EAPI} == [67] ]] || + die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}." + _check-reqs_get_kibibytes "$@" +} + +# @FUNCTION: _check-reqs_get_kibibytes +# @INTERNAL +# @DESCRIPTION: +# Internal function that returns number in KiB. +# Returns 1024**2 for 1G or 1024**3 for 1T. +_check-reqs_get_kibibytes() { debug-print-function ${FUNCNAME} "$@" [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]" @@ -274,10 +285,10 @@ check-reqs_memory() { | sed -e 's/^[^:=]*[:=][[:space:]]*//') fi if [[ -n ${actual_memory} ]] ; then - if [[ ${actual_memory} -ge $(check-reqs_get_kibibytes ${size}) ]] ; then + if [[ ${actual_memory} -ge $(_check-reqs_get_kibibytes ${size}) ]] ; then eend 0 elif [[ -n ${actual_swap} && $((${actual_memory} + ${actual_swap})) \ - -ge $(check-reqs_get_kibibytes ${size}) ]] ; then + -ge $(_check-reqs_get_kibibytes ${size}) ]] ; then ewarn "Amount of main memory is insufficient, but amount" ewarn "of main memory combined with swap is sufficient." ewarn "Build process may make computer very slow!" @@ -314,7 +325,7 @@ check-reqs_disk() { space_kbi=$(df -Pk "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}') if [[ $? == 0 && -n ${space_kbi} ]] ; then - if [[ ${space_kbi} -lt $(check-reqs_get_kibibytes ${size}) ]] ; then + if [[ ${space_kbi} -lt $(_check-reqs_get_kibibytes ${size}) ]] ; then eend 1 check-reqs_unsatisfied \ ${size} \ -- cgit v1.2.3-65-gdbad