From 0ed2a03450cc50b0f307fd2a8d04bf645e02d9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C3=85berg?= Date: Tue, 17 Aug 2021 18:27:55 +0200 Subject: [PATCH] Meta: Assume and find GNU du We want to use use the 'du' option '--apparent-size' which is a GNU coreutils extension. GNU coreutils is a build dependency so we know it is available. With this commit we first try to pick up du as 'gdu', and if that fails, try 'du' instead. --- Meta/build-image-qemu.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Meta/build-image-qemu.sh b/Meta/build-image-qemu.sh index 4dc8726804e..87d45609400 100755 --- a/Meta/build-image-qemu.sh +++ b/Meta/build-image-qemu.sh @@ -30,13 +30,17 @@ PATH="$SCRIPT_DIR/../Toolchain/Local/qemu/bin:$PATH" # directory was changed to Toolchain/Local/qemu. PATH="$SCRIPT_DIR/../Toolchain/Local/i686/bin:$PATH" +# We depend on GNU coreutils du for the --apparent-size extension. +# GNU coreutils is a build dependency. +if type gdu > /dev/null 2>&1; then + GNUDU="gdu" +else + GNUDU="du" +fi + disk_usage() { # shellcheck disable=SC2003 -if [ "$(uname -s)" = "Darwin" ]; then - expr "$(du -sk "$1" | cut -f1)" -else - expr "$(du -sk --apparent-size "$1" | cut -f1)" -fi + expr "$(${GNUDU} -sk --apparent-size "$1" | cut -f1)" } inode_usage() {