Skip to content

Commit

Permalink
Meta: Assume and find GNU du
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
endofexclusive authored and awesomekling committed Aug 18, 2021
1 parent dd0244a commit 0ed2a03
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Meta/build-image-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

disk_usage() {
# shellcheck disable=SC2003
if [ "$(uname -s)" = "Darwin" ]; then
expr "$(du -sk "$1" | cut -f1)"
# 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
expr "$(du -sk --apparent-size "$1" | cut -f1)"
GNUDU="du"
fi

disk_usage() {
# shellcheck disable=SC2003
expr "$(${GNUDU} -sk --apparent-size "$1" | cut -f1)"
}

inode_usage() {
Expand Down

0 comments on commit 0ed2a03

Please sign in to comment.