Signed-off-by: Andreas Sturmlechner <[email protected]> --- eclass/check-reqs.eclass | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 123 insertions(+), 17 deletions(-)
diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
index 6b11794fbb2..39e4bad1363 100644
--- a/eclass/check-reqs.eclass
+++ b/eclass/check-reqs.eclass
@@ -76,9 +76,9 @@ _CHECK_REQS_ECLASS=1
check-reqs_pkg_setup() {
debug-print-function ${FUNCNAME} "$@"
- check-reqs_prepare
- check-reqs_run
- check-reqs_output
+ _check-reqs_prepare
+ _check-reqs_run
+ _check-reqs_output
}
# @FUNCTION: check-reqs_pkg_pretend
@@ -95,6 +95,16 @@ check-reqs_pkg_pretend() {
# @DESCRIPTION:
# Internal function that checks the variables that should be defined.
check-reqs_prepare() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_prepare "$@"
+}
+
+# @FUNCTION: _check-reqs_prepare
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that checks the variables that should be defined.
+_check-reqs_prepare() {
debug-print-function ${FUNCNAME} "$@"
if [[ -z ${CHECKREQS_MEMORY} &&
@@ -112,6 +122,16 @@ check-reqs_prepare() {
# @DESCRIPTION:
# Internal function that runs the check based on variable settings.
check-reqs_run() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_run "$@"
+}
+
+# @FUNCTION: _check-reqs_run
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that runs the check based on variable settings.
+_check-reqs_run() {
debug-print-function ${FUNCNAME} "$@"
# some people are *censored*
@@ -119,23 +139,23 @@ check-reqs_run() {
if [[ ${MERGE_TYPE} != binary ]]; then
[[ -n ${CHECKREQS_MEMORY} ]] && \
- check-reqs_memory \
+ _check-reqs_memory \
${CHECKREQS_MEMORY}
[[ -n ${CHECKREQS_DISK_BUILD} ]] && \
- check-reqs_disk \
+ _check-reqs_disk \
"${T}" \
"${CHECKREQS_DISK_BUILD}"
fi
if [[ ${MERGE_TYPE} != buildonly ]]; then
[[ -n ${CHECKREQS_DISK_USR} ]] && \
- check-reqs_disk \
+ _check-reqs_disk \
"${EROOT%/}/usr" \
"${CHECKREQS_DISK_USR}"
[[ -n ${CHECKREQS_DISK_VAR} ]] && \
- check-reqs_disk \
+ _check-reqs_disk \
"${EROOT%/}/var" \
"${CHECKREQS_DISK_VAR}"
fi
@@ -147,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]"
@@ -170,6 +201,17 @@ check-reqs_get_kibibytes() {
# Internal function that returns the numerical value without the unit.
# Returns "1" for "1G" or "150" for "150T".
check-reqs_get_number() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_get_number "$@"
+}
+
+# @FUNCTION: _check-reqs_get_number
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that returns the numerical value without the unit.
+# Returns "1" for "1G" or "150" for "150T".
+_check-reqs_get_number() {
debug-print-function ${FUNCNAME} "$@"
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
@@ -186,6 +228,17 @@ check-reqs_get_number() {
# Internal function that returns the unit without the numerical value.
# Returns "GiB" for "1G" or "TiB" for "150T".
check-reqs_get_unit() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_get_unit "$@"
+}
+
+# @FUNCTION: _check-reqs_get_unit
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that returns the unit without the numerical value.
+# Returns "GiB" for "1G" or "TiB" for "150T".
+_check-reqs_get_unit() {
debug-print-function ${FUNCNAME} "$@"
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
@@ -208,6 +261,17 @@ check-reqs_get_unit() {
# Internal function that prints the warning and dies if required based on
# the test results.
check-reqs_output() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_get_unit "$@"
+}
+
+# @FUNCTION: _check-reqs_output
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that prints the warning and dies if required based on
+# the test results.
+_check-reqs_output() {
debug-print-function ${FUNCNAME} "$@"
local msg="ewarn"
@@ -230,6 +294,16 @@ check-reqs_output() {
# @DESCRIPTION:
# Internal function that checks size of RAM.
check-reqs_memory() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_memory "$@"
+}
+
+# @FUNCTION: _check-reqs_memory
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that checks size of RAM.
+_check-reqs_memory() {
debug-print-function ${FUNCNAME} "$@"
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
@@ -238,7 +312,7 @@ check-reqs_memory() {
local actual_memory
local actual_swap
- check-reqs_start_phase \
+ _check-reqs_start_phase \
${size} \
"RAM"
@@ -254,17 +328,17 @@ 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!"
eend 0
else
eend 1
- check-reqs_unsatisfied \
+ _check-reqs_unsatisfied \
${size} \
"RAM"
fi
@@ -279,6 +353,16 @@ check-reqs_memory() {
# @DESCRIPTION:
# Internal function that checks space on the harddrive.
check-reqs_disk() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_disk "$@"
+}
+
+# @FUNCTION: _check-reqs_disk
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that checks space on the harddrive.
+_check-reqs_disk() {
debug-print-function ${FUNCNAME} "$@"
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [path] [size]"
@@ -287,16 +371,16 @@ check-reqs_disk() {
local size=${2}
local space_kbi
- check-reqs_start_phase \
+ _check-reqs_start_phase \
${size} \
"disk space at \"${path}\""
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 \
+ _check-reqs_unsatisfied \
${size} \
"disk space at \"${path}\""
else
@@ -313,13 +397,23 @@ check-reqs_disk() {
# @DESCRIPTION:
# Internal function that inform about started check
check-reqs_start_phase() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_start_phase "$@"
+}
+
+# @FUNCTION: _check-reqs_start_phase
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that inform about started check
+_check-reqs_start_phase() {
debug-print-function ${FUNCNAME} "$@"
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]"
local size=${1}
local location=${2}
- local sizeunit="$(check-reqs_get_number ${size}) $(check-reqs_get_unit
${size})"
+ local sizeunit="$(_check-reqs_get_number ${size})
$(_check-reqs_get_unit ${size})"
ebegin "Checking for at least ${sizeunit} ${location}"
}
@@ -327,10 +421,22 @@ check-reqs_start_phase() {
# @FUNCTION: check-reqs_unsatisfied
# @INTERNAL
# @DESCRIPTION:
-# Internal function that inform about check result.
+# Internal function that informs about check result.
# It has different output between pretend and setup phase,
# where in pretend phase it is fatal.
check-reqs_unsatisfied() {
+ [[ ${EAPI} == [67] ]] ||
+ die "Internal function ${FUNCNAME} is not available in EAPI
${EAPI}."
+ _check-reqs_unsatisfied "$@"
+}
+
+# @FUNCTION: _check-reqs_unsatisfied
+# @INTERNAL
+# @DESCRIPTION:
+# Internal function that informs about check result.
+# It has different output between pretend and setup phase,
+# where in pretend phase it is fatal.
+_check-reqs_unsatisfied() {
debug-print-function ${FUNCNAME} "$@"
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]"
@@ -338,7 +444,7 @@ check-reqs_unsatisfied() {
local msg="ewarn"
local size=${1}
local location=${2}
- local sizeunit="$(check-reqs_get_number ${size}) $(check-reqs_get_unit
${size})"
+ local sizeunit="$(_check-reqs_get_number ${size})
$(_check-reqs_get_unit ${size})"
[[ ${EBUILD_PHASE} == "pretend" && -z ${I_KNOW_WHAT_I_AM_DOING} ]] &&
msg="eerror"
${msg} "There is NOT at least ${sizeunit} ${location}"
signature.asc
Description: This is a digitally signed message part.
