mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
[build] Add support for Debian packages (#4434)
* Add support for Debian packages * SDL: add device probe
This commit is contained in:
committed by
Frans de Jonge
parent
7055ffe7d6
commit
6de5927dc2
5
.gitignore
vendored
5
.gitignore
vendored
@@ -26,6 +26,7 @@ trace-out.txt
|
|||||||
|
|
||||||
koreader-*.zip
|
koreader-*.zip
|
||||||
koreader-*.apk
|
koreader-*.apk
|
||||||
|
koreader-*.deb
|
||||||
koreader-*.tar.gz
|
koreader-*.tar.gz
|
||||||
koreader-*.targz
|
koreader-*.targz
|
||||||
koreader-*.click
|
koreader-*.click
|
||||||
@@ -42,6 +43,10 @@ koreader-android-arm-linux-androideabi*
|
|||||||
koreader-android-i686-linux-android*
|
koreader-android-i686-linux-android*
|
||||||
koreader-cervantes-arm-linux-gnueabi*
|
koreader-cervantes-arm-linux-gnueabi*
|
||||||
koreader-cervantes-arm-cervantes-linux-gnueabi*
|
koreader-cervantes-arm-cervantes-linux-gnueabi*
|
||||||
|
koreader-debian-i686-linux-gnu*
|
||||||
|
koreader-debian-x86_64-linux-gnu*
|
||||||
|
koreader-debian-armel-arm-linux-gnueabi*
|
||||||
|
koreader-debian-armhf-arm-linux-gnueabihf*
|
||||||
koreader-kindle-legacy-arm-kindle-linux-gnueabi*
|
koreader-kindle-legacy-arm-kindle-linux-gnueabi*
|
||||||
koreader-kindle-arm-linux-gnueabi*
|
koreader-kindle-arm-linux-gnueabi*
|
||||||
koreader-kobo-arm-linux-gnueabihf*
|
koreader-kobo-arm-linux-gnueabihf*
|
||||||
|
|||||||
28
Makefile
28
Makefile
@@ -39,6 +39,7 @@ ANDROID_DIR=$(PLATFORM_DIR)/android
|
|||||||
ANDROID_LAUNCHER_DIR:=$(ANDROID_DIR)/luajit-launcher
|
ANDROID_LAUNCHER_DIR:=$(ANDROID_DIR)/luajit-launcher
|
||||||
APPIMAGE_DIR=$(PLATFORM_DIR)/appimage
|
APPIMAGE_DIR=$(PLATFORM_DIR)/appimage
|
||||||
CERVANTES_DIR=$(PLATFORM_DIR)/cervantes
|
CERVANTES_DIR=$(PLATFORM_DIR)/cervantes
|
||||||
|
DEBIAN_DIR=$(PLATFORM_DIR)/debian
|
||||||
KINDLE_DIR=$(PLATFORM_DIR)/kindle
|
KINDLE_DIR=$(PLATFORM_DIR)/kindle
|
||||||
KOBO_DIR=$(PLATFORM_DIR)/kobo
|
KOBO_DIR=$(PLATFORM_DIR)/kobo
|
||||||
POCKETBOOK_DIR=$(PLATFORM_DIR)/pocketbook
|
POCKETBOOK_DIR=$(PLATFORM_DIR)/pocketbook
|
||||||
@@ -365,6 +366,24 @@ androidupdate: all
|
|||||||
cp $(ANDROID_LAUNCHER_DIR)/bin/NativeActivity-debug.apk \
|
cp $(ANDROID_LAUNCHER_DIR)/bin/NativeActivity-debug.apk \
|
||||||
koreader-android-$(MACHINE)-$(VERSION).apk
|
koreader-android-$(MACHINE)-$(VERSION).apk
|
||||||
|
|
||||||
|
debianupdate: all
|
||||||
|
mkdir -p $(INSTALL_DIR)/debian/usr/share/pixmaps
|
||||||
|
cp -pr resources/koreader.png $(INSTALL_DIR)/debian/usr/share/pixmaps
|
||||||
|
|
||||||
|
mkdir -p $(INSTALL_DIR)/debian/usr/share/applications
|
||||||
|
cp -pr $(DEBIAN_DIR)/koreader.desktop $(INSTALL_DIR)/debian/usr/share/applications
|
||||||
|
|
||||||
|
mkdir -p $(INSTALL_DIR)/debian/usr/bin
|
||||||
|
cp -pr $(DEBIAN_DIR)/koreader.sh $(INSTALL_DIR)/debian/usr/bin/koreader
|
||||||
|
|
||||||
|
mkdir -p $(INSTALL_DIR)/debian/usr/lib
|
||||||
|
cp -Lr $(INSTALL_DIR)/koreader $(INSTALL_DIR)/debian/usr/lib
|
||||||
|
|
||||||
|
cd $(INSTALL_DIR)/debian/usr/lib/koreader && pwd && \
|
||||||
|
rm -rf ota cache clipboard screenshots spec && \
|
||||||
|
rm -rf resources/fonts resources/icons/src && \
|
||||||
|
rm -rf ev_replay.py
|
||||||
|
|
||||||
sony-prstuxupdate: all
|
sony-prstuxupdate: all
|
||||||
# ensure that the binaries were built for ARM
|
# ensure that the binaries were built for ARM
|
||||||
file $(INSTALL_DIR)/koreader/luajit | grep ARM || exit 1
|
file $(INSTALL_DIR)/koreader/luajit | grep ARM || exit 1
|
||||||
@@ -439,6 +458,15 @@ else ifeq ($(TARGET), sony-prstux)
|
|||||||
make sony-prstuxupdate
|
make sony-prstuxupdate
|
||||||
else ifeq ($(TARGET), ubuntu-touch)
|
else ifeq ($(TARGET), ubuntu-touch)
|
||||||
make utupdate
|
make utupdate
|
||||||
|
else ifeq ($(TARGET), debian)
|
||||||
|
make debianupdate
|
||||||
|
$(CURDIR)/platform/debian/do_debian_package.sh $(INSTALL_DIR)
|
||||||
|
else ifeq ($(TARGET), debian-armel)
|
||||||
|
make debianupdate
|
||||||
|
$(CURDIR)/platform/debian/do_debian_package.sh $(INSTALL_DIR) armel
|
||||||
|
else ifeq ($(TARGET), debian-armhf)
|
||||||
|
make debianupdate
|
||||||
|
$(CURDIR)/platform/debian/do_debian_package.sh $(INSTALL_DIR) armhf
|
||||||
endif
|
endif
|
||||||
|
|
||||||
androiddev: androidupdate
|
androiddev: androidupdate
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function DataStorage:getDataDir()
|
|||||||
local package_name = app_id:match("^(.-)_")
|
local package_name = app_id:match("^(.-)_")
|
||||||
-- confined 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)
|
data_dir = string.format("%s/%s", os.getenv("XDG_DATA_HOME"), package_name)
|
||||||
elseif os.getenv("APPIMAGE") then
|
elseif os.getenv("APPIMAGE") or os.getenv("KO_MULTIUSER") then
|
||||||
data_dir = string.format("%s/%s/%s", os.getenv("HOME"), ".config", "koreader")
|
data_dir = string.format("%s/%s/%s", os.getenv("HOME"), ".config", "koreader")
|
||||||
else
|
else
|
||||||
data_dir = "."
|
data_dir = "."
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ local Device = {
|
|||||||
isPocketBook = no,
|
isPocketBook = no,
|
||||||
isSonyPRSTUX = no,
|
isSonyPRSTUX = no,
|
||||||
isSDL = no,
|
isSDL = no,
|
||||||
|
isEmulator = no,
|
||||||
|
|
||||||
-- some devices have part of their screen covered by the bezel
|
-- some devices have part of their screen covered by the bezel
|
||||||
viewport = nil,
|
viewport = nil,
|
||||||
|
|||||||
@@ -12,25 +12,46 @@ local Device = Generic:new{
|
|||||||
hasKeyboard = yes,
|
hasKeyboard = yes,
|
||||||
hasKeys = yes,
|
hasKeys = yes,
|
||||||
hasDPad = yes,
|
hasDPad = yes,
|
||||||
hasFrontlight = yes,
|
|
||||||
isTouchDevice = yes,
|
isTouchDevice = yes,
|
||||||
needsScreenRefreshAfterResume = no,
|
needsScreenRefreshAfterResume = no,
|
||||||
hasColorScreen = yes,
|
hasColorScreen = yes,
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.getenv("DISABLE_TOUCH") == "1" then
|
local AppImage = Device:new{
|
||||||
Device.isTouchDevice = no
|
model = "AppImage",
|
||||||
end
|
}
|
||||||
|
|
||||||
|
local Emulator = Device:new{
|
||||||
|
model = "Emulator",
|
||||||
|
isEmulator = yes,
|
||||||
|
hasFrontlight = yes,
|
||||||
|
}
|
||||||
|
|
||||||
|
local Linux = Device:new{
|
||||||
|
model = "Linux",
|
||||||
|
}
|
||||||
|
|
||||||
|
local UbuntuTouch = Device:new{
|
||||||
|
model = "UbuntuTouch",
|
||||||
|
hasFrontlight = yes,
|
||||||
|
}
|
||||||
|
|
||||||
function Device:init()
|
function Device:init()
|
||||||
|
local emulator = self.isEmulator
|
||||||
-- allows to set a viewport via environment variable
|
-- allows to set a viewport via environment variable
|
||||||
-- syntax is Lua table syntax, e.g. EMULATE_READER_VIEWPORT="{x=10,w=550,y=5,h=790}"
|
-- syntax is Lua table syntax, e.g. EMULATE_READER_VIEWPORT="{x=10,w=550,y=5,h=790}"
|
||||||
local viewport = os.getenv("EMULATE_READER_VIEWPORT")
|
local viewport = os.getenv("EMULATE_READER_VIEWPORT")
|
||||||
if viewport then
|
if emulator and viewport then
|
||||||
self.viewport = require("ui/geometry"):new(loadstring("return " .. viewport)())
|
self.viewport = require("ui/geometry"):new(loadstring("return " .. viewport)())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local touchless = os.getenv("DISABLE_TOUCH") == "1"
|
||||||
|
if emulator and touchless then
|
||||||
|
self.isTouchDevice = no
|
||||||
|
end
|
||||||
|
|
||||||
local portrait = os.getenv("EMULATE_READER_FORCE_PORTRAIT")
|
local portrait = os.getenv("EMULATE_READER_FORCE_PORTRAIT")
|
||||||
if portrait then
|
if emulator and portrait then
|
||||||
self.isAlwaysPortrait = yes
|
self.isAlwaysPortrait = yes
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -151,7 +172,7 @@ function Device:init()
|
|||||||
|
|
||||||
self.keyboard_layout = require("device/sdl/keyboard_layout")
|
self.keyboard_layout = require("device/sdl/keyboard_layout")
|
||||||
|
|
||||||
if portrait then
|
if emulator and portrait then
|
||||||
self.input:registerEventAdjustHook(self.input.adjustTouchSwitchXY)
|
self.input:registerEventAdjustHook(self.input.adjustTouchSwitchXY)
|
||||||
self.input:registerEventAdjustHook(
|
self.input:registerEventAdjustHook(
|
||||||
self.input.adjustTouchMirrorX,
|
self.input.adjustTouchMirrorX,
|
||||||
@@ -196,4 +217,13 @@ function Device:simulateResume()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
return Device
|
-------------- device probe ------------
|
||||||
|
if os.getenv("APPIMAGE") then
|
||||||
|
return AppImage
|
||||||
|
elseif os.getenv("KO_MULTIUSER") then
|
||||||
|
return Linux
|
||||||
|
elseif os.getenv("UBUNTU_APPLICATION_ISOLATION") then
|
||||||
|
return UbuntuTouch
|
||||||
|
else
|
||||||
|
return Emulator
|
||||||
|
end
|
||||||
|
|||||||
36
kodev
36
kodev
@@ -122,6 +122,9 @@ SUPPORTED_TARGETS="
|
|||||||
pocketbook
|
pocketbook
|
||||||
ubuntu-touch
|
ubuntu-touch
|
||||||
appimage
|
appimage
|
||||||
|
debian Debian package for current arch
|
||||||
|
debian-armel Debian package for generic armel devices
|
||||||
|
debian-armhf Debian package for generic armhf devices
|
||||||
emu (*default) If no TARGET is given, assume emulator
|
emu (*default) If no TARGET is given, assume emulator
|
||||||
win32
|
win32
|
||||||
"
|
"
|
||||||
@@ -228,6 +231,18 @@ ${SUPPORTED_TARGETS}"
|
|||||||
make TARGET=appimage
|
make TARGET=appimage
|
||||||
assert_ret_zero $?
|
assert_ret_zero $?
|
||||||
;;
|
;;
|
||||||
|
debian)
|
||||||
|
make TARGET=debian
|
||||||
|
assert_ret_zero $?
|
||||||
|
;;
|
||||||
|
debian-armel)
|
||||||
|
make TARGET=debian-armel
|
||||||
|
assert_ret_zero $?
|
||||||
|
;;
|
||||||
|
debian-armhf)
|
||||||
|
make TARGET=debian-armhf
|
||||||
|
assert_ret_zero $?
|
||||||
|
;;
|
||||||
win32)
|
win32)
|
||||||
make TARGET=win32
|
make TARGET=win32
|
||||||
assert_ret_zero $?
|
assert_ret_zero $?
|
||||||
@@ -308,6 +323,15 @@ ${SUPPORTED_TARGETS}"
|
|||||||
appimage)
|
appimage)
|
||||||
make TARGET=appimage clean
|
make TARGET=appimage clean
|
||||||
;;
|
;;
|
||||||
|
debian)
|
||||||
|
make TARGET=debian clean
|
||||||
|
;;
|
||||||
|
debian-armel)
|
||||||
|
make TARGET=debian-armel clean
|
||||||
|
;;
|
||||||
|
debian-armhf)
|
||||||
|
make TARGET=debian-armhf clean
|
||||||
|
;;
|
||||||
win32)
|
win32)
|
||||||
make TARGET=win32 clean
|
make TARGET=win32 clean
|
||||||
;;
|
;;
|
||||||
@@ -428,6 +452,18 @@ ${SUPPORTED_RELEASE_TARGETS}"
|
|||||||
kodev-build appimage
|
kodev-build appimage
|
||||||
make TARGET=appimage update
|
make TARGET=appimage update
|
||||||
;;
|
;;
|
||||||
|
debian)
|
||||||
|
kodev-build debian
|
||||||
|
make TARGET=debian update
|
||||||
|
;;
|
||||||
|
debian-armel)
|
||||||
|
kodev-build debian-armel
|
||||||
|
make TARGET=debian-armel update
|
||||||
|
;;
|
||||||
|
debian-armhf)
|
||||||
|
kodev-build debian-armhf
|
||||||
|
make TARGET=debian-armhf update
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported target for release: $1."
|
echo "Unsupported target for release: $1."
|
||||||
echo "${RELEASE_HELP_MSG}"
|
echo "${RELEASE_HELP_MSG}"
|
||||||
|
|||||||
63
platform/debian/do_debian_package.sh
Executable file
63
platform/debian/do_debian_package.sh
Executable file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Script to generate debian packages for KOReader
|
||||||
|
|
||||||
|
if [ -z "${1}" ]; then
|
||||||
|
echo "${0}: can't find KOReader build, please specify a path"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
INSTALL_DIR="${1}"
|
||||||
|
VERSION="$(cut -f2 -dv "${1}/koreader/git-rev" | cut -f1,2 -d-)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
uname_to_debian() {
|
||||||
|
if [ "$(uname -m)" == "x86_64" ]; then
|
||||||
|
echo "amd64"
|
||||||
|
elif [ "$(uname -m)" == "i686" ]; then
|
||||||
|
echo "i686"
|
||||||
|
elif [ "$(uname -m)" == "arm64" ]; then
|
||||||
|
echo "aarch64"
|
||||||
|
else
|
||||||
|
echo "any"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${2}" ]; then
|
||||||
|
ARCH="$(uname_to_debian)"
|
||||||
|
else
|
||||||
|
ARCH="${2}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
command_exists() {
|
||||||
|
type "$1" >/dev/null 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run only if dpkg-deb exists
|
||||||
|
COMMAND="dpkg-deb"
|
||||||
|
if command_exists "$COMMAND"; then
|
||||||
|
mkdir -p "${INSTALL_DIR}/debian/DEBIAN"
|
||||||
|
{
|
||||||
|
echo "Section: graphics"
|
||||||
|
echo "Priority: optional"
|
||||||
|
echo "Depends: libsdl2-2.0-0"
|
||||||
|
echo "Architecture: ${ARCH}"
|
||||||
|
echo "Version: ${VERSION}"
|
||||||
|
echo "Installed-Size: $(du -ks "${INSTALL_DIR}/debian/usr/" | cut -f 1)"
|
||||||
|
|
||||||
|
echo "Package: KOReader"
|
||||||
|
echo "Maintainer: KOReader team"
|
||||||
|
echo "Homepage: https://koreader.rocks"
|
||||||
|
echo "Description: An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats"
|
||||||
|
echo " KOReader is a document viewer application, originally created for Kindle e-ink readers."
|
||||||
|
echo " It currently runs on Kindle, Kobo, PocketBook, Ubuntu Touch, Android and Linux devices"
|
||||||
|
|
||||||
|
} >"${INSTALL_DIR}/debian/DEBIAN/control"
|
||||||
|
|
||||||
|
(cd "${INSTALL_DIR}/.." \
|
||||||
|
&& fakeroot dpkg-deb -b "${INSTALL_DIR}/debian" "koreader-${VERSION}-${ARCH}.deb")
|
||||||
|
else
|
||||||
|
echo "${COMMAND} not found, unable to build Debian package"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
9
platform/debian/koreader.desktop
Normal file
9
platform/debian/koreader.desktop
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=KOReader
|
||||||
|
Comment=KOReader is a document viewer
|
||||||
|
Exec=koreader %u
|
||||||
|
Icon=koreader
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
Categories=Graphics;
|
||||||
|
MimeType=application/pdf;application/x-cbz;application/epub+zip;image/vnd.djvu;text/plain;
|
||||||
42
platform/debian/koreader.sh
Executable file
42
platform/debian/koreader.sh
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
export LC_ALL="en_US.UTF-8"
|
||||||
|
|
||||||
|
# writable storage: ${HOME}/.config/koreader.
|
||||||
|
export KO_MULTIUSER=1
|
||||||
|
|
||||||
|
if [ -z "${1}" ]; then
|
||||||
|
ARGS="${HOME}"
|
||||||
|
else
|
||||||
|
if [ $# -eq 1 ] && [ -e "$(pwd)/${1}" ]; then
|
||||||
|
ARGS="$(pwd)/${1}"
|
||||||
|
else
|
||||||
|
ARGS="${*}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# working directory of koreader
|
||||||
|
KOREADER_DIR="/usr/lib/koreader"
|
||||||
|
|
||||||
|
# we're always starting from our working directory
|
||||||
|
cd "${KOREADER_DIR}" || exit
|
||||||
|
|
||||||
|
# export load library path
|
||||||
|
export LD_LIBRARY_PATH=${KOREADER_DIR}/libs:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
# export external font directory
|
||||||
|
export EXT_FONT_DIR="${HOME}/.config/koreader/fonts"
|
||||||
|
[ ! -d "${EXT_FONT_DIR}" ] && mkdir -pv "${EXT_FONT_DIR}"
|
||||||
|
|
||||||
|
RETURN_VALUE=85
|
||||||
|
while [ $RETURN_VALUE -eq 85 ]; do
|
||||||
|
./reader.lua "${ARGS}"
|
||||||
|
RETURN_VALUE=$?
|
||||||
|
# do not restart with saved arguments
|
||||||
|
ARGS="${HOME}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# remove the flag to avoid emulator confusion
|
||||||
|
export -n KO_MULTIUSER
|
||||||
|
|
||||||
|
exit $RETURN_VALUE
|
||||||
|
|
||||||
Reference in New Issue
Block a user