From 4ffd959df43790d17a8962bd36f621da898ff279 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Wed, 4 Jul 2018 19:25:55 +0200 Subject: [PATCH] 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) ;). --- base | 2 +- frontend/ui/otamanager.lua | 6 +++ platform/kindle/koreader.sh | 69 ++++++++++++++++++--------------- platform/kindle/zsync_status.sh | 12 +++++- platform/kobo/koreader.sh | 41 ++++++++++++-------- platform/kobo/nickel.sh | 10 ++--- 6 files changed, 84 insertions(+), 56 deletions(-) diff --git a/base b/base index abe91abb0..a68b75df5 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit abe91abb0f4a2146a65ca131d323eb1d47760068 +Subproject commit a68b75df5037a480ad3dd5366ca7473371a74059 diff --git a/frontend/ui/otamanager.lua b/frontend/ui/otamanager.lua index f61935f39..fa6d03633 100644 --- a/frontend/ui/otamanager.lua +++ b/frontend/ui/otamanager.lua @@ -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?"), diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index 8ee7844d4..54906e8f0 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -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=$? - 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 +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 - 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 diff --git a/platform/kindle/zsync_status.sh b/platform/kindle/zsync_status.sh index 6ce02cfc3..9a3c601b6 100755 --- a/platform/kindle/zsync_status.sh +++ b/platform/kindle/zsync_status.sh @@ -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 diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index 093bf1e57..da393ec92 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -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 diff --git a/platform/kobo/nickel.sh b/platform/kobo/nickel.sh index 63e390f76..00207bc38 100755 --- a/platform/kobo/nickel.sh +++ b/platform/kobo/nickel.sh @@ -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