mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-30 10:01:32 +02:00
eclass/check-reqs: Sync with gentoo
It's from gentoo commit a1db03163fb4a08d7813e92fa723db7a79566ef0.
This commit is contained in:
parent
71e54186fd
commit
53dd124de6
@ -1,4 +1,4 @@
|
|||||||
# Copyright 1999-2018 Gentoo Foundation
|
# Copyright 2004-2021 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: check-reqs.eclass
|
# @ECLASS: check-reqs.eclass
|
||||||
@ -7,8 +7,8 @@
|
|||||||
# @AUTHOR:
|
# @AUTHOR:
|
||||||
# Bo Ørsted Andresen <zlin@gentoo.org>
|
# Bo Ørsted Andresen <zlin@gentoo.org>
|
||||||
# Original Author: Ciaran McCreesh <ciaranm@gentoo.org>
|
# Original Author: Ciaran McCreesh <ciaranm@gentoo.org>
|
||||||
# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
|
# @SUPPORTED_EAPIS: 6 7 8
|
||||||
# @BLURB: Provides a uniform way of handling ebuild which have very high build requirements
|
# @BLURB: Provides a uniform way of handling ebuilds with very high build requirements
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This eclass provides a uniform way of handling ebuilds which have very high
|
# This eclass provides a uniform way of handling ebuilds which have very high
|
||||||
# build requirements in terms of memory or disk space. It provides a function
|
# build requirements in terms of memory or disk space. It provides a function
|
||||||
@ -38,7 +38,15 @@
|
|||||||
# These checks should probably mostly work on non-Linux, and they should
|
# These checks should probably mostly work on non-Linux, and they should
|
||||||
# probably degrade gracefully if they don't. Probably.
|
# probably degrade gracefully if they don't. Probably.
|
||||||
|
|
||||||
if [[ ! ${_CHECK_REQS_ECLASS_} ]]; then
|
case ${EAPI} in
|
||||||
|
6|7|8) ;;
|
||||||
|
*) die "${ECLASS}: EAPI=${EAPI:-0} is not supported" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
EXPORT_FUNCTIONS pkg_pretend pkg_setup
|
||||||
|
|
||||||
|
if [[ ! ${_CHECK_REQS_ECLASS} ]]; then
|
||||||
|
_CHECK_REQS_ECLASS=1
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: CHECKREQS_MEMORY
|
# @ECLASS-VARIABLE: CHECKREQS_MEMORY
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
@ -60,19 +68,13 @@ if [[ ! ${_CHECK_REQS_ECLASS_} ]]; then
|
|||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# How much space is needed in /var? Eg.: CHECKREQS_DISK_VAR=3000M
|
# How much space is needed in /var? Eg.: CHECKREQS_DISK_VAR=3000M
|
||||||
|
|
||||||
EXPORT_FUNCTIONS pkg_setup
|
# @ECLASS-VARIABLE: CHECKREQS_DONOTHING
|
||||||
case "${EAPI:-0}" in
|
# @USER_VARIABLE
|
||||||
0|1|2|3) ;;
|
# @DEFAULT_UNSET
|
||||||
4|5|6|7) EXPORT_FUNCTIONS pkg_pretend ;;
|
# @DESCRIPTION:
|
||||||
*) die "EAPI=${EAPI} is not supported" ;;
|
# Do not error out in _check-reqs_output if requirements are not met.
|
||||||
esac
|
# This is a user flag and should under _no circumstances_ be set in the ebuild.
|
||||||
|
[[ -n ${I_KNOW_WHAT_I_AM_DOING} ]] && CHECKREQS_DONOTHING=1
|
||||||
# Obsolete function executing all the checks and printing out results
|
|
||||||
check_reqs() {
|
|
||||||
eerror "Package calling old ${FUNCNAME} function."
|
|
||||||
eerror "It should call check-reqs_pkg_pretend and check-reqs_pkg_setup."
|
|
||||||
die "${FUNCNAME} is banned"
|
|
||||||
}
|
|
||||||
|
|
||||||
# @FUNCTION: check-reqs_pkg_setup
|
# @FUNCTION: check-reqs_pkg_setup
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
@ -82,9 +84,9 @@ check_reqs() {
|
|||||||
check-reqs_pkg_setup() {
|
check-reqs_pkg_setup() {
|
||||||
debug-print-function ${FUNCNAME} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
check-reqs_prepare
|
_check-reqs_prepare
|
||||||
check-reqs_run
|
_check-reqs_run
|
||||||
check-reqs_output
|
_check-reqs_output
|
||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: check-reqs_pkg_pretend
|
# @FUNCTION: check-reqs_pkg_pretend
|
||||||
@ -101,6 +103,16 @@ check-reqs_pkg_pretend() {
|
|||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Internal function that checks the variables that should be defined.
|
# Internal function that checks the variables that should be defined.
|
||||||
check-reqs_prepare() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
if [[ -z ${CHECKREQS_MEMORY} &&
|
if [[ -z ${CHECKREQS_MEMORY} &&
|
||||||
@ -109,7 +121,7 @@ check-reqs_prepare() {
|
|||||||
-z ${CHECKREQS_DISK_VAR} ]]; then
|
-z ${CHECKREQS_DISK_VAR} ]]; then
|
||||||
eerror "Set some check-reqs eclass variables if you want to use it."
|
eerror "Set some check-reqs eclass variables if you want to use it."
|
||||||
eerror "If you are user and see this message file a bug against the package."
|
eerror "If you are user and see this message file a bug against the package."
|
||||||
die "${FUNCNAME}: check-reqs eclass called but not actualy used!"
|
die "${FUNCNAME}: check-reqs eclass called but not actually used!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,34 +130,41 @@ check-reqs_prepare() {
|
|||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Internal function that runs the check based on variable settings.
|
# Internal function that runs the check based on variable settings.
|
||||||
check-reqs_run() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
# some people are *censored*
|
# some people are *censored*
|
||||||
unset CHECKREQS_FAILED
|
unset CHECKREQS_FAILED
|
||||||
|
|
||||||
[[ ${EAPI:-0} == [0123] ]] && local MERGE_TYPE=""
|
|
||||||
|
|
||||||
# use != in test, because MERGE_TYPE only exists in EAPI 4 and later
|
|
||||||
if [[ ${MERGE_TYPE} != binary ]]; then
|
if [[ ${MERGE_TYPE} != binary ]]; then
|
||||||
[[ -n ${CHECKREQS_MEMORY} ]] && \
|
[[ -n ${CHECKREQS_MEMORY} ]] && \
|
||||||
check-reqs_memory \
|
_check-reqs_memory \
|
||||||
${CHECKREQS_MEMORY}
|
${CHECKREQS_MEMORY}
|
||||||
|
|
||||||
[[ -n ${CHECKREQS_DISK_BUILD} ]] && \
|
[[ -n ${CHECKREQS_DISK_BUILD} ]] && \
|
||||||
check-reqs_disk \
|
_check-reqs_disk \
|
||||||
"${T}" \
|
"${T}" \
|
||||||
"${CHECKREQS_DISK_BUILD}"
|
"${CHECKREQS_DISK_BUILD}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${MERGE_TYPE} != buildonly ]]; then
|
if [[ ${MERGE_TYPE} != buildonly ]]; then
|
||||||
[[ -n ${CHECKREQS_DISK_USR} ]] && \
|
[[ -n ${CHECKREQS_DISK_USR} ]] && \
|
||||||
check-reqs_disk \
|
_check-reqs_disk \
|
||||||
"${EROOT}/usr" \
|
"${EROOT%/}/usr" \
|
||||||
"${CHECKREQS_DISK_USR}"
|
"${CHECKREQS_DISK_USR}"
|
||||||
|
|
||||||
[[ -n ${CHECKREQS_DISK_VAR} ]] && \
|
[[ -n ${CHECKREQS_DISK_VAR} ]] && \
|
||||||
check-reqs_disk \
|
_check-reqs_disk \
|
||||||
"${EROOT}/var" \
|
"${EROOT%/}/var" \
|
||||||
"${CHECKREQS_DISK_VAR}"
|
"${CHECKREQS_DISK_VAR}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -156,6 +175,17 @@ check-reqs_run() {
|
|||||||
# Internal function that returns number in KiB.
|
# Internal function that returns number in KiB.
|
||||||
# Returns 1024**2 for 1G or 1024**3 for 1T.
|
# Returns 1024**2 for 1G or 1024**3 for 1T.
|
||||||
check-reqs_get_kibibytes() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
|
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
|
||||||
@ -179,6 +209,17 @@ check-reqs_get_kibibytes() {
|
|||||||
# Internal function that returns the numerical value without the unit.
|
# Internal function that returns the numerical value without the unit.
|
||||||
# Returns "1" for "1G" or "150" for "150T".
|
# Returns "1" for "1G" or "150" for "150T".
|
||||||
check-reqs_get_number() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
|
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
|
||||||
@ -195,6 +236,17 @@ check-reqs_get_number() {
|
|||||||
# Internal function that returns the unit without the numerical value.
|
# Internal function that returns the unit without the numerical value.
|
||||||
# Returns "GiB" for "1G" or "TiB" for "150T".
|
# Returns "GiB" for "1G" or "TiB" for "150T".
|
||||||
check-reqs_get_unit() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
|
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
|
||||||
@ -217,11 +269,22 @@ check-reqs_get_unit() {
|
|||||||
# Internal function that prints the warning and dies if required based on
|
# Internal function that prints the warning and dies if required based on
|
||||||
# the test results.
|
# the test results.
|
||||||
check-reqs_output() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
local msg="ewarn"
|
local msg="ewarn"
|
||||||
|
|
||||||
[[ ${EBUILD_PHASE} == "pretend" && -z ${I_KNOW_WHAT_I_AM_DOING} ]] && msg="eerror"
|
[[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && msg="eerror"
|
||||||
if [[ -n ${CHECKREQS_FAILED} ]]; then
|
if [[ -n ${CHECKREQS_FAILED} ]]; then
|
||||||
${msg}
|
${msg}
|
||||||
${msg} "Space constraints set in the ebuild were not met!"
|
${msg} "Space constraints set in the ebuild were not met!"
|
||||||
@ -229,7 +292,7 @@ check-reqs_output() {
|
|||||||
${msg} "as per failed tests."
|
${msg} "as per failed tests."
|
||||||
${msg}
|
${msg}
|
||||||
|
|
||||||
[[ ${EBUILD_PHASE} == "pretend" && -z ${I_KNOW_WHAT_I_AM_DOING} ]] && \
|
[[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && \
|
||||||
die "Build requirements not met!"
|
die "Build requirements not met!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -239,32 +302,53 @@ check-reqs_output() {
|
|||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Internal function that checks size of RAM.
|
# Internal function that checks size of RAM.
|
||||||
check-reqs_memory() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
|
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
|
||||||
|
|
||||||
local size=${1}
|
local size=${1}
|
||||||
local actual_memory
|
local actual_memory
|
||||||
|
local actual_swap
|
||||||
|
|
||||||
check-reqs_start_phase \
|
_check-reqs_start_phase \
|
||||||
${size} \
|
${size} \
|
||||||
"RAM"
|
"RAM"
|
||||||
|
|
||||||
if [[ -r /proc/meminfo ]] ; then
|
if [[ -r /proc/meminfo ]] ; then
|
||||||
actual_memory=$(awk '/MemTotal/ { print $2 }' /proc/meminfo)
|
actual_memory=$(awk '/MemTotal/ { print $2 }' /proc/meminfo)
|
||||||
|
actual_swap=$(awk '/SwapTotal/ { print $2 }' /proc/meminfo)
|
||||||
else
|
else
|
||||||
actual_memory=$(sysctl hw.physmem 2>/dev/null )
|
actual_memory=$(sysctl hw.physmem 2>/dev/null)
|
||||||
[[ "$?" == "0" ]] &&
|
[[ $? -eq 0 ]] && actual_memory=$(echo "${actual_memory}" \
|
||||||
actual_memory=$(echo $actual_memory | sed -e 's/^[^:=]*[:=]//' )
|
| sed -e 's/^[^:=]*[:=][[:space:]]*//')
|
||||||
|
actual_swap=$(sysctl vm.swap_total 2>/dev/null)
|
||||||
|
[[ $? -eq 0 ]] && actual_swap=$(echo "${actual_swap}" \
|
||||||
|
| sed -e 's/^[^:=]*[:=][[:space:]]*//')
|
||||||
fi
|
fi
|
||||||
if [[ -n ${actual_memory} ]] ; then
|
if [[ -n ${actual_memory} ]] ; then
|
||||||
if [[ ${actual_memory} -lt $(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
|
||||||
|
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
|
eend 1
|
||||||
check-reqs_unsatisfied \
|
_check-reqs_unsatisfied \
|
||||||
${size} \
|
${size} \
|
||||||
"RAM"
|
"RAM"
|
||||||
else
|
|
||||||
eend 0
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
eend 1
|
eend 1
|
||||||
@ -277,6 +361,16 @@ check-reqs_memory() {
|
|||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Internal function that checks space on the harddrive.
|
# Internal function that checks space on the harddrive.
|
||||||
check-reqs_disk() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [path] [size]"
|
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [path] [size]"
|
||||||
@ -285,16 +379,16 @@ check-reqs_disk() {
|
|||||||
local size=${2}
|
local size=${2}
|
||||||
local space_kbi
|
local space_kbi
|
||||||
|
|
||||||
check-reqs_start_phase \
|
_check-reqs_start_phase \
|
||||||
${size} \
|
${size} \
|
||||||
"disk space at \"${path}\""
|
"disk space at \"${path}\""
|
||||||
|
|
||||||
space_kbi=$(df -Pk "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}')
|
space_kbi=$(df -Pk "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}')
|
||||||
|
|
||||||
if [[ $? == 0 && -n ${space_kbi} ]] ; then
|
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
|
eend 1
|
||||||
check-reqs_unsatisfied \
|
_check-reqs_unsatisfied \
|
||||||
${size} \
|
${size} \
|
||||||
"disk space at \"${path}\""
|
"disk space at \"${path}\""
|
||||||
else
|
else
|
||||||
@ -311,13 +405,23 @@ check-reqs_disk() {
|
|||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Internal function that inform about started check
|
# Internal function that inform about started check
|
||||||
check-reqs_start_phase() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]"
|
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]"
|
||||||
|
|
||||||
local size=${1}
|
local size=${1}
|
||||||
local location=${2}
|
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}"
|
ebegin "Checking for at least ${sizeunit} ${location}"
|
||||||
}
|
}
|
||||||
@ -325,10 +429,22 @@ check-reqs_start_phase() {
|
|||||||
# @FUNCTION: check-reqs_unsatisfied
|
# @FUNCTION: check-reqs_unsatisfied
|
||||||
# @INTERNAL
|
# @INTERNAL
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Internal function that inform about check result.
|
# Internal function that informs about check result.
|
||||||
# It has different output between pretend and setup phase,
|
# It has different output between pretend and setup phase,
|
||||||
# where in pretend phase it is fatal.
|
# where in pretend phase it is fatal.
|
||||||
check-reqs_unsatisfied() {
|
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} "$@"
|
debug-print-function ${FUNCNAME} "$@"
|
||||||
|
|
||||||
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]"
|
[[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]"
|
||||||
@ -336,18 +452,17 @@ check-reqs_unsatisfied() {
|
|||||||
local msg="ewarn"
|
local msg="ewarn"
|
||||||
local size=${1}
|
local size=${1}
|
||||||
local location=${2}
|
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"
|
[[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && msg="eerror"
|
||||||
${msg} "There is NOT at least ${sizeunit} ${location}"
|
${msg} "There is NOT at least ${sizeunit} ${location}"
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: CHECKREQS_FAILED
|
# @ECLASS-VARIABLE: CHECKREQS_FAILED
|
||||||
# @DESCRIPTION:
|
|
||||||
# @INTERNAL
|
# @INTERNAL
|
||||||
|
# @DESCRIPTION:
|
||||||
# If set the checks failed and eclass should abort the build.
|
# If set the checks failed and eclass should abort the build.
|
||||||
# Internal, do not set yourself.
|
# Internal, do not set yourself.
|
||||||
CHECKREQS_FAILED="true"
|
CHECKREQS_FAILED="true"
|
||||||
}
|
}
|
||||||
|
|
||||||
_CHECK_REQS_ECLASS_=1
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user