]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
make.sh: Refactor the space check
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Jul 2024 18:13:06 +0000 (18:13 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Jul 2024 15:39:43 +0000 (15:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
make.sh

diff --git a/make.sh b/make.sh
index 18d8093e85d4e5910dfc60c4e44e2cc8717184af..e644a594d649fe8214dc3e07e7d47848f37b9be7 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -385,18 +385,17 @@ prepareenv() {
                        exiterror "root privileges required for building"
        fi
 
-       # Checking for necessary temporary space
-       print_line "Checking for necessary space on disk $BASE_DEV"
-       BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
-       BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
-       if (( 2048000 > $BASE_ASPACE )); then
-                       BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
-                       if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
-                               print_status FAIL
-                               exiterror "Not enough temporary space available, need at least 2GB on $BASE_DEV"
-                       fi
-       else
-                       print_status DONE
+       local free_space free_blocks block_size
+
+       # Fetch free blocks
+       read -r free_blocks block_size <<< "$(stat --file-system --format="%a %S" "${BUILD_DIR}")"
+
+       # Calculate free space
+       (( free_space = free_blocks * block_size / 1024 / 1024 ))
+
+       # Check if we have at least 4GB of space
+       if [ "${free_space}" -lt 4096 ]; then
+               exiterror "Not enough temporary space available, need at least 4GB"
        fi
 
        # Set umask