More KoboUSBMS related tweaks & cleanups (#6590)

* Be even more defensive around KoboUSBMS handling in the startup script

And add some more logging. To the log before a session, to the syslog
after, because we can't be sure onboard is viable.

* Display a short version string straight in the Version label

* Move system statistics inside the Help menu

* Move Version inside Help


* Bump base

https://github.com/koreader/koreader-base/pull/1173
reviewable/pr6596/r1
NiLuJe 4 years ago committed by GitHub
parent 06bce655c5
commit e402c9d6f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 44f88d93db67117409c7b6734776961738f1f180
Subproject commit 3deb3dafe137f57bde6ab1ca3a0f96af2c477597

@ -3,6 +3,7 @@ local Device = require("device")
local Event = require("ui/event")
local InfoMessage = require("ui/widget/infomessage")
local UIManager = require("ui/uimanager")
local Version = require("version")
local _ = require("gettext")
local T = require("ffi/util").template
@ -12,13 +13,12 @@ if Device:hasOTAUpdates() then
local OTAManager = require("ui/otamanager")
common_info.ota_update = OTAManager:getOTAMenuTable()
end
local version = require("version"):getCurrentRevision()
common_info.version = {
text = _("Version"),
text = T(_("Version: %1"), Version:getShortVersion()),
keep_menu_open = true,
callback = function()
UIManager:show(InfoMessage:new{
text = version,
text = Version:getCurrentRevision(),
})
end
}
@ -45,7 +45,7 @@ common_info.about = {
keep_menu_open = true,
callback = function()
UIManager:show(InfoMessage:new{
text = T(_("KOReader %1\n\nA document viewer for E Ink devices.\n\nLicensed under Affero GPL v3. All dependencies are free software.\n\nhttp://koreader.rocks/"), BD.ltr(version)),
text = T(_("KOReader %1\n\nA document viewer for E Ink devices.\n\nLicensed under Affero GPL v3. All dependencies are free software.\n\nhttp://koreader.rocks/"), BD.ltr(Version:getCurrentRevision())),
icon_file = "resources/ko-icon.png",
alpha = true,
})
@ -57,7 +57,7 @@ common_info.report_bug = {
callback = function()
UIManager:show(InfoMessage:new{
text = T(_("Please report bugs to \nhttps://github.com/koreader/koreader/issues\n\nVersion:\n%1\n\nDetected device:\n%2"),
version, Device:info()),
Version:getCurrentRevision(), Device:info()),
})
end
}

@ -139,11 +139,9 @@ local order = {
"----------------------------",
"collections",
"----------------------------",
"system_statistics",
"mass_storage_actions",
"mass_storage_actions", -- if Device:canToggleMassStorage()
"----------------------------",
"ota_update", -- if Device:hasOTAUpdates()
"version",
"help",
"----------------------------",
"exit_menu",
@ -153,6 +151,8 @@ local order = {
"----------------------------",
"report_bug",
"----------------------------",
"system_statistics", -- if enabled (Plugin)
"version",
"about",
},
plus_menu = {},

@ -166,11 +166,9 @@ local order = {
"book_status",
"book_info",
"----------------------------",
"system_statistics",
"mass_storage_actions",
"mass_storage_actions", -- if Device:canToggleMassStorage()
"----------------------------",
"ota_update", -- if Device:hasOTAUpdates()
"version",
"help",
"----------------------------",
"exit_menu",
@ -180,6 +178,8 @@ local order = {
"----------------------------",
"report_bug",
"----------------------------",
"system_statistics", -- if enabled (Plugin)
"version",
"about",
},
exit_menu = {

@ -50,4 +50,21 @@ function Version:getNormalizedCurrentVersion()
return self.version, self.commit
end
--- Returns current version of KOReader, in short form.
-- @treturn string version, without the git details (i.e., at most YYYY.MM.P-R)
function Version:getShortVersion()
if not self.short then
local rev = self:getCurrentRevision()
local year, month, point, revision = rev:match("v(%d%d%d%d)%.(%d%d)%.?(%d?%d?)-?(%d*)")
self.short = year .. "." .. month
if point then
self.short = self.short .. "." .. point
end
if revision then
self.short = self.short .. "-" .. revision
end
end
return self.short
end
return Version

@ -363,7 +363,10 @@ while [ ${RETURN_VALUE} -ne 0 ]; do
if [ ${RETURN_VALUE} -eq ${KO_RC_USBMS} ]; then
# User requested an USBMS session, setup the tool outside of onboard
mkdir -p "/tmp/usbms"
./tar xzf "./data/KoboUSBMS.tar.gz" -C "/tmp/usbms"
if ! ./tar xzf "./data/KoboUSBMS.tar.gz" -C "/tmp/usbms"; then
echo "Couldn't unpack KoboUSBMS to /tmp/usbms, restarting KOReader . . ." >>crash.log 2>&1
continue
fi
# Then siphon KOReader's language for i18n...
if grep -q '\["language"\]' 'settings.reader.lua' 2>/dev/null; then
@ -373,15 +376,24 @@ while [ ${RETURN_VALUE} -ne 0 ]; do
fi
# Here we go!
cd "/tmp/usbms" || continue
if ! cd "/tmp/usbms"; then
echo "Couldn't chdir to /tmp/usbms, restarting KOReader . . ." >>crash.log 2>&1
continue
fi
if ! env LANGUAGE="${usbms_lang}" ./usbms; then
# Hu, oh, something went wrong... Stay around for 90s (enough time to look at the syslog over Wi-Fi), and then shutdown.
fail=$?
logger -p "DAEMON.CRIT" -t "koreader.sh[$$]" "USBMS session failed (${fail}), shutting down in 90 sec!"
sleep 90
poweroff -f
fi
# Jump back to the right place, and keep on trucking
cd "${KOREADER_DIR}" || poweroff -f
if ! cd "${KOREADER_DIR}"; then
logger -p "DAEMON.CRIT" -t "koreader.sh[$$]" "Couldn't chdir back to KOREADER_DIR (${KOREADER_DIR}), shutting down in 30 sec!"
sleep 30
poweroff -f
fi
rm -rf "/tmp/usbms"
fi
done

Loading…
Cancel
Save