From: Justin Lecher <jlec@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: qa@gentoo.org, Justin Lecher <jlec@gentoo.org>
Subject: [gentoo-dev] [PATCH] check-reqs.eclass: Replace obsolete df option -m with -k
Date: Mon, 28 Dec 2015 16:27:43 +0100 [thread overview]
Message-ID: <1451316463-14550-2-git-send-email-jlec@gentoo.org> (raw)
In-Reply-To: <1451316463-14550-1-git-send-email-jlec@gentoo.org>
Using kbi as base unit for calculation as linux and bsd only have -k as
common option
Signed-off-by: Justin Lecher <jlec@gentoo.org>
---
eclass/check-reqs.eclass | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
index 138bfec..a649693 100644
--- a/eclass/check-reqs.eclass
+++ b/eclass/check-reqs.eclass
@@ -159,12 +159,12 @@ check-reqs_run() {
fi
}
-# @FUNCTION: check-reqs_get_mebibytes
+# @FUNCTION: check-reqs_get_kbibytes
# @INTERNAL
# @DESCRIPTION:
-# Internal function that returns number in mebibytes.
-# Returns 1024 for 1G or 1048576 for 1T.
-check-reqs_get_mebibytes() {
+# Internal function that returns number in kbibytes.
+# Returns 1024**2 for 1G or 1024**3 for 1T.
+check-reqs_get_kbibytes() {
debug-print-function ${FUNCNAME} "$@"
[[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
@@ -173,9 +173,10 @@ check-reqs_get_mebibytes() {
local size=${1%[GMT]}
case ${unit} in
- G) echo $((1024 * size)) ;;
- [M0-9]) echo ${size} ;;
- T) echo $((1024 * 1024 * size)) ;;
+ G) echo $((1024 * 1024 * size)) ;;
+ M) echo $((1024 * size)) ;;
+ T) echo $((1024 * 1024 * 1024 * size)) ;;
+ [0-9]) echo $((1024 * size)) ;;
*)
die "${FUNCNAME}: Unknown unit: ${unit}"
;;
@@ -275,7 +276,7 @@ check-reqs_memory() {
actual_memory=$(echo $actual_memory | sed -e 's/^[^:=]*[:=]//' )
fi
if [[ -n ${actual_memory} ]] ; then
- if [[ ${actual_memory} -lt $((1024 * $(check-reqs_get_mebibytes ${size}))) ]] ; then
+ if [[ ${actual_memory} -lt $(check-reqs_get_kbibytes ${size}) ]] ; then
eend 1
check-reqs_unsatisfied \
${size} \
@@ -300,16 +301,16 @@ check-reqs_disk() {
local path=${1}
local size=${2}
- local space_megs
+ local space_kbi
check-reqs_start_phase \
${size} \
"disk space at \"${path}\""
- space_megs=$(df -Pm "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}')
+ space_kbi=$(df -Pk "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}')
- if [[ $? == 0 && -n ${space_megs} ]] ; then
- if [[ ${space_megs} -lt $(check-reqs_get_mebibytes ${size}) ]] ; then
+ if [[ $? == 0 && -n ${space_kbi} ]] ; then
+ if [[ ${space_kbi} -lt $(check-reqs_get_kbibytes ${size}) ]] ; then
eend 1
check-reqs_unsatisfied \
${size} \
--
2.6.4
next prev parent reply other threads:[~2015-12-28 15:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-28 8:43 [gentoo-dev] [PATCH 0/9] Cleanup and EAPI=6 support for check-reqs.eclass Justin Lecher
2015-12-28 8:43 ` [gentoo-dev] [PATCH 1/9] check-reqs.eclass: Only inherit eclass once Justin Lecher
2015-12-28 8:43 ` [gentoo-dev] [PATCH 2/9] check-reqs.eclass: Use eqawarn() from eutils.eclass Justin Lecher
2015-12-28 8:43 ` [gentoo-dev] [PATCH 3/9] check-reqs.eclass: Mark interal function with @INTERNAL Justin Lecher
2015-12-28 8:43 ` [gentoo-dev] [PATCH 4/9] check-reqs.eclass: Fix typo Justin Lecher
2015-12-28 8:43 ` [gentoo-dev] [PATCH 5/9] check-reqs.eclass: Replace obsolete df option -m with -B ### Justin Lecher
2015-12-28 13:58 ` Andrew Savchenko
2015-12-28 14:16 ` Justin Lecher (jlec)
2015-12-28 14:24 ` Michał Górny
2015-12-28 14:28 ` Justin Lecher (jlec)
2015-12-28 14:34 ` Michał Górny
2015-12-28 15:27 ` [gentoo-dev] [PATCH] Replace df -m with df -k Justin Lecher
2015-12-28 15:27 ` Justin Lecher [this message]
2015-12-28 15:41 ` [gentoo-dev] [PATCH] check-reqs.eclass: Replace obsolete df option -m with -k Michał Górny
2015-12-28 15:45 ` Justin Lecher (jlec)
2015-12-28 8:43 ` [gentoo-dev] [PATCH 6/9] check-reqs.eclass: Ban obsolete functions in newer EAPIs Justin Lecher
2015-12-28 8:43 ` [gentoo-dev] [PATCH 7/9] check-reqs.eclass: Sanitize MERGE_TYPE for EAPI < 4 Justin Lecher
2015-12-28 8:43 ` [gentoo-dev] [PATCH 8/9] check-reqs.eclass: Require units for CHECKREQS_ in EAPIs > 5 Justin Lecher
2015-12-28 8:43 ` [gentoo-dev] [PATCH 9/9] check-reqs.eclass: Enable EAPI 6 support Justin Lecher
2015-12-28 9:35 ` [gentoo-dev] [PATCH 0/9] Cleanup and EAPI=6 support for check-reqs.eclass Andrew Savchenko
2015-12-28 9:40 ` Justin Lecher (jlec)
2015-12-28 12:34 ` Andrew Savchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1451316463-14550-2-git-send-email-jlec@gentoo.org \
--to=jlec@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=qa@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox