|
|
@ -26,6 +26,10 @@ ko_update_check() {
|
|
|
|
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
|
|
|
|
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
|
|
|
|
if [ -f "${NEWUPDATE}" ]; then
|
|
|
|
if [ -f "${NEWUPDATE}" ]; then
|
|
|
|
"${KOREADER_DIR}/fbink" -q -y -7 -pmh "Updating KOReader"
|
|
|
|
"${KOREADER_DIR}/fbink" -q -y -7 -pmh "Updating KOReader"
|
|
|
|
|
|
|
|
# Setup the FBInk daemon
|
|
|
|
|
|
|
|
export FBINK_NAMED_PIPE="/tmp/.koreader.fbink"
|
|
|
|
|
|
|
|
rm -f "${FBINK_NAMED_PIPE}"
|
|
|
|
|
|
|
|
FBINK_PID="$("${KOREADER_DIR}/fbink" --daemon 1 %KOREADER% -q -y -6 -P 0)"
|
|
|
|
# NOTE: See frontend/ui/otamanager.lua for a few more details on how we squeeze a percentage out of tar's checkpoint feature
|
|
|
|
# NOTE: See frontend/ui/otamanager.lua for a few more details on how we squeeze a percentage out of tar's checkpoint feature
|
|
|
|
# NOTE: %B should always be 512 in our case, so let stat do part of the maths for us instead of using %s ;).
|
|
|
|
# NOTE: %B should always be 512 in our case, so let stat do part of the maths for us instead of using %s ;).
|
|
|
|
FILESIZE="$(stat -c %b "${NEWUPDATE}")"
|
|
|
|
FILESIZE="$(stat -c %b "${NEWUPDATE}")"
|
|
|
@ -35,8 +39,9 @@ ko_update_check() {
|
|
|
|
# c.f., https://github.com/koreader/koreader/issues/7581
|
|
|
|
# c.f., https://github.com/koreader/koreader/issues/7581
|
|
|
|
KO_PB_TARLOG="/tmp/.koreader.tar"
|
|
|
|
KO_PB_TARLOG="/tmp/.koreader.tar"
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
"${KOREADER_DIR}/tar" --no-same-permissions --no-same-owner --checkpoint="${CPOINTS}" --checkpoint-action=exec='${KOREADER_DIR}/fbink -q -y -6 -P $(($TAR_CHECKPOINT/$CPOINTS))' -C "/mnt/ext1" -xf "${NEWUPDATE}" 2>"${KO_PB_TARLOG}"
|
|
|
|
"${KOREADER_DIR}/tar" --no-same-permissions --no-same-owner --checkpoint="${CPOINTS}" --checkpoint-action=exec='printf "%s" $((TAR_CHECKPOINT / CPOINTS)) > ${FBINK_NAMED_PIPE}' -C "/mnt/ext1" -xf "${NEWUPDATE}" 2>"${KO_PB_TARLOG}"
|
|
|
|
fail=$?
|
|
|
|
fail=$?
|
|
|
|
|
|
|
|
kill -TERM "${FBINK_PID}"
|
|
|
|
# As mentioned above, filter out potential chmod & utime failures...
|
|
|
|
# As mentioned above, filter out potential chmod & utime failures...
|
|
|
|
if [ "${fail}" -ne 0 ]; then
|
|
|
|
if [ "${fail}" -ne 0 ]; then
|
|
|
|
if [ "$(grep -Evc '(Cannot utime|Cannot change mode|Exiting with failure status due to previous errors)' "${KO_PB_TARLOG}")" -eq "0" ]; then
|
|
|
|
if [ "$(grep -Evc '(Cannot utime|Cannot change mode|Exiting with failure status due to previous errors)' "${KO_PB_TARLOG}")" -eq "0" ]; then
|
|
|
@ -56,7 +61,8 @@ ko_update_check() {
|
|
|
|
"${KOREADER_DIR}/fbink" -q -y -5 -pm "KOReader may fail to function properly!"
|
|
|
|
"${KOREADER_DIR}/fbink" -q -y -5 -pm "KOReader may fail to function properly!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
rm -f "${NEWUPDATE}" # always purge newupdate to prevent update loops
|
|
|
|
rm -f "${NEWUPDATE}" # always purge newupdate to prevent update loops
|
|
|
|
unset BLOCKS CPOINTS
|
|
|
|
unset CPOINTS FBINK_NAMED_PIPE
|
|
|
|
|
|
|
|
unset BLOCKS FILESIZE FBINK_PID
|
|
|
|
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!
|
|
|
|
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!
|
|
|
|
sync
|
|
|
|
sync
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|