]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
make.sh: Make the disk space check optional
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Jul 2024 09:45:39 +0000 (09:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Jul 2024 15:39:44 +0000 (15:39 +0000)
There is little value in running this when entering a shell...

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
make.sh

diff --git a/make.sh b/make.sh
index 0671387accce4c766a4b6e4cf09c4cad70a1be58..8e7372b325a1c0b9798fbe0f928165ea4421a5d1 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -398,17 +398,36 @@ prepareenv() {
                exiterror "root privileges required for building"
        fi
 
-       local free_space free_blocks block_size
+       local required_space
 
-       # Fetch free blocks
-       read -r free_blocks block_size <<< "$(stat --file-system --format="%a %S" "${BASEDIR}")"
+       # Parse arguments
+       while [ $# -gt 0 ]; do
+               case "${1}" in
+                       --required-space=*)
+                               required_space="${1#--required-space=}"
+                               ;;
+
+                       *)
+                               exiterror "Unknown argument: ${1}"
+                               ;;
+               esac
+               shift
+       done
 
-       # Calculate free space
-       (( free_space = free_blocks * block_size / 1024 / 1024 ))
+       # Do we need to check the required space?
+       if [ -n "${required_space}" ]; then
+               local free_space free_blocks block_size
 
-       # 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"
+               # Fetch free blocks
+               read -r free_blocks block_size <<< "$(stat --file-system --format="%a %S" "${BASEDIR}")"
+
+               # Calculate free space
+               (( free_space = free_blocks * block_size / 1024 / 1024 ))
+
+               # Check if we have at least 4GB of space
+               if [ "${free_space}" -lt "${required_space}" ]; then
+                       exiterror "Not enough temporary space available, need at least ${required_space}MiB"
+               fi
        fi
 
        # Set umask
@@ -2067,7 +2086,7 @@ build)
        exec_in_namespace "$@"
 
        # Prepare the environment
-       prepareenv
+       prepareenv --required-space=2048
 
        # Check if the toolchain is available
        if [ ! -e "${BUILD_DIR}${TOOLS_DIR}/.toolchain-successful" ]; then