add space check

This commit is contained in:
Ing 2024-03-15 00:44:45 +08:00
parent f8ac354fd0
commit 22f410fdcb
14 changed files with 1838 additions and 1806 deletions

4
.gitignore vendored
View File

@ -8,9 +8,7 @@ test*.sh
cache cache
*.bak *.bak
*.o *.o
files/initrd/opt/rr/lang/*.mo **.mo
tests tests
/extractor /extractor
/br
/rdxz_tmp
Changelog* Changelog*

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -11,9 +11,9 @@
alias DIALOG='dialog --backtitle "$(backtitle)" --colors --aspect 50' alias DIALOG='dialog --backtitle "$(backtitle)" --colors --aspect 50'
# Check partition 3 space, if < 2GiB is necessary clean cache folder # Check partition 3 space, if < 2GiB is necessary clean cache folder
PACELEFT=$(df -m ${LOADER_DISK_PART3} 2>/dev/null | awk 'NR==2 {print $4}') SPACELEFT=$(df -m ${PART3_PATH} 2>/dev/null | awk 'NR==2 {print $4}')
CLEARCACHE=0 CLEARCACHE=0
if [ ${PACELEFT:-0} -lt 430 ]; then if [ ${SPACELEFT:-0} -lt 430 ]; then
CLEARCACHE=1 CLEARCACHE=1
fi fi
@ -450,7 +450,7 @@ function ParsePat() {
mkdir -p "${PART3_PATH}/dl" mkdir -p "${PART3_PATH}/dl"
# Check disk space left # Check disk space left
SPACELEFT=$(df -m ${LOADER_DISK_PART3} 2>/dev/null | awk 'NR==2 {print $4}') SPACELEFT=$(df -m ${PART3_PATH} 2>/dev/null | awk 'NR==2 {print $4}')
# Discover remote file size # Discover remote file size
FILESIZE=$(du -m "${PAT_PATH}" 2>/dev/null | awk '{print $1}') FILESIZE=$(du -m "${PAT_PATH}" 2>/dev/null | awk '{print $1}')
if [ ${FILESIZE:-0} -ge ${SPACELEFT:-0} ]; then if [ ${FILESIZE:-0} -ge ${SPACELEFT:-0} ]; then
@ -1208,7 +1208,7 @@ function extractDsmFiles() {
fi fi
echo "$(printf "$(TEXT "Downloading %s ...")" "${PAT_FILE}")" echo "$(printf "$(TEXT "Downloading %s ...")" "${PAT_FILE}")"
# Check disk space left # Check disk space left
SPACELEFT=$(df --block-size=1 ${LOADER_DISK_PART3} 2>/dev/null | awk 'NR==2 {print $4}') SPACELEFT=$(df --block-size=1 ${PART3_PATH} 2>/dev/null | awk 'NR==2 {print $4}')
# Discover remote file size # Discover remote file size
FILESIZE=$(curl -skLI --connect-timeout 10 "${PATURL}" | grep -i Content-Length | tail -n 1 | tr -d '\r\n' | awk '{print $2}') FILESIZE=$(curl -skLI --connect-timeout 10 "${PATURL}" | grep -i Content-Length | tail -n 1 | tr -d '\r\n' | awk '{print $2}')
if [ ${FILESIZE:-0} -ge ${SPACELEFT:-0} ]; then if [ ${FILESIZE:-0} -ge ${SPACELEFT:-0} ]; then
@ -1270,6 +1270,16 @@ function make() {
[ $? -ne 0 ] && break [ $? -ne 0 ] && break
fi fi
while true; do
SIZE=256 # initrd-dsm + zImage-dsm ≈ 210M
SPACELEFT=$(df -m ${PART3_PATH} 2>/dev/null | awk 'NR==2 {print $4}')
[ ${SPACELEFT:-0} -ge ${SIZE} ] && break
[ -f ${MOD_ZIMAGE_FILE} ] && rm -f "${MOD_ZIMAGE_FILE}" && continue
[ -f ${MOD_RDGZ_FILE} ] && rm -f "${MOD_RDGZ_FILE}" && continue
echo -e "$(TEXT "No disk space left, please clean the cache and try again!")" >"${LOG_FILE}"
break 2
done
${WORK_PATH}/zimage-patch.sh ${WORK_PATH}/zimage-patch.sh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "$(TEXT "zImage not patched,\nPlease upgrade the bootloader version and try again.\nPatch error:\n")$(<"${LOG_FILE}")" >"${LOG_FILE}" echo -e "$(TEXT "zImage not patched,\nPlease upgrade the bootloader version and try again.\nPatch error:\n")$(<"${LOG_FILE}")" >"${LOG_FILE}"