Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Mon, 19 Aug 2019 20:35:45
Message-Id: 1566246456.297e41122a17dea6e7867ed4345255916c379a6c.ulm@gentoo
1 commit: 297e41122a17dea6e7867ed4345255916c379a6c
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Mon May 13 14:30:15 2019 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Mon Aug 19 20:27:36 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=297e4112
7
8 check-reqs.eclass: check-reqs_memory(): Check for available swap.
9
10 Print warning if usage of swap appears to be needed.
11
12 Closes: https://bugs.gentoo.org/569966
13 Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
14 Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
15
16 eclass/check-reqs.eclass | 25 ++++++++++++++++++-------
17 1 file changed, 18 insertions(+), 7 deletions(-)
18
19 diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
20 index 689944c8770..95f73a3012e 100644
21 --- a/eclass/check-reqs.eclass
22 +++ b/eclass/check-reqs.eclass
23 @@ -1,4 +1,4 @@
24 -# Copyright 1999-2018 Gentoo Foundation
25 +# Copyright 2004-2019 Gentoo Authors
26 # Distributed under the terms of the GNU General Public License v2
27
28 # @ECLASS: check-reqs.eclass
29 @@ -245,6 +245,7 @@ check-reqs_memory() {
30
31 local size=${1}
32 local actual_memory
33 + local actual_swap
34
35 check-reqs_start_phase \
36 ${size} \
37 @@ -252,19 +253,29 @@ check-reqs_memory() {
38
39 if [[ -r /proc/meminfo ]] ; then
40 actual_memory=$(awk '/MemTotal/ { print $2 }' /proc/meminfo)
41 + actual_swap=$(awk '/SwapTotal/ { print $2 }' /proc/meminfo)
42 else
43 - actual_memory=$(sysctl hw.physmem 2>/dev/null )
44 - [[ "$?" == "0" ]] &&
45 - actual_memory=$(echo $actual_memory | sed -e 's/^[^:=]*[:=]//' )
46 + actual_memory=$(sysctl hw.physmem 2>/dev/null)
47 + [[ $? -eq 0 ]] && actual_memory=$(echo "${actual_memory}" \
48 + | sed -e 's/^[^:=]*[:=][[:space:]]*//')
49 + actual_swap=$(sysctl vm.swap_total 2>/dev/null)
50 + [[ $? -eq 0 ]] && actual_swap=$(echo "${actual_swap}" \
51 + | sed -e 's/^[^:=]*[:=][[:space:]]*//')
52 fi
53 if [[ -n ${actual_memory} ]] ; then
54 - if [[ ${actual_memory} -lt $(check-reqs_get_kibibytes ${size}) ]] ; then
55 + if [[ ${actual_memory} -ge $(check-reqs_get_kibibytes ${size}) ]] ; then
56 + eend 0
57 + elif [[ -n ${actual_swap} && $((${actual_memory} + ${actual_swap})) \
58 + -ge $(check-reqs_get_kibibytes ${size}) ]] ; then
59 + ewarn "Amount of main memory is insufficient, but amount"
60 + ewarn "of main memory combined with swap is sufficient."
61 + ewarn "Build process may make computer very slow!"
62 + eend 0
63 + else
64 eend 1
65 check-reqs_unsatisfied \
66 ${size} \
67 "RAM"
68 - else
69 - eend 0
70 fi
71 else
72 eend 1