@@ -8817,6 +8817,51 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or
88178817 return 1
88188818 fi
88198819
8820+ # #---------------------------------------##
8821+ # # Added by ExtremeFiretop [2025-May-29] ##
8822+ # #---------------------------------------##
8823+ # Step 1: Find files
8824+ foundFiles=$( { /usr/bin/find -L " $FW_BIN_DIR " -name " *.w" -print; /usr/bin/find -L " $FW_BIN_DIR " -name " *.pkgtb" -print; } )
8825+
8826+ # Initialize the total size counter
8827+ total_size_bytes=0
8828+
8829+ IFS=$' \n ' # Set IFS to newline to correctly iterate over files in case they contain spaces
8830+ for file in $foundFiles ; do
8831+ if [ -f " $file " ]; then # Ensure the file exists and is a regular file
8832+ # Use wc -c to count the file size in bytes and add it to the total
8833+ size=$( wc -c < " $file " )
8834+ total_size_bytes=$(( total_size_bytes + size)) # Accumulate total size
8835+ fi
8836+ done
8837+ unset IFS # Reset IFS to default
8838+
8839+ # Display the total size in bytes
8840+ Say " Total size of files: $total_size_bytes bytes"
8841+
8842+ # Convert total size from bytes to KB and adjust the required space
8843+ total_size_kb=" $(( total_size_bytes / 1024 )) "
8844+
8845+ # Set the minimum required RAM cushion to 50MB (50 * 1024 = 51200)
8846+ minimum_cushion_kb=51200
8847+
8848+ # Subtract the calculated size from requiredRAM_kb
8849+ if [ " $total_size_kb " -gt 0 ]; then
8850+ requiredRAM_kb=$(( requiredRAM_kb - total_size_kb))
8851+ Say " Adjusted required RAM by subtracting sizes of .w or .pkgtb files: $total_size_kb KB. New required RAM: ${requiredRAM_kb} KB"
8852+
8853+ # Check if the adjusted required space is less than the minimum cushion
8854+ if [ " $requiredRAM_kb " -lt " $minimum_cushion_kb " ]; then
8855+ # Add the difference to fulfill the minimum cushion
8856+ cushion_diff=$(( minimum_cushion_kb - requiredRAM_kb))
8857+ requiredRAM_kb=$(( requiredRAM_kb + cushion_diff))
8858+ Say " Added cushion of $cushion_diff KB to meet the minimum required RAM of 50MB."
8859+ fi
8860+ else
8861+ Say " No .w or .pkgtb file found for adjustment."
8862+ return 1
8863+ fi
8864+
88208865 freeRAM_kb=" $( _GetFreeRAM_KB_) "
88218866 availableRAM_kb=" $( _GetAvailableRAM_KB_) "
88228867 Say " Required RAM: ${requiredRAM_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB"
0 commit comments