Meta: Run 'du' with '--apparent-size', except on macOS

Fixes #7172.
This commit is contained in:
Siddharth Kapoor 2021-05-16 14:50:46 -07:00 committed by GitHub
parent 2eb9dca782
commit dbd9d13857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-18 17:58:42 +09:00
3 changed files with 12 additions and 0 deletions

View file

@ -25,7 +25,11 @@ if [ -z $syslinux_dir ]; then
fi fi
disk_usage() { disk_usage() {
if [ "$(uname -s)" = "Darwin" ]; then
du -sm "$1" | cut -f1 du -sm "$1" | cut -f1
else
du -sm --apparent-size "$1" | cut -f1
fi
} }
DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 300)) DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 300))

View file

@ -24,7 +24,11 @@ fi
echo "using grub-install at ${grub}" echo "using grub-install at ${grub}"
disk_usage() { disk_usage() {
if [ "$(uname -s)" = "Darwin" ]; then
du -sm "$1" | cut -f1 du -sm "$1" | cut -f1
else
du -sm --apparent-size "$1" | cut -f1
fi
} }
DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 300)) DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 300))

View file

@ -20,7 +20,11 @@ fi
disk_usage() { disk_usage() {
# shellcheck disable=SC2003 # shellcheck disable=SC2003
if [ "$(uname -s)" = "Darwin" ]; then
expr "$(du -sk "$1" | cut -f1)" / 1024 expr "$(du -sk "$1" | cut -f1)" / 1024
else
expr "$(du -sk --apparent-size "$1" | cut -f1)" / 1024
fi
} }
DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 100)) DISK_SIZE=$(($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + 100))