Gentoo Archives: gentoo-commits

From: Justin Lecher <jlec@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sat, 02 Jan 2016 10:41:38
Message-Id: 1451731286.a21ab6367e8a7726df1480eab8115fda81431477.jlec@gentoo
1 commit: a21ab6367e8a7726df1480eab8115fda81431477
2 Author: Justin Lecher <jlec <AT> gentoo <DOT> org>
3 AuthorDate: Sun Dec 27 09:15:03 2015 +0000
4 Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 2 10:41:26 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a21ab636
7
8 check-reqs.eclass: Replace obsolete df option -m with -k
9
10 Using KiB as base unit for calculation as linux and bsd only have -k as
11 common option
12
13 Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>
14
15 eclass/check-reqs.eclass | 25 +++++++++++++------------
16 1 file changed, 13 insertions(+), 12 deletions(-)
17
18 diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
19 index 138bfec..204bcc3 100644
20 --- a/eclass/check-reqs.eclass
21 +++ b/eclass/check-reqs.eclass
22 @@ -159,12 +159,12 @@ check-reqs_run() {
23 fi
24 }
25
26 -# @FUNCTION: check-reqs_get_mebibytes
27 +# @FUNCTION: check-reqs_get_kibibytes
28 # @INTERNAL
29 # @DESCRIPTION:
30 -# Internal function that returns number in mebibytes.
31 -# Returns 1024 for 1G or 1048576 for 1T.
32 -check-reqs_get_mebibytes() {
33 +# Internal function that returns number in KiB.
34 +# Returns 1024**2 for 1G or 1024**3 for 1T.
35 +check-reqs_get_kibibytes() {
36 debug-print-function ${FUNCNAME} "$@"
37
38 [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
39 @@ -173,9 +173,10 @@ check-reqs_get_mebibytes() {
40 local size=${1%[GMT]}
41
42 case ${unit} in
43 - G) echo $((1024 * size)) ;;
44 - [M0-9]) echo ${size} ;;
45 - T) echo $((1024 * 1024 * size)) ;;
46 + G) echo $((1024 * 1024 * size)) ;;
47 + M) echo $((1024 * size)) ;;
48 + T) echo $((1024 * 1024 * 1024 * size)) ;;
49 + [0-9]) echo $((1024 * size)) ;;
50 *)
51 die "${FUNCNAME}: Unknown unit: ${unit}"
52 ;;
53 @@ -275,7 +276,7 @@ check-reqs_memory() {
54 actual_memory=$(echo $actual_memory | sed -e 's/^[^:=]*[:=]//' )
55 fi
56 if [[ -n ${actual_memory} ]] ; then
57 - if [[ ${actual_memory} -lt $((1024 * $(check-reqs_get_mebibytes ${size}))) ]] ; then
58 + if [[ ${actual_memory} -lt $(check-reqs_get_kibibytes ${size}) ]] ; then
59 eend 1
60 check-reqs_unsatisfied \
61 ${size} \
62 @@ -300,16 +301,16 @@ check-reqs_disk() {
63
64 local path=${1}
65 local size=${2}
66 - local space_megs
67 + local space_kbi
68
69 check-reqs_start_phase \
70 ${size} \
71 "disk space at \"${path}\""
72
73 - space_megs=$(df -Pm "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}')
74 + space_kbi=$(df -Pk "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}')
75
76 - if [[ $? == 0 && -n ${space_megs} ]] ; then
77 - if [[ ${space_megs} -lt $(check-reqs_get_mebibytes ${size}) ]] ; then
78 + if [[ $? == 0 && -n ${space_kbi} ]] ; then
79 + if [[ ${space_kbi} -lt $(check-reqs_get_kibibytes ${size}) ]] ; then
80 eend 1
81 check-reqs_unsatisfied \
82 ${size} \