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