Skip to content

Commit

Permalink
check-reqs.eclass: Make check-reqs_get_kibibytes internal
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Sturmlechner <[email protected]>
  • Loading branch information
a17r committed Aug 3, 2021
1 parent 222510b commit 596014f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions eclass/check-reqs.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down Expand Up @@ -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!"
Expand Down Expand Up @@ -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} \
Expand Down

0 comments on commit 596014f

Please sign in to comment.