1 |
Using kbi as base unit for calculation as linux and bsd only have -k as |
2 |
common option |
3 |
|
4 |
Signed-off-by: Justin Lecher <jlec@g.o> |
5 |
--- |
6 |
eclass/check-reqs.eclass | 25 +++++++++++++------------ |
7 |
1 file changed, 13 insertions(+), 12 deletions(-) |
8 |
|
9 |
diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass |
10 |
index 138bfec..a649693 100644 |
11 |
--- a/eclass/check-reqs.eclass |
12 |
+++ b/eclass/check-reqs.eclass |
13 |
@@ -159,12 +159,12 @@ check-reqs_run() { |
14 |
fi |
15 |
} |
16 |
|
17 |
-# @FUNCTION: check-reqs_get_mebibytes |
18 |
+# @FUNCTION: check-reqs_get_kbibytes |
19 |
# @INTERNAL |
20 |
# @DESCRIPTION: |
21 |
-# Internal function that returns number in mebibytes. |
22 |
-# Returns 1024 for 1G or 1048576 for 1T. |
23 |
-check-reqs_get_mebibytes() { |
24 |
+# Internal function that returns number in kbibytes. |
25 |
+# Returns 1024**2 for 1G or 1024**3 for 1T. |
26 |
+check-reqs_get_kbibytes() { |
27 |
debug-print-function ${FUNCNAME} "$@" |
28 |
|
29 |
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]" |
30 |
@@ -173,9 +173,10 @@ check-reqs_get_mebibytes() { |
31 |
local size=${1%[GMT]} |
32 |
|
33 |
case ${unit} in |
34 |
- G) echo $((1024 * size)) ;; |
35 |
- [M0-9]) echo ${size} ;; |
36 |
- T) echo $((1024 * 1024 * size)) ;; |
37 |
+ G) echo $((1024 * 1024 * size)) ;; |
38 |
+ M) echo $((1024 * size)) ;; |
39 |
+ T) echo $((1024 * 1024 * 1024 * size)) ;; |
40 |
+ [0-9]) echo $((1024 * size)) ;; |
41 |
*) |
42 |
die "${FUNCNAME}: Unknown unit: ${unit}" |
43 |
;; |
44 |
@@ -275,7 +276,7 @@ check-reqs_memory() { |
45 |
actual_memory=$(echo $actual_memory | sed -e 's/^[^:=]*[:=]//' ) |
46 |
fi |
47 |
if [[ -n ${actual_memory} ]] ; then |
48 |
- if [[ ${actual_memory} -lt $((1024 * $(check-reqs_get_mebibytes ${size}))) ]] ; then |
49 |
+ if [[ ${actual_memory} -lt $(check-reqs_get_kbibytes ${size}) ]] ; then |
50 |
eend 1 |
51 |
check-reqs_unsatisfied \ |
52 |
${size} \ |
53 |
@@ -300,16 +301,16 @@ check-reqs_disk() { |
54 |
|
55 |
local path=${1} |
56 |
local size=${2} |
57 |
- local space_megs |
58 |
+ local space_kbi |
59 |
|
60 |
check-reqs_start_phase \ |
61 |
${size} \ |
62 |
"disk space at \"${path}\"" |
63 |
|
64 |
- space_megs=$(df -Pm "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}') |
65 |
+ space_kbi=$(df -Pk "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}') |
66 |
|
67 |
- if [[ $? == 0 && -n ${space_megs} ]] ; then |
68 |
- if [[ ${space_megs} -lt $(check-reqs_get_mebibytes ${size}) ]] ; then |
69 |
+ if [[ $? == 0 && -n ${space_kbi} ]] ; then |
70 |
+ if [[ ${space_kbi} -lt $(check-reqs_get_kbibytes ${size}) ]] ; then |
71 |
eend 1 |
72 |
check-reqs_unsatisfied \ |
73 |
${size} \ |
74 |
-- |
75 |
2.6.4 |