From ab712f1a293ee25e83b0e25e398f8377f830f95f Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Sun, 8 Apr 2018 22:39:52 +0200 Subject: [PATCH] [feat] Build AppImage (#3850) References #1417. --- Makefile | 35 ++++++++++++++++++++++++-- base | 2 +- datastorage.lua | 4 ++- frontend/ui/quickstart.lua | 2 +- kodev | 14 ++++++++++- platform/appimage/AppRun | 30 ++++++++++++++++++++++ platform/appimage/koreader.appdata.xml | 27 ++++++++++++++++++++ platform/appimage/koreader.desktop | 7 ++++++ 8 files changed, 115 insertions(+), 6 deletions(-) create mode 100755 platform/appimage/AppRun create mode 100644 platform/appimage/koreader.appdata.xml create mode 100644 platform/appimage/koreader.desktop diff --git a/Makefile b/Makefile index 4289ba8f2..7148f0012 100644 --- a/Makefile +++ b/Makefile @@ -35,17 +35,20 @@ KINDLE_DIR=$(PLATFORM_DIR)/kindle KOBO_DIR=$(PLATFORM_DIR)/kobo POCKETBOOK_DIR=$(PLATFORM_DIR)/pocketbook UBUNTUTOUCH_DIR=$(PLATFORM_DIR)/ubuntu-touch +APPIMAGE_DIR=$(PLATFORM_DIR)/appimage ANDROID_DIR=$(PLATFORM_DIR)/android ANDROID_LAUNCHER_DIR:=$(ANDROID_DIR)/luajit-launcher UBUNTUTOUCH_SDL_DIR:=$(UBUNTUTOUCH_DIR)/ubuntu-touch-sdl WIN32_DIR=$(PLATFORM_DIR)/win32 +# appimage setup +APPIMAGETOOL=appimagetool-x86_64.AppImage +APPIMAGETOOL_URL=https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage + # files to link from main directory INSTALL_FILES=reader.lua setupkoenv.lua frontend resources defaults.lua datastorage.lua \ l10n tools README.md COPYING - - all: $(if $(ANDROID),,$(KOR_BASE)/$(OUTPUT_DIR)/luajit) $(MAKE) -C $(KOR_BASE) install -d $(INSTALL_DIR)/koreader @@ -292,6 +295,32 @@ utupdate: all click build koreader && \ mv *.click ../../koreader-$(DIST)-$(MACHINE)-$(VERSION).click +appimageupdate: all + # remove old package if any + rm -f koreader-appimage-$(MACHINE)-$(VERSION).appimage + + ln -sf ../../$(APPIMAGE_DIR)/AppRun $(INSTALL_DIR)/koreader + ln -sf ../../$(APPIMAGE_DIR)/koreader.appdata.xml $(INSTALL_DIR)/koreader + ln -sf ../../$(APPIMAGE_DIR)/koreader.desktop $(INSTALL_DIR)/koreader + ln -sf ../../$(UBUNTUTOUCH_DIR)/koreader.png $(INSTALL_DIR)/koreader + # TODO at best this is DebUbuntu specific + ln -sf /usr/lib/x86_64-linux-gnu/libSDL2.so $(INSTALL_DIR)/koreader/libs +ifeq ("$(wildcard $(APPIMAGETOOL))","") + # download appimagetool + wget "$(APPIMAGETOOL_URL)" + chmod a+x "$(APPIMAGETOOL)" +endif + cd $(INSTALL_DIR) && pwd && \ + rm -rf tmp && mkdir -p tmp && \ + cp -Lr koreader tmp && \ + rm -rf tmp/koreader/ota && \ + rm -rf tmp/koreader/resources/icons/src && \ + rm -rf tmp/koreader/spec + + # generate AppImage + cd $(INSTALL_DIR)/tmp && \ + ARCH=x86_64 ../../$(APPIMAGETOOL) koreader && \ + mv *.AppImage ../../koreader-$(DIST)-$(MACHINE)-$(VERSION).AppImage androidupdate: all mkdir -p $(ANDROID_LAUNCHER_DIR)/assets/module @@ -336,6 +365,8 @@ else ifeq ($(TARGET), pocketbook) make pbupdate else ifeq ($(TARGET), ubuntu-touch) make utupdate +else ifeq ($(TARGET), appimage) + make appimageupdate else ifeq ($(TARGET), android) make androidupdate endif diff --git a/base b/base index 2ed403b61..3f0084f1d 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 2ed403b617cdb189d47b8eec9700144ec887a748 +Subproject commit 3f0084f1d7457941303a29c576268944c47df071 diff --git a/datastorage.lua b/datastorage.lua index a74ae9607..a826ed718 100644 --- a/datastorage.lua +++ b/datastorage.lua @@ -15,8 +15,10 @@ function DataStorage:getDataDir() elseif os.getenv("UBUNTU_APPLICATION_ISOLATION") then local app_id = os.getenv("APP_ID") local package_name = app_id:match("^(.-)_") - -- confinded ubuntu app has write access to this dir + -- confined ubuntu app has write access to this dir data_dir = string.format("%s/%s", os.getenv("XDG_DATA_HOME"), package_name) + elseif os.getenv("APPIMAGE") then + data_dir = string.format("%s/%s/%s", os.getenv("HOME"), ".config", "koreader") else data_dir = "." end diff --git a/frontend/ui/quickstart.lua b/frontend/ui/quickstart.lua index 57f99dfe1..a77b09f43 100644 --- a/frontend/ui/quickstart.lua +++ b/frontend/ui/quickstart.lua @@ -99,7 +99,7 @@ function QuickStart:getQuickStart() FileConverter:writeStringToFile(quickstart_html, quickstart_filename) end end - -- remember filemaname for file manager + -- remember filename for file manager self.quickstart_filename = quickstart_filename G_reader_settings:saveSetting("quickstart_shown_version", version) return quickstart_filename diff --git a/kodev b/kodev index 56be100f3..47698108f 100755 --- a/kodev +++ b/kodev @@ -117,6 +117,7 @@ SUPPORTED_TARGETS=" android pocketbook ubuntu-touch + appimage emu (*default) If no TARGET is given, assume emulator win32 " @@ -215,6 +216,10 @@ ${SUPPORTED_TARGETS}" make TARGET=ubuntu-touch assert_ret_zero $? ;; + appimage) + make TARGET=appimage + assert_ret_zero $? + ;; win32) make TARGET=win32 assert_ret_zero $? @@ -268,6 +273,9 @@ ${SUPPORTED_TARGETS}" ubuntu-touch) make TARGET=ubuntu-touch clean ;; + appimage) + make TARGET=appimage clean + ;; win32) make TARGET=win32 clean ;; @@ -372,9 +380,13 @@ ${SUPPORTED_RELEASE_TARGETS}" make TARGET=pocketbook update ;; ubuntu-touch) - kodev-build pocketbook + kodev-build ubuntu-touch make TARGET=ubuntu-touch update ;; + appimage) + kodev-build appimage + make TARGET=appimage update + ;; *) echo "Unsupported target for release: $1." echo "${RELEASE_HELP_MSG}" diff --git a/platform/appimage/AppRun b/platform/appimage/AppRun new file mode 100755 index 000000000..a85c45bca --- /dev/null +++ b/platform/appimage/AppRun @@ -0,0 +1,30 @@ +#!/bin/sh +export LC_ALL="en_US.UTF-8" + +# working directory of koreader +KOREADER_DIR="${0%/*}" + +# we're always starting from our working directory +cd "${KOREADER_DIR}" || exit + +# export load library path for some old firmware +export LD_LIBRARY_PATH=${KOREADER_DIR}/libs:$LD_LIBRARY_PATH + +# export external font directory +export EXT_FONT_DIR="${HOME}/.fonts" + +RETURN_VALUE=85 + +if [ $# -eq 0 ]; then + # no arguments + start_path=~/Documents +else + start_path="$*" +fi + +while [ $RETURN_VALUE -eq 85 ]; do + ./reader.lua -d "$start_path" + RETURN_VALUE=$? +done + +exit $RETURN_VALUE diff --git a/platform/appimage/koreader.appdata.xml b/platform/appimage/koreader.appdata.xml new file mode 100644 index 000000000..f6993293d --- /dev/null +++ b/platform/appimage/koreader.appdata.xml @@ -0,0 +1,27 @@ + + + org.koreader.KOReader + org.koreader.KOReader.desktop + CC0-1.0 + AGPL + KOReader + A document viewer for DjVu, PDF, EPUB and more + +

+ KOReader is a document viewer for E Ink devices. It supports PDF, DjVu, XPS, CBT, CBZ, FB2, PDB, TXT, HTML, RTF, CHM, EPUB, DOC, MOBI, and ZIP files. It currently runs on Kindle, Kobo, PocketBook, Ubuntu Touch and Android devices. +

+
+ + + https://cloud.githubusercontent.com/assets/24273478/26781004/9fdb0e8e-49ec-11e7-8de4-92cd08bf80ea.png + + + https://koreader.rocks/ + https://github.com/koreader/koreader/issues + https://github.com/koreader/koreader/wiki + https://github.com/koreader/koreader#translation + + Document viewers + + +
diff --git a/platform/appimage/koreader.desktop b/platform/appimage/koreader.desktop new file mode 100644 index 000000000..1c6e84db5 --- /dev/null +++ b/platform/appimage/koreader.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=KOReader +Comment=KOReader is a document viewer +Exec=reader.lua %u +Icon=koreader +Terminal=false +Type=Application