mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Add generic Linux package (#9351)
Relates to https://github.com/koreader/koreader/issues/9268 Requires https://github.com/koreader/koreader-base/pull/1504 Usage: - `kodev release linux` for native package (same arch as host) - `LINUX_ARCH=arm release linux` for armhf on a x86_64 host. - `LINUX_ARCH=arm64 release linux` for arm64 on a x86_64 host. It produces a `koreader-linux-$ARCH-$VERSION.tar.xz` archive, where $ARCH follows `uname -m` convention {x86_64, armv7l, aarch64} To generate the debian package from the generic archive the following command is required `./platform/linux/do_debian_package.sh path_to.tar.xz`
This commit is contained in:
13
Makefile
13
Makefile
@@ -12,7 +12,7 @@ endif
|
||||
|
||||
# releases do not contain tests and misc data
|
||||
IS_RELEASE := $(if $(or $(EMULATE_READER),$(WIN32)),,1)
|
||||
IS_RELEASE := $(if $(or $(IS_RELEASE),$(APPIMAGE),$(DEBIAN),$(MACOS)),1,)
|
||||
IS_RELEASE := $(if $(or $(IS_RELEASE),$(APPIMAGE),$(LINUX),$(MACOS)),1,)
|
||||
|
||||
ifeq ($(ANDROID_ARCH), arm64)
|
||||
ANDROID_ABI?=arm64-v8a
|
||||
@@ -29,6 +29,17 @@ endif
|
||||
ANDROID_VERSION?=$(shell git rev-list --count HEAD)
|
||||
ANDROID_NAME?=$(VERSION)
|
||||
|
||||
LINUX_ARCH?=native
|
||||
ifeq ($(LINUX_ARCH), native)
|
||||
LINUX_ARCH_NAME:=$(shell uname -m)
|
||||
else ifeq ($(LINUX_ARCH), arm64)
|
||||
LINUX_ARCH_NAME:=aarch64
|
||||
else ifeq ($(LINUX_ARCH), arm)
|
||||
LINUX_ARCH_NAME:=armv7l
|
||||
endif
|
||||
LINUX_ARCH_NAME?=$(LINUX_ARCH)
|
||||
|
||||
|
||||
MACHINE=$(TARGET_MACHINE)
|
||||
ifdef KODEBUG
|
||||
MACHINE:=$(MACHINE)-debug
|
||||
|
||||
2
base
2
base
Submodule base updated: f11b599645...e138fe2d0f
52
kodev
52
kodev
@@ -154,10 +154,7 @@ SUPPORTED_TARGETS="
|
||||
pocketbook
|
||||
ubuntu-touch
|
||||
appimage
|
||||
debian Debian package for current arch
|
||||
debian-armel Debian package for generic armel devices
|
||||
debian-armhf Debian package for generic armhf devices
|
||||
debian-arm64 Debian package for generic 64 bits arm devices
|
||||
linux
|
||||
macos MacOS app bundle. You need a mac to build this package
|
||||
emu (*default) If no TARGET is given, assume emulator
|
||||
win32
|
||||
@@ -268,20 +265,8 @@ ${SUPPORTED_TARGETS}"
|
||||
make TARGET=appimage
|
||||
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 $?
|
||||
;;
|
||||
debian-arm64)
|
||||
make TARGET=debian-arm64
|
||||
linux)
|
||||
make TARGET=linux
|
||||
assert_ret_zero $?
|
||||
;;
|
||||
macos)
|
||||
@@ -389,17 +374,8 @@ ${SUPPORTED_TARGETS}"
|
||||
appimage)
|
||||
make TARGET=appimage clean
|
||||
;;
|
||||
debian)
|
||||
make TARGET=debian clean
|
||||
;;
|
||||
debian-armel)
|
||||
make TARGET=debian-armel clean
|
||||
;;
|
||||
debian-armhf)
|
||||
make TARGET=debian-armhf clean
|
||||
;;
|
||||
debian-arm64)
|
||||
make TARGET=debian-arm64 clean
|
||||
linux)
|
||||
make TARGET=linux clean
|
||||
;;
|
||||
macos)
|
||||
is_mac
|
||||
@@ -540,21 +516,9 @@ ${SUPPORTED_RELEASE_TARGETS}"
|
||||
kodev-build appimage
|
||||
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
|
||||
;;
|
||||
debian-arm64)
|
||||
kodev-build debian-arm64
|
||||
make TARGET=debian-arm64 update
|
||||
linux)
|
||||
kodev-build linux
|
||||
make TARGET=linux update
|
||||
;;
|
||||
macos)
|
||||
is_mac
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
DEBIAN_DIR = $(PLATFORM_DIR)/debian
|
||||
|
||||
update: all
|
||||
mkdir -pv \
|
||||
$(INSTALL_DIR)/debian/usr/bin \
|
||||
$(INSTALL_DIR)/debian/usr/lib \
|
||||
$(INSTALL_DIR)/debian/usr/share/pixmaps \
|
||||
$(INSTALL_DIR)/debian/usr/share/applications \
|
||||
$(INSTALL_DIR)/debian/usr/share/doc/koreader \
|
||||
$(INSTALL_DIR)/debian/usr/share/man/man1
|
||||
cp -pv resources/koreader.png $(INSTALL_DIR)/debian/usr/share/pixmaps
|
||||
cp -pv $(DEBIAN_DIR)/koreader.desktop $(INSTALL_DIR)/debian/usr/share/applications
|
||||
cp -pv $(DEBIAN_DIR)/copyright COPYING $(INSTALL_DIR)/debian/usr/share/doc/koreader
|
||||
cp -pv $(DEBIAN_DIR)/koreader.sh $(INSTALL_DIR)/debian/usr/bin/koreader
|
||||
cp -Lr $(INSTALL_DIR)/koreader $(INSTALL_DIR)/debian/usr/lib
|
||||
gzip -cn9 $(DEBIAN_DIR)/changelog > $(INSTALL_DIR)/debian/usr/share/doc/koreader/changelog.Debian.gz
|
||||
gzip -cn9 $(DEBIAN_DIR)/koreader.1 > $(INSTALL_DIR)/debian/usr/share/man/man1/koreader.1.gz
|
||||
chmod 644 \
|
||||
$(INSTALL_DIR)/debian/usr/share/doc/koreader/changelog.Debian.gz \
|
||||
$(INSTALL_DIR)/debian/usr/share/doc/koreader/copyright \
|
||||
$(INSTALL_DIR)/debian/usr/share/man/man1/koreader.1.gz
|
||||
rm -rf \
|
||||
$(INSTALL_DIR)/debian/usr/lib/koreader/{ota,cache,clipboard,screenshots,spec,tools,resources/fonts,resources/icons/src}
|
||||
|
||||
.PHONY: update
|
||||
34
make/linux.mk
Normal file
34
make/linux.mk
Normal file
@@ -0,0 +1,34 @@
|
||||
LINUX_DIR = $(PLATFORM_DIR)/linux
|
||||
LINUX_PACKAGE:=koreader-linux-$(LINUX_ARCH_NAME)$(KODEDUG_SUFFIX)-$(VERSION).tar.xz
|
||||
|
||||
update: all
|
||||
mkdir -pv \
|
||||
$(INSTALL_DIR)/linux/bin \
|
||||
$(INSTALL_DIR)/linux/lib \
|
||||
$(INSTALL_DIR)/linux/share/pixmaps \
|
||||
$(INSTALL_DIR)/linux/share/applications \
|
||||
$(INSTALL_DIR)/linux/share/doc/koreader \
|
||||
$(INSTALL_DIR)/linux/share/man/man1
|
||||
cp -pv resources/koreader.png $(INSTALL_DIR)/linux/share/pixmaps
|
||||
cp -pv $(LINUX_DIR)/koreader.desktop $(INSTALL_DIR)/linux/share/applications
|
||||
cp -pv $(LINUX_DIR)/copyright COPYING $(INSTALL_DIR)/linux/share/doc/koreader
|
||||
cp -pv $(LINUX_DIR)/koreader.sh $(INSTALL_DIR)/linux/bin/koreader
|
||||
cp -Lr $(INSTALL_DIR)/koreader $(INSTALL_DIR)/linux/lib
|
||||
gzip -cn9 $(LINUX_DIR)/koreader.1 > $(INSTALL_DIR)/linux/share/man/man1/koreader.1.gz
|
||||
chmod 644 \
|
||||
$(INSTALL_DIR)/linux/share/doc/koreader/copyright \
|
||||
$(INSTALL_DIR)/linux/share/man/man1/koreader.1.gz
|
||||
rm -rf \
|
||||
$(INSTALL_DIR)/linux/lib/koreader/{ota,cache,clipboard,screenshots,spec,tools,resources/fonts,resources/icons/src}
|
||||
|
||||
# remove leftovers
|
||||
find $(INSTALL_DIR)/linux -type f \( -name ".git" -o -name ".gitignore" -o -name "discovery2spore" -o -name "wadl2spore" -o -name "*.txt" -o -name "LICENSE*" -o -name "NOTICE" -o -name "README.md" \) -print0 | xargs -0 rm -rf
|
||||
find $(INSTALL_DIR)/linux -type d \( -name "test" -o -name ".github" \) -print0 | xargs -0 rm -rf
|
||||
|
||||
# fix permissions
|
||||
chmod -R u=rwX,og=rX $(INSTALL_DIR)/linux
|
||||
XZ_OPT=9 tar -C $(INSTALL_DIR)/linux -cvJf $(LINUX_PACKAGE) .
|
||||
|
||||
rm -rf $(INSTALL_DIR)/linux
|
||||
|
||||
.PHONY: update
|
||||
@@ -1,11 +0,0 @@
|
||||
koreader (0.1) unstable; urgency=low
|
||||
|
||||
* Fixes most lintian errors and warnings
|
||||
|
||||
-- Martín Fdez <paziusss@gmail.com> Thu, 14 May 2020 00:00:00 +0100
|
||||
|
||||
koreader (0.0.1) experimental; urgency=low
|
||||
|
||||
* Initial release as Debian package (Closes: https://github.com/koreader/koreader/issues/3108)
|
||||
|
||||
-- Martín Fdez <paziusss@gmail.com> Tue, 03 Jan 2019 00:00:00 +0100
|
||||
@@ -1,119 +0,0 @@
|
||||
#!/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
|
||||
}
|
||||
|
||||
link_fonts() {
|
||||
syspath="../../../../share/fonts/truetype/$(basename "${1}")"
|
||||
for FILE in *.ttf; do
|
||||
rm -rf "${FILE}"
|
||||
ln -s "${syspath}/${FILE}" "${FILE}"
|
||||
done
|
||||
}
|
||||
|
||||
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
|
||||
BASE_DIR="${INSTALL_DIR}/debian/usr"
|
||||
|
||||
# populate debian control file
|
||||
mkdir -p "${INSTALL_DIR}/debian/DEBIAN"
|
||||
{
|
||||
echo "Section: graphics"
|
||||
echo "Priority: optional"
|
||||
echo "Depends: libsdl2-2.0-0, fonts-noto-hinted, fonts-droid-fallback, libc6 (>= 2.2.3)"
|
||||
echo "Architecture: ${ARCH}"
|
||||
echo "Version: ${VERSION}"
|
||||
echo "Installed-Size: $(du -ks "${INSTALL_DIR}/debian/usr/" | cut -f 1)"
|
||||
echo "Package: koreader"
|
||||
echo "Maintainer: Martín Fdez <paziusss@gmail.com>"
|
||||
echo "Homepage: https://koreader.rocks"
|
||||
echo "Description: Ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats"
|
||||
echo " KOReader is a document viewer for E Ink devices."
|
||||
echo " Supported fileformats include EPUB, PDF, DjVu, XPS, CBT,"
|
||||
echo " CBZ, FB2, PDB, TXT, HTML, RTF, CHM, DOC, MOBI and ZIP files."
|
||||
echo " It’s available for Kindle, Kobo, PocketBook, Android and desktop Linux."
|
||||
|
||||
} >"${INSTALL_DIR}/debian/DEBIAN/control"
|
||||
|
||||
# remove leftovers
|
||||
find "${BASE_DIR}" -type f -name ".git" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}" -type f -name ".gitignore" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}" -type f -name "discovery2spore" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}" -type f -name "wadl2spore" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}" -type d -name "test" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}" -type f -name "*.txt" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}" -type f -name "LICENSE" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}" -type f -name "NOTICE" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}" -type f -name "README.md" -print0 | xargs -0 rm -rf
|
||||
find "${BASE_DIR}/lib" -type f -name "COPYING" -print0 | xargs -0 rm -rf
|
||||
|
||||
# fix permissions
|
||||
find "${BASE_DIR}" -type d -print0 | xargs -0 chmod 755
|
||||
find "${BASE_DIR}" -executable -type f -print0 | xargs -0 chmod 755
|
||||
find "${BASE_DIR}" -type f -name "*.cff" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*.html" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*.lua" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*manifest" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*.pattern" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*.png" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*.otf" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*.po*" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*.so*" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "*.ttf" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "git-rev" -print0 | xargs -0 chmod 644
|
||||
find "${BASE_DIR}" -type f -name "reader.lua" -print0 | xargs -0 chmod 755
|
||||
|
||||
# use absolute path to luajit in reader.lua
|
||||
sed -i 's/.\/luajit/\/usr\/lib\/koreader\/luajit/' "${BASE_DIR}/lib/koreader/reader.lua"
|
||||
|
||||
# use debian packaged fonts instead of our embedded ones to save a couple of MB.
|
||||
# Note: avoid linking against fonts-noto-cjk-extra, cause it weights ~200MB.
|
||||
(cd "${BASE_DIR}/lib/koreader/fonts/noto" && link_fonts "$(pwd)")
|
||||
|
||||
# DroidSansMono has a restrictive license. Replace it with DroidSansFallback
|
||||
(
|
||||
cd "${BASE_DIR}/lib/koreader/fonts/droid" && rm -rf DroidSansMono.ttf &&
|
||||
ln -s ../../../../share/fonts-droid-fallback/truetype/DroidSansFallback.ttf DroidSansMono.ttf
|
||||
)
|
||||
|
||||
# try to remove rpath
|
||||
if command_exists chrpath; then
|
||||
find "${BASE_DIR}/lib/koreader/libs" -type f -name "*.so*" -print0 | xargs -0 chrpath -d
|
||||
else
|
||||
echo "chrpath tool not found. Skipping RPATH deletion"
|
||||
fi
|
||||
|
||||
(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
|
||||
109
platform/linux/do_debian_package.sh
Executable file
109
platform/linux/do_debian_package.sh
Executable file
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
# Script to generate debian packages for KOReader
|
||||
|
||||
command_exists() {
|
||||
type "$1" >/dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
link_fonts() {
|
||||
syspath="../../../../share/fonts/truetype/$(basename "$1")"
|
||||
for FILE in "$1"/*.ttf; do
|
||||
ln -snf "${syspath}/${FILE##*/}" "${FILE}"
|
||||
done
|
||||
}
|
||||
|
||||
uname_to_debian() {
|
||||
case "$1" in
|
||||
x86_64) echo "amd64" ;;
|
||||
armv7l) echo "armhf" ;;
|
||||
aarch64) echo "arm64" ;;
|
||||
*) echo "$1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
write_changelog() {
|
||||
CHANGELOG_PATH="${1}/share/doc/koreader/changelog.Debian.gz"
|
||||
CHANGELOG=$(
|
||||
cat <<'END_HEREDOC'
|
||||
koreader (0.1) unstable; urgency=low
|
||||
|
||||
* Fixes most lintian errors and warnings
|
||||
|
||||
-- Martín Fdez <paziusss@gmail.com> Thu, 14 May 2020 00:00:00 +0100
|
||||
|
||||
koreader (0.0.1) experimental; urgency=low
|
||||
|
||||
* Initial release as Debian package (Closes: https://github.com/koreader/koreader/issues/3108)
|
||||
|
||||
-- Martín Fdez <paziusss@gmail.com> Tue, 03 Jan 2019 00:00:00 +0100
|
||||
END_HEREDOC
|
||||
)
|
||||
|
||||
echo "${CHANGELOG}" | gzip -cn9 >"${CHANGELOG_PATH}"
|
||||
chmod 644 "${CHANGELOG_PATH}"
|
||||
}
|
||||
|
||||
if ! [ -r "${1}" ]; then
|
||||
echo "${0}: can't find KOReader archive, please specify a path to a KOReader tar.gz" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for required tools.
|
||||
missing_tools=()
|
||||
for tool in dpkg-deb fakeroot; do
|
||||
if ! command_exists "${tool}"; then
|
||||
missing_tools+=("${tool}")
|
||||
fi
|
||||
done
|
||||
if [[ ${#missing_tools[@]} -ne 0 ]]; then
|
||||
echo "${0}: unable to build Debian package, the following tools are missing: ${missing_tools[*]}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p tmp-debian/usr
|
||||
chmod 0755 tmp-debian/usr
|
||||
tar -xf "${1}" -C tmp-debian/usr
|
||||
ARCH="$(echo "${1}" | cut -d '-' -f3)"
|
||||
VERSION="$(cut -f2 -dv "tmp-debian/usr/lib/koreader/git-rev" | cut -f1,2 -d-)"
|
||||
DEB_ARCH="$(uname_to_debian "${ARCH}")"
|
||||
BASE_DIR="tmp-debian"
|
||||
|
||||
# populate debian control file
|
||||
mkdir -p "${BASE_DIR}/DEBIAN"
|
||||
cat >"${BASE_DIR}/DEBIAN/control" <<EOF
|
||||
Section: graphics
|
||||
Priority: optional
|
||||
Depends: libsdl2-2.0-0, fonts-noto-hinted, fonts-droid-fallback, libc6 (>= 2.31)
|
||||
Architecture: ${DEB_ARCH}
|
||||
Version: ${VERSION}
|
||||
Installed-Size: $(du -ks "${BASE_DIR}/usr/" | cut -f 1)
|
||||
Package: koreader
|
||||
Maintainer: Martín Fdez <paziusss@gmail.com>
|
||||
Homepage: https://koreader.rocks
|
||||
Description: Ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats
|
||||
KOReader is a document viewer for E Ink devices.
|
||||
Supported fileformats include EPUB, PDF, DjVu, XPS, CBT,
|
||||
CBZ, FB2, PDB, TXT, HTML, RTF, CHM, DOC, MOBI and ZIP files.
|
||||
It’s available for Kindle, Kobo, PocketBook, Android and desktop Linux.
|
||||
EOF
|
||||
|
||||
# use absolute path to luajit in reader.lua
|
||||
sed -i 's,./luajit,/usr/lib/koreader/luajit,' "${BASE_DIR}/usr/lib/koreader/reader.lua"
|
||||
|
||||
# use debian packaged fonts instead of our embedded ones to save a couple of MB.
|
||||
# Note: avoid linking against fonts-noto-cjk-extra, cause it weights ~200MB.
|
||||
link_fonts "${BASE_DIR}/usr/lib/koreader/fonts/noto"
|
||||
|
||||
# DroidSansMono has a restrictive license. Replace it with DroidSansFallback
|
||||
ln -snf ../../../../share/fonts-droid-fallback/truetype/DroidSansFallback.ttf "${BASE_DIR}/usr/lib/koreader/fonts/droid/DroidSansMono.ttf"
|
||||
|
||||
# lintian complains if shared libraries have execute rights.
|
||||
find "${BASE_DIR}" -type f -perm /+x -name '*.so*' -print0 | xargs -0 chmod a-x
|
||||
|
||||
# add debian changelog
|
||||
write_changelog "${BASE_DIR}/usr"
|
||||
|
||||
fakeroot dpkg-deb -b "${BASE_DIR}" "koreader-${VERSION}-${DEB_ARCH}.deb"
|
||||
rm -rf tmp-debian
|
||||
Reference in New Issue
Block a user