diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2019-05-13 16:30:15 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2019-08-19 22:27:36 +0200 |
commit | 297e41122a17dea6e7867ed4345255916c379a6c (patch) | |
tree | 4b61a560e81a533e6e55b2a1bd8c1fcf87ead453 /eclass | |
parent | net-wireless/hostapd: amd64 stable wrt bug #692540 (diff) | |
download | gentoo-297e41122a17dea6e7867ed4345255916c379a6c.tar.gz gentoo-297e41122a17dea6e7867ed4345255916c379a6c.tar.bz2 gentoo-297e41122a17dea6e7867ed4345255916c379a6c.zip |
check-reqs.eclass: check-reqs_memory(): Check for available swap.
Print warning if usage of swap appears to be needed.
Closes: https://bugs.gentoo.org/569966
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/check-reqs.eclass | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass index 689944c87700..95f73a3012eb 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 @@ -245,6 +245,7 @@ check-reqs_memory() { local size=${1} local actual_memory + local actual_swap check-reqs_start_phase \ ${size} \ @@ -252,19 +253,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 |