The concept is quite simple: stick a file on the OTA server named
something like `koreader-appimage-latest-stable` (by analogy with
`koreader-cervantes-latest-stable.zsync`), which contains nothing
but a filename.
The difference with the zsync update is that the link is then launched
in the user's browser (AppImage) or DownloadManager (Android, not yet
implemented).
* Android hasOTAUpdate = no for the moment
text=T(_("OTA package is not available on %1 channel."),channel),
text=T(_("Update information not available on %1 channel."),channel),
})
})
elseifota_versionthen
elseifota_versionthen
UIManager:show(ConfirmBox:new{
ifOTAManager:getOTAType()=="link"then
text=T(
UIManager:show(ConfirmBox:new{
_("Do you want to update?\nInstalled version: %1\nAvailable version: %2"),
text=T(
local_version,
_("Do you want to update?\nInstalled version: %1\nAvailable version: %2"),
ota_version
local_version,
),
ota_version
ok_text=_("Update"),
),
ok_callback=function()
ok_text=_("Update"),
UIManager:show(InfoMessage:new{
ok_callback=function()
text=_("Downloading may take several minutes…"),
ifDevice:isSDL()then
timeout=3,
os.execute("xdg-open '"..link.."'")
})
UIManager:scheduleIn(1,function()
ifOTAManager:zsync()==0then
UIManager:show(InfoMessage:new{
text=_("KOReader will be updated on next restart."),
})
-- Make it clear that zsync is done
ifself.can_pretty_printthen
os.execute("./fbink -q -y -7 -pm ' ' ' '")
end
else
-- Make it clear that zsync is done
ifself.can_pretty_printthen
os.execute("./fbink -q -y -7 -pm ' ' ' '")
end
UIManager:show(MultiConfirmBox:new{
text=_("Failed to update KOReader.\n\nYou can:\nCancel, keeping temporary files.\nRetry the update process with a full download.\nAbort and cleanup all temporary files."),
choice1_text=_("Retry"),
choice1_callback=function()
UIManager:show(InfoMessage:new{
text=_("Downloading may take several minutes…"),
timeout=3,
})
-- Clear the installed package, as well as the complete/incomplete update download
os.execute("rm "..self.installed_package)
os.execute("rm "..self.updated_package.."*")
-- And then relaunch zsync in full download mode...
UIManager:scheduleIn(1,function()
ifOTAManager:zsync(true)==0then
UIManager:show(InfoMessage:new{
text=_("KOReader will be updated on next restart."),
})
-- Make it clear that zsync is done
ifself.can_pretty_printthen
os.execute("./fbink -q -y -7 -pm ' ' ' '")
end
else
-- Make it clear that zsync is done
ifself.can_pretty_printthen
os.execute("./fbink -q -y -7 -pm ' ' ' '")
end
UIManager:show(ConfirmBox:new{
text=_("Error updating KOReader. Would you like to delete temporary files?"),
ok_callback=function()
os.execute("rm "..ota_dir.."ko*")
end,
})
end
end)
end,
choice2_text=_("Abort"),
choice2_callback=function()
os.execute("rm "..ota_dir.."ko*")
end,
})
end
end
end)
end
end
})
})
else
UIManager:show(ConfirmBox:new{
text=T(
_("Do you want to update?\nInstalled version: %1\nAvailable version: %2"),
local_version,
ota_version
),
ok_text=_("Update"),
ok_callback=function()
UIManager:show(InfoMessage:new{
text=_("Downloading may take several minutes…"),
timeout=3,
})
UIManager:scheduleIn(1,function()
ifOTAManager:zsync()==0then
UIManager:show(InfoMessage:new{
text=_("KOReader will be updated on next restart."),
})
-- Make it clear that zsync is done
ifself.can_pretty_printthen
os.execute("./fbink -q -y -7 -pm ' ' ' '")
end
else
-- Make it clear that zsync is done
ifself.can_pretty_printthen
os.execute("./fbink -q -y -7 -pm ' ' ' '")
end
UIManager:show(MultiConfirmBox:new{
text=_("Failed to update KOReader.\n\nYou can:\nCancel, keeping temporary files.\nRetry the update process with a full download.\nAbort and cleanup all temporary files."),
choice1_text=_("Retry"),
choice1_callback=function()
UIManager:show(InfoMessage:new{
text=_("Downloading may take several minutes…"),
timeout=3,
})
-- Clear the installed package, as well as the complete/incomplete update download
os.execute("rm "..self.installed_package)
os.execute("rm "..self.updated_package.."*")
-- And then relaunch zsync in full download mode...
UIManager:scheduleIn(1,function()
ifOTAManager:zsync(true)==0then
UIManager:show(InfoMessage:new{
text=_("KOReader will be updated on next restart."),
})
-- Make it clear that zsync is done
ifself.can_pretty_printthen
os.execute("./fbink -q -y -7 -pm ' ' ' '")
end
else
-- Make it clear that zsync is done
ifself.can_pretty_printthen
os.execute("./fbink -q -y -7 -pm ' ' ' '")
end
UIManager:show(ConfirmBox:new{
text=_("Error updating KOReader. Would you like to delete temporary files?"),
ok_callback=function()
os.execute("rm "..ota_dir.."ko*")
end,
})
end
end)
end,
choice2_text=_("Abort"),
choice2_callback=function()
os.execute("rm "..ota_dir.."ko*")
end,
})
end
end)
end
})
end
end
end
end
end
@ -262,44 +310,39 @@ function OTAManager:_buildLocalPackage()
logger.err("Missing ota metadata:",self.package_indexfile)
logger.err("Missing ota metadata:",self.package_indexfile)
returnnil
returnnil
end
end
ifDevice:isAndroid()then
returnos.execute(string.format(
-- With visual feedback if supported...
"./tar --no-recursion -cf %s -T %s",
ifself.can_pretty_printthen
self.installed_package,self.package_indexfile))
os.execute("./fbink -q -y -7 -pmh 'Preparing local OTA package'")
else
-- We need a vague idea of how much space the tarball we're creating will take to compute a proper percentage...
-- With visual feedback if supported...
-- Get the size from the latest zsync package, which'll be a closer match than anything else we might come up with.
ifself.can_pretty_printthen
localupdate_file=self:getZsyncFilename()
os.execute("./fbink -q -y -7 -pmh 'Preparing local OTA package'")
locallocal_update_file=ota_dir..update_file
-- We need a vague idea of how much space the tarball we're creating will take to compute a proper percentage...
localtarball_size=nil
-- Get the size from the latest zsync package, which'll be a closer match than anything else we might come up with.
localzsync=io.open(local_update_file,"r")
localzsync_file=self:getZsyncFilename()
ifzsyncthen
locallocal_zsync_file=ota_dir..zsync_file
forlineinzsync:lines()do
localtarball_size=nil
tarball_size=line:match("^Length: (%d*)$")
localzsync=io.open(local_zsync_file,"r")
iftarball_sizethenbreakend
ifzsyncthen
forlineinzsync:lines()do
tarball_size=line:match("^Length: (%d*)$")
iftarball_sizethenbreakend
end
zsync:close()
end
-- Next, we need to compute the amount of tar blocks that'll take, knowing that tar's default blocksize is 20 * 512 bytes.