mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1886 from chrox/android_ota
add OTA update on Android
This commit is contained in:
@@ -14,11 +14,7 @@ indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 8
|
||||
|
||||
[Makefile.def]
|
||||
[Makefile*]
|
||||
indent_style = tab
|
||||
indent_size = 8
|
||||
|
||||
|
||||
16
Makefile
16
Makefile
@@ -277,6 +277,22 @@ utupdate: all
|
||||
androidupdate: all
|
||||
mkdir -p $(ANDROID_LAUNCHER_DIR)/assets/module
|
||||
-rm $(ANDROID_LAUNCHER_DIR)/assets/module/koreader-*
|
||||
# create zip package
|
||||
cd $(INSTALL_DIR)/koreader && \
|
||||
zip -9 -r \
|
||||
../../koreader-android-$(MACHINE)-$(VERSION).zip \
|
||||
* -x "resources/fonts/*" "resources/icons/src/*" "spec/*"
|
||||
# generate android update package index file
|
||||
zipinfo -1 koreader-android-$(MACHINE)-$(VERSION).zip > \
|
||||
$(INSTALL_DIR)/koreader/ota/package.index
|
||||
rm -f koreader-android-$(MACHINE)-$(VERSION).zip
|
||||
echo "ota/package.index" >> $(INSTALL_DIR)/koreader/ota/package.index
|
||||
cp $(INSTALL_DIR)/koreader/git-rev $(INSTALL_DIR)/koreader/ota-rev
|
||||
# make gzip android update for zsync OTA update
|
||||
cd $(INSTALL_DIR)/koreader && \
|
||||
tar czafh ../../koreader-android-$(MACHINE)-$(VERSION).targz \
|
||||
-T ota/package.index --no-recursion
|
||||
# make android update apk
|
||||
cd $(INSTALL_DIR)/koreader && 7z a -l -mx=1 \
|
||||
../../$(ANDROID_LAUNCHER_DIR)/assets/module/koreader-g$(REVISION).7z * \
|
||||
-x!resources/fonts -x!resources/icons/src -x!spec
|
||||
|
||||
@@ -5,7 +5,8 @@ local _ = require("gettext")
|
||||
|
||||
local common_info = {}
|
||||
|
||||
if Device:isKindle() or Device:isKobo() or Device:isPocketBook() then
|
||||
if Device:isKindle() or Device:isKobo() or Device:isPocketBook()
|
||||
or Device:isAndroid() then
|
||||
local OTAManager = require("ui/otamanager")
|
||||
table.insert(common_info, OTAManager:getOTAMenuTable())
|
||||
end
|
||||
|
||||
@@ -25,9 +25,9 @@ local OTAManager = {
|
||||
"nightly",
|
||||
},
|
||||
zsync_template = "koreader-%s-latest-%s.zsync",
|
||||
installed_package = ota_dir .. "/koreader.installed.tar",
|
||||
installed_package = ota_dir .. "koreader.installed.tar",
|
||||
package_indexfile = "ota/package.index",
|
||||
updated_package = ota_dir .. "/koreader.updated.tar",
|
||||
updated_package = ota_dir .. "koreader.updated.tar",
|
||||
}
|
||||
|
||||
local ota_channels = {
|
||||
@@ -42,6 +42,8 @@ function OTAManager:getOTAModel()
|
||||
return "kobo"
|
||||
elseif Device:isPocketBook() then
|
||||
return "pocketbook"
|
||||
elseif Device:isAndroid() then
|
||||
return "android"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
@@ -152,7 +154,7 @@ function OTAManager:fetchAndProcessUpdate()
|
||||
UIManager:show(ConfirmBox:new{
|
||||
text = _("Error updating KOReader. Would you like to delete temporary files?"),
|
||||
ok_callback = function()
|
||||
os.execute("rm " .. ota_dir .. "/ko*")
|
||||
os.execute("rm " .. ota_dir .. "ko*")
|
||||
end,
|
||||
})
|
||||
end
|
||||
@@ -164,13 +166,19 @@ end
|
||||
|
||||
function OTAManager:_buildLocalPackage()
|
||||
-- TODO: validate the installed package?
|
||||
local installed_package = lfs.currentdir() .. "/" .. self.installed_package
|
||||
local installed_package = self.installed_package
|
||||
if lfs.attributes(installed_package, "mode") == "file" then
|
||||
return 0
|
||||
end
|
||||
return os.execute(string.format(
|
||||
"./tar cvf %s -C .. -T %s --no-recursion",
|
||||
self.installed_package, self.package_indexfile))
|
||||
if Device:isAndroid() then
|
||||
return os.execute(string.format(
|
||||
"./tar cvf %s -T %s --no-recursion",
|
||||
self.installed_package, self.package_indexfile))
|
||||
else
|
||||
return os.execute(string.format(
|
||||
"./tar cvf %s -C .. -T %s --no-recursion",
|
||||
self.installed_package, self.package_indexfile))
|
||||
end
|
||||
end
|
||||
|
||||
function OTAManager:zsync()
|
||||
|
||||
@@ -29,11 +29,27 @@ local file = A.jni:context(A.app.activity.vm, function(JNI)
|
||||
end)
|
||||
A.LOGI("intent file path " .. (file or ""))
|
||||
|
||||
-- update koreader from ota
|
||||
local function update()
|
||||
local new_update = "/sdcard/koreader/ota/koreader.update.tar"
|
||||
local installed = "/sdcard/koreader/ota/koreader.installed.tar"
|
||||
local update_file = io.open(new_update, "r")
|
||||
if update_file ~= nil then
|
||||
io.close(update_file)
|
||||
if os.execute("tar xf " .. new_update) == 0 then
|
||||
os.execute("mv " .. new_update .. " " .. installed)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- run koreader patch before koreader startup
|
||||
pcall(function() dofile("/sdcard/koreader/patch.lua") end)
|
||||
|
||||
-- set proper permission for sdcv
|
||||
A.execute("chmod", "755", "./sdcv")
|
||||
A.execute("chmod", "755", "./tar")
|
||||
A.execute("chmod", "755", "./zsync")
|
||||
|
||||
-- set TESSDATA_PREFIX env var
|
||||
ffi.C.putenv("TESSDATA_PREFIX=/sdcard/koreader/data")
|
||||
|
||||
Submodule platform/android/luajit-launcher updated: 08f23b83e8...f0284840b3
Reference in New Issue
Block a user