remarkable: detect if launcher script has changed

And a complete restart from the parent launcher is needed.
This commit is contained in:
Benoit Pierre
2025-12-13 00:35:52 +01:00
committed by Frans de Jonge
parent 0094ea2cb0
commit 2e2a4875c9
2 changed files with 18 additions and 1 deletions

View File

@@ -426,6 +426,12 @@ function Remarkable:getDefaultCoverPath()
return "/usr/share/remarkable/poweroff.png"
end
function Remarkable:isStartupScriptUpToDate()
local md5 = require("ffi/MD5")
-- Compare the hash of the *active* script to the *potential* one.
return md5.sumFile("/tmp/koreader.sh") == md5.sumFile(os.getenv("KOREADER_DIR") .. "/koreader.sh")
end
function Remarkable:setEventHandlers(UIManager)
UIManager.event_handlers.Suspend = function()
self:onPowerEvent("Suspend")

View File

@@ -1,7 +1,18 @@
#!/bin/sh
# Relocalize ourselves to /tmp: this is used by KOReader to detect if the
# original script has changed after an update (requiring a complete restart
# from the parent launcher).
if [ "$(dirname "${0}")" != '/tmp' ]; then
cp -pf "${0}" '/tmp/koreader.sh'
chmod 777 '/tmp/koreader.sh'
exec '/tmp/koreader.sh' "$@"
fi
export LC_ALL="en_US.UTF-8"
# working directory of koreader
KOREADER_DIR="${0%/*}"
export KOREADER_DIR="${0%/*}"
UNPACK_DIR="${KOREADER_DIR%/*}"
# we're always starting from our working directory