eclass/check-reqs: Sync with Gentoo

It's from Gentoo commit e105854611974017415af6199d521b78f1134ff4.
This commit is contained in:
Krzesimir Nowak 2024-08-02 16:04:28 +02:00
parent 008947c9da
commit 22a6e3a16f

View File

@ -1,4 +1,4 @@
# Copyright 2004-2021 Gentoo Authors
# Copyright 2004-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: check-reqs.eclass
@ -40,35 +40,33 @@
case ${EAPI} in
6|7|8) ;;
*) die "${ECLASS}: EAPI=${EAPI:-0} is not supported" ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
EXPORT_FUNCTIONS pkg_pretend pkg_setup
if [[ ! ${_CHECK_REQS_ECLASS} ]]; then
if [[ -z ${_CHECK_REQS_ECLASS} ]]; then
_CHECK_REQS_ECLASS=1
# @ECLASS-VARIABLE: CHECKREQS_MEMORY
# @ECLASS_VARIABLE: CHECKREQS_MEMORY
# @DEFAULT_UNSET
# @DESCRIPTION:
# How much RAM is needed? Eg.: CHECKREQS_MEMORY=15M
# @ECLASS-VARIABLE: CHECKREQS_DISK_BUILD
# @ECLASS_VARIABLE: CHECKREQS_DISK_BUILD
# @DEFAULT_UNSET
# @DESCRIPTION:
# How much diskspace is needed to build the package? Eg.: CHECKREQS_DISK_BUILD=2T
# @ECLASS-VARIABLE: CHECKREQS_DISK_USR
# @ECLASS_VARIABLE: CHECKREQS_DISK_USR
# @DEFAULT_UNSET
# @DESCRIPTION:
# How much space in /usr is needed to install the package? Eg.: CHECKREQS_DISK_USR=15G
# @ECLASS-VARIABLE: CHECKREQS_DISK_VAR
# @ECLASS_VARIABLE: CHECKREQS_DISK_VAR
# @DEFAULT_UNSET
# @DESCRIPTION:
# How much space is needed in /var? Eg.: CHECKREQS_DISK_VAR=3000M
# @ECLASS-VARIABLE: CHECKREQS_DONOTHING
# @ECLASS_VARIABLE: CHECKREQS_DONOTHING
# @USER_VARIABLE
# @DEFAULT_UNSET
# @DESCRIPTION:
@ -76,6 +74,12 @@ _CHECK_REQS_ECLASS=1
# 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
# @ECLASS_VARIABLE: CHECKREQS_FAILED
# @INTERNAL
# @DESCRIPTION:
# If set the checks failed and eclass should abort the build.
# Internal, do not set yourself.
# @FUNCTION: check-reqs_pkg_setup
# @DESCRIPTION:
# Exported function running the resources checks in pkg_setup phase.
@ -287,9 +291,11 @@ _check-reqs_output() {
[[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && msg="eerror"
if [[ -n ${CHECKREQS_FAILED} ]]; then
${msg}
${msg} "Space constraints set in the ebuild were not met!"
${msg} "The build will most probably fail, you should enhance the space"
${msg} "as per failed tests."
${msg} "Memory or space constraints set in the ebuild were not met!"
${msg} "The build will most probably fail, you should:"
${msg} "- enhance the memory (reduce MAKEOPTS, add swap), or"
${msg} "- add more space"
${msg} "as required depending on the failed tests."
${msg}
[[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && \
@ -457,12 +463,9 @@ _check-reqs_unsatisfied() {
[[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && msg="eerror"
${msg} "There is NOT at least ${sizeunit} ${location}"
# @ECLASS-VARIABLE: CHECKREQS_FAILED
# @INTERNAL
# @DESCRIPTION:
# If set the checks failed and eclass should abort the build.
# Internal, do not set yourself.
CHECKREQS_FAILED="true"
}
fi
EXPORT_FUNCTIONS pkg_pretend pkg_setup