mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Handle OTA updates during the restart loop on Kobo/Kindle (#4049)
* Handle OTA updates during the restart loop on Kobo/Kindle So we can actually process OTA updates without ever truly exiting KOReader (i.e., via the "Restart KOReader" menu entry) ;).
This commit is contained in:
2
base
2
base
Submodule base updated: abe91abb0f...a68b75df50
@@ -155,6 +155,12 @@ function OTAManager:fetchAndProcessUpdate()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("KOReader will be updated on next restart."),
|
||||
})
|
||||
-- Make it clear that zsync is done
|
||||
if Device:isKindle() then
|
||||
os.execute("./zsync_status.sh clear")
|
||||
elseif Device:isKobo() then
|
||||
os.execute("./fbink -q -y -7 -pm ' ' ' '")
|
||||
end
|
||||
else
|
||||
UIManager:show(ConfirmBox:new{
|
||||
text = _("Error updating KOReader. Would you like to delete temporary files?"),
|
||||
|
||||
@@ -86,38 +86,42 @@ fi
|
||||
cd "${KOREADER_DIR}" || exit
|
||||
|
||||
# Handle pending OTA update
|
||||
NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar"
|
||||
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
|
||||
if [ -f "${NEWUPDATE}" ]; then
|
||||
logmsg "Updating koreader . . ."
|
||||
# Look for our own GNU tar build to do a fancy progress tracking...
|
||||
GNUTAR_BIN="${KOREADER_DIR}/tar"
|
||||
if [ -x "${GNUTAR_BIN}" ]; then
|
||||
# Let our checkpoint script handle the detailed visual feedback...
|
||||
eips_print_bottom_centered "Updating KOReader" 3
|
||||
# shellcheck disable=SC2016
|
||||
${GNUTAR_BIN} -C "/mnt/us" --no-same-owner --no-same-permissions --checkpoint=200 --checkpoint-action=exec='./kotar_cpoint $TAR_CHECKPOINT' -xf "${NEWUPDATE}"
|
||||
fail=$?
|
||||
else
|
||||
# Fall back to busybox tar
|
||||
eips_print_bottom_centered "Updating KOReader . . ." 3
|
||||
tar -C "/mnt/us" -xf "${NEWUPDATE}"
|
||||
fail=$?
|
||||
ko_update_check() {
|
||||
NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar"
|
||||
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
|
||||
if [ -f "${NEWUPDATE}" ]; then
|
||||
logmsg "Updating koreader . . ."
|
||||
# Look for our own GNU tar build to do a fancy progress tracking...
|
||||
GNUTAR_BIN="${KOREADER_DIR}/tar"
|
||||
if [ -x "${GNUTAR_BIN}" ]; then
|
||||
# Let our checkpoint script handle the detailed visual feedback...
|
||||
eips_print_bottom_centered "Updating KOReader" 3
|
||||
# shellcheck disable=SC2016
|
||||
${GNUTAR_BIN} -C "/mnt/us" --no-same-owner --no-same-permissions --checkpoint=200 --checkpoint-action=exec='./kotar_cpoint $TAR_CHECKPOINT' -xf "${NEWUPDATE}"
|
||||
fail=$?
|
||||
else
|
||||
# Fall back to busybox tar
|
||||
eips_print_bottom_centered "Updating KOReader . . ." 3
|
||||
tar -C "/mnt/us" -xf "${NEWUPDATE}"
|
||||
fail=$?
|
||||
fi
|
||||
# Cleanup behind us...
|
||||
if [ "${fail}" -eq 0 ]; then
|
||||
mv "${NEWUPDATE}" "${INSTALLED}"
|
||||
logmsg "Update successful :)"
|
||||
eips_print_bottom_centered "Update successful :)" 2
|
||||
eips_print_bottom_centered "KOReader will start momentarily . . ." 1
|
||||
else
|
||||
# Huh ho...
|
||||
logmsg "Update failed :("
|
||||
eips_print_bottom_centered "Update failed :(" 2
|
||||
eips_print_bottom_centered "KOReader may fail to function properly" 1
|
||||
fi
|
||||
rm -f "${NEWUPDATE}" # always purge newupdate in all cases to prevent update loop
|
||||
fi
|
||||
# Cleanup behind us...
|
||||
if [ "${fail}" -eq 0 ]; then
|
||||
mv "${NEWUPDATE}" "${INSTALLED}"
|
||||
logmsg "Update successful :)"
|
||||
eips_print_bottom_centered "Update successful :)" 2
|
||||
eips_print_bottom_centered "KOReader will start momentarily . . ." 1
|
||||
else
|
||||
# Huh ho...
|
||||
logmsg "Update failed :("
|
||||
eips_print_bottom_centered "Update failed :(" 2
|
||||
eips_print_bottom_centered "KOReader may fail to function properly" 1
|
||||
fi
|
||||
rm -f "${NEWUPDATE}" # always purge newupdate in all cases to prevent update loop
|
||||
fi
|
||||
}
|
||||
# NOTE: Keep doing an initial update check, in addition to one during the restart loop...
|
||||
ko_update_check
|
||||
|
||||
# load our own shared libraries if possible
|
||||
export LD_LIBRARY_PATH="${KOREADER_DIR}/libs:${LD_LIBRARY_PATH}"
|
||||
@@ -235,6 +239,9 @@ fi
|
||||
|
||||
RETURN_VALUE=85
|
||||
while [ "${RETURN_VALUE}" -eq 85 ]; do
|
||||
# Do an update check now, so we can actually update KOReader via the "Restart KOReader" menu entry ;).
|
||||
ko_update_check
|
||||
|
||||
./reader.lua "$@" >>crash.log 2>&1
|
||||
RETURN_VALUE=$?
|
||||
done
|
||||
|
||||
@@ -15,5 +15,13 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eips_print_bottom_centered "Computing zsync delta . . ." 3
|
||||
|
||||
# What are we printing?
|
||||
case "${1}" in
|
||||
"clear")
|
||||
eips_print_bottom_centered " " 3
|
||||
eips_print_bottom_centered " " 2
|
||||
;;
|
||||
*)
|
||||
eips_print_bottom_centered "Computing zsync delta . . ." 3
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -8,24 +8,28 @@ KOREADER_DIR="${0%/*}"
|
||||
cd "${KOREADER_DIR}" || exit
|
||||
|
||||
# update to new version from OTA directory
|
||||
NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar"
|
||||
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
|
||||
if [ -f "${NEWUPDATE}" ]; then
|
||||
# shellcheck disable=SC2016
|
||||
./tar xf "${NEWUPDATE}" --strip-components=1 --no-same-permissions --no-same-owner --checkpoint=200 --checkpoint-action=exec='./kotar_cpoint $TAR_CHECKPOINT'
|
||||
fail=$?
|
||||
# Cleanup behind us...
|
||||
if [ "${fail}" -eq 0 ]; then
|
||||
mv "${NEWUPDATE}" "${INSTALLED}"
|
||||
./fbink -q -y -6 -pm "Update successful :)"
|
||||
./fbink -q -y -5 -pm "KOReader will start momentarily . . ."
|
||||
else
|
||||
# Huh ho...
|
||||
./fbink -q -y -6 -pmh "Update failed :("
|
||||
./fbink -q -y -5 -pm "KOReader may fail to function properly!"
|
||||
ko_update_check() {
|
||||
NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar"
|
||||
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
|
||||
if [ -f "${NEWUPDATE}" ]; then
|
||||
# shellcheck disable=SC2016
|
||||
./tar xf "${NEWUPDATE}" --strip-components=1 --no-same-permissions --no-same-owner --checkpoint=200 --checkpoint-action=exec='./kotar_cpoint $TAR_CHECKPOINT'
|
||||
fail=$?
|
||||
# Cleanup behind us...
|
||||
if [ "${fail}" -eq 0 ]; then
|
||||
mv "${NEWUPDATE}" "${INSTALLED}"
|
||||
./fbink -q -y -6 -pm "Update successful :)"
|
||||
./fbink -q -y -5 -pm "KOReader will start momentarily . . ."
|
||||
else
|
||||
# Huh ho...
|
||||
./fbink -q -y -6 -pmh "Update failed :("
|
||||
./fbink -q -y -5 -pm "KOReader may fail to function properly!"
|
||||
fi
|
||||
rm -f "${NEWUPDATE}" # always purge newupdate in all cases to prevent update loop
|
||||
fi
|
||||
rm -f "${NEWUPDATE}" # always purge newupdate in all cases to prevent update loop
|
||||
fi
|
||||
}
|
||||
# NOTE: Keep doing an initial update check, in addition to one during the restart loop...
|
||||
ko_update_check
|
||||
|
||||
# load our own shared libraries if possible
|
||||
export LD_LIBRARY_PATH="${KOREADER_DIR}/libs:${LD_LIBRARY_PATH}"
|
||||
@@ -116,6 +120,9 @@ fi
|
||||
|
||||
RETURN_VALUE=85
|
||||
while [ $RETURN_VALUE -eq 85 ]; do
|
||||
# Do an update check now, so we can actually update KOReader via the "Restart KOReader" menu entry ;).
|
||||
ko_update_check
|
||||
|
||||
./reader.lua "${args}" >>crash.log 2>&1
|
||||
RETURN_VALUE=$?
|
||||
done
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#!/bin/sh
|
||||
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib:"
|
||||
|
||||
# We don't need to duplicate any of the env setup from rcS, since we will only ever run this to *restart* nickel, and not bootstrap it.
|
||||
# Meaning we've already got most of the necessary env from nickel itself via both our launcher (fmon/KFMon) and our own startup script.
|
||||
# NOTE: LD_LIBRARY_PATH is the only late export from rcS we don't siphon in koreader.sh, for obvious reasons ;).
|
||||
export LD_LIBRARY_PATH="/usr/local/Kobo"
|
||||
|
||||
# Ensures fmon will restart. Note that we don't have to worry about reaping this, nickel kills on-animator.sh on start.
|
||||
(
|
||||
if [ "${PLATFORM}" = "freescale" ] || [ "${PLATFORM}" = "mx50-ntx" ] || [ "${PLATFORM}" = "mx6sl-ntx" ]; then
|
||||
@@ -9,11 +14,6 @@ PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib:"
|
||||
/etc/init.d/on-animator.sh
|
||||
) &
|
||||
|
||||
# We don't need to duplicate any of the env setup from rcS, since we will only ever run this to *restart* nickel, and not bootstrap it.
|
||||
# Meaning we've already got most of the necessary env from nickel itself via both our launcher (fmon/KFMon) and our own startup script.
|
||||
# NOTE: LD_LIBRARY_PATH is the only late export from rcS we don't siphon in koreader.sh, for obvious reasons ;).
|
||||
export LD_LIBRARY_PATH="/usr/local/Kobo"
|
||||
|
||||
# Make sure we kill the WiFi first, because nickel apparently doesn't like it if it's up... (cf. #1520)
|
||||
# NOTE: That check is possibly wrong on PLATFORM == freescale (because I don't know if the sdio_wifi_pwr module exists there), but we don't terribly care about that.
|
||||
if lsmod | grep -q sdio_wifi_pwr; then
|
||||
|
||||
Reference in New Issue
Block a user