From f1af93971b7490792d8541bc790e0d8c6d787059 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 6 Sep 2019 10:28:05 +0100 Subject: gentoo resync : 06.08.2019 --- eclass/check-reqs.eclass | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'eclass/check-reqs.eclass') diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass index 689944c87700..192d6fa740dc 100644 --- a/eclass/check-reqs.eclass +++ b/eclass/check-reqs.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2018 Gentoo Foundation +# Copyright 2004-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: check-reqs.eclass @@ -7,7 +7,7 @@ # @AUTHOR: # Bo Ørsted Andresen # Original Author: Ciaran McCreesh -# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7 +# @SUPPORTED_EAPIS: 4 5 6 7 # @BLURB: Provides a uniform way of handling ebuild which have very high build requirements # @DESCRIPTION: # This eclass provides a uniform way of handling ebuilds which have very high @@ -60,13 +60,13 @@ if [[ ! ${_CHECK_REQS_ECLASS_} ]]; then # @DESCRIPTION: # How much space is needed in /var? Eg.: CHECKREQS_DISK_VAR=3000M -EXPORT_FUNCTIONS pkg_setup -case "${EAPI:-0}" in - 0|1|2|3) ;; - 4|5|6|7) EXPORT_FUNCTIONS pkg_pretend ;; - *) die "EAPI=${EAPI} is not supported" ;; +case ${EAPI:-0} in + 4|5|6|7) ;; + *) die "${ECLASS}: EAPI=${EAPI:-0} is not supported" ;; esac +EXPORT_FUNCTIONS pkg_pretend pkg_setup + # Obsolete function executing all the checks and printing out results check_reqs() { eerror "Package calling old ${FUNCNAME} function." @@ -123,9 +123,6 @@ check-reqs_run() { # some people are *censored* 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 [[ -n ${CHECKREQS_MEMORY} ]] && \ check-reqs_memory \ @@ -140,12 +137,12 @@ check-reqs_run() { if [[ ${MERGE_TYPE} != buildonly ]]; then [[ -n ${CHECKREQS_DISK_USR} ]] && \ check-reqs_disk \ - "${EROOT}/usr" \ + "${EROOT%/}/usr" \ "${CHECKREQS_DISK_USR}" [[ -n ${CHECKREQS_DISK_VAR} ]] && \ check-reqs_disk \ - "${EROOT}/var" \ + "${EROOT%/}/var" \ "${CHECKREQS_DISK_VAR}" fi } @@ -245,6 +242,7 @@ check-reqs_memory() { local size=${1} local actual_memory + local actual_swap check-reqs_start_phase \ ${size} \ @@ -252,19 +250,29 @@ check-reqs_memory() { if [[ -r /proc/meminfo ]] ; then actual_memory=$(awk '/MemTotal/ { print $2 }' /proc/meminfo) + actual_swap=$(awk '/SwapTotal/ { print $2 }' /proc/meminfo) else - actual_memory=$(sysctl hw.physmem 2>/dev/null ) - [[ "$?" == "0" ]] && - actual_memory=$(echo $actual_memory | sed -e 's/^[^:=]*[:=]//' ) + actual_memory=$(sysctl hw.physmem 2>/dev/null) + [[ $? -eq 0 ]] && actual_memory=$(echo "${actual_memory}" \ + | 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 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 check-reqs_unsatisfied \ ${size} \ "RAM" - else - eend 0 fi else eend 1 -- cgit v1.2.3