From a50bd44c440efd126175d08db57e4274abdb5316 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 3 Sep 2024 18:42:25 +0000 Subject: [PATCH] make.sh: Subtract any used space for the space check Signed-off-by: Michael Tremer --- make.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/make.sh b/make.sh index 966e5bc2e6..0c5c30987d 100755 --- a/make.sh +++ b/make.sh @@ -378,6 +378,7 @@ prepareenv() { # Do we need to check the required space? if [ -n "${required_space}" ]; then local free_space free_blocks block_size + local consumed_space path # Fetch free blocks read -r free_blocks block_size <<< "$(stat --file-system --format="%a %S" "${BASEDIR}")" @@ -385,9 +386,17 @@ prepareenv() { # Calculate free space (( free_space = free_blocks * block_size / 1024 / 1024 )) - # Check if we have at least 4GB of space + # If we don't have the total space free, we need to check how much we have consumed already... if [ "${free_space}" -lt "${required_space}" ]; then - exiterror "Not enough temporary space available, need at least ${required_space}MiB" + # Add any consumed space + while read -r consumed_space path; do + (( free_space += consumed_space / 1024 / 1024 )) + done <<< "$(du --summarize --bytes "${BUILD_DIR}" "${IMAGES_DIR}" "${LOG_DIR}")" + fi + + # Check that we have the required space + if [ "${free_space}" -lt "${required_space}" ]; then + exiterror "Not enough temporary space available, need at least ${required_space}MiB, but only have ${free_space}MiB" fi fi -- 2.39.5