diff --git a/frontend/apps/filemanager/filemanagermenu.lua b/frontend/apps/filemanager/filemanagermenu.lua index 014c913a7..50a6e5269 100644 --- a/frontend/apps/filemanager/filemanagermenu.lua +++ b/frontend/apps/filemanager/filemanagermenu.lua @@ -565,8 +565,21 @@ dbg:guard(FileManagerMenu, 'setUpdateItemTable', end end) -function FileManagerMenu:exitOrRestart(callback) +function FileManagerMenu:exitOrRestart(callback, force) UIManager:close(self.menu_container) + + -- Only restart sets a callback, which suits us just fine for this check ;) + if callback and not force and not Device:isStartupScriptUpToDate() then + UIManager:show(ConfirmBox:new{ + text = _("KOReader's startup script has been updated. You'll need to completely exit KOReader to finalize the update."), + ok_text = _("Restart anyway"), + ok_callback = function() + self:exitOrRestart(callback, true) + end, + }) + return + end + self.ui:onClose() if callback then callback() diff --git a/frontend/apps/reader/modules/readermenu.lua b/frontend/apps/reader/modules/readermenu.lua index e3e31f83f..9ebba88b2 100644 --- a/frontend/apps/reader/modules/readermenu.lua +++ b/frontend/apps/reader/modules/readermenu.lua @@ -259,8 +259,21 @@ dbg:guard(ReaderMenu, 'setUpdateItemTable', end end) -function ReaderMenu:exitOrRestart(callback) +function ReaderMenu:exitOrRestart(callback, force) if self.menu_container then self:onTapCloseMenu() end + + -- Only restart sets a callback, which suits us just fine for this check ;) + if callback and not force and not Device:isStartupScriptUpToDate() then + UIManager:show(ConfirmBox:new{ + text = _("KOReader's startup script has been updated. You'll need to completely exit KOReader to finalize the update."), + ok_text = _("Restart anyway"), + ok_callback = function() + self:exitOrRestart(callback, true) + end, + }) + return + end + UIManager:nextTick(function() self.ui:onClose() if callback ~= nil then diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index d08c2cca0..30d59eced 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -491,4 +491,9 @@ function Device:isValidPath(path) return util.pathExists(path) end +-- Device specific method to check if the startup script has been updated +function Device:isStartupScriptUpToDate() + return true +end + return Device diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index b42610457..9eb0c383f 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -819,6 +819,15 @@ function Kobo:toggleChargingLED(toggle) io.close(f) end +function Kobo:isStartupScriptUpToDate() + -- Compare the hash of the *active* script (i.e., the one in /tmp) to the *potential* one (i.e., the one in KOREADER_DIR) + local current_script = "/tmp/koreader.sh" + local new_script = os.getenv("KOREADER_DIR") .. "/" .. "koreader.sh" + + local md5 = require("ffi/MD5") + return md5.sumFile(current_script) == md5.sumFile(new_script) +end + -------------- device probe ------------ local codename = Kobo:getCodeName() diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index ee51af1f1..8a71611e1 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -100,6 +100,11 @@ ko_update_check() { mv "${NEWUPDATE}" "${INSTALLED}" ./fbink -q -y -6 -pm "Update successful :)" ./fbink -q -y -5 -pm "KOReader will start momentarily . . ." + + # Warn if the startup script has been updated... + if [ "$(md5sum "/tmp/koreader.sh" | cut -f1 -d' ')" != "$(md5sum "${KOREADER_DIR}/koreader.sh" | cut -f1 -d' ')" ]; then + ./fbink -q -pmMh "Update contains a startup script update!" + fi else # Uh oh... ./fbink -q -y -6 -pmh "Update failed :("