Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

212.4. koreader-2026.07.2

E-book and document reader for EPUB, PDF, DjVu, FB2 and comics, on SDL3 with no toolkit

Version 2026.07.2, release 2
Shelf documents — PDF, PostScript, DjVu, EPUB, CHM and DOCX viewers, libraries and tools, and ebook managers
Phase 42_graphics (Graphics Stack), 85 of 189 in build order
Licence AGPL-3.0-or-later
Homepage https://koreader.rocks
Build time 10.4 SBU
Installed size 97.2 MiB in 1071 files
Recipe ports/core/documents/koreader/kpkgbuild

About

KOReader is an e-book and document reader for EPUB, PDF, DjVu, FB2, MOBI and comic book archives, written in Lua on LuaJIT, with crengine for reflowable formats and MuPDF and DjVuLibre for fixed-layout ones. It is made for e-ink readers, and its desktop build, the one this port makes, draws its own interface in an SDL3 window with no toolkit. Every library it runs on, apart from SDL3 and the system’s C and C++ runtimes, is built by its own base tree and installed privately under /usr/lib/koreader.

Sources

Dependencies

Depends on: autoconf, automake, cmake, coreutils, diffutils, findutils, gettext, git, libtool, meson, nasm, ninja, perl, pkgconf, curl, sdl3, bash, procps-ng, librsvg.

Required by: no port names it.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/42_graphics/phase.env && kpkg install koreader'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/documents/koreader.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/documents/koreader
echo '67e3d2cd432ccfcfb29f4f3203376d595704b0cb562274086eb3bb25a1bc662d  koreader-2026.07.2.tar.gz' | sha256sum -c -
echo '6f67b8f0276d870967acc4a918f6035b34bea2a14b389b419cd5fe6771d4e9d0  koreader-thirdparty-2026.07.2.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/koreader
SRC=$SRC_ROOT/koreader-2026.07.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf koreader-2026.07.2.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

tar xf "$PORT_SRC/koreader-thirdparty-$version.tar.xz"

patch -p1 -i "$PORT_SRC/koreader-sh-enable-ko-multiuser.patch"
patch -p1 -i "$PORT_SRC/koreader-sdl-app-id.patch"

unset PKG_CONFIG_PATH
make TARGET= KODEBUG= VERBOSE= TARGET_CFLAGS= \
	QFLAGS=-fstack-clash-protection COMPAT_LDFLAGS=-Wl,-z,now

install -d "$PKG/usr/lib" "$PKG/usr/bin"
cp -RL koreader-emulator-*/koreader "$PKG/usr/lib/koreader"
ln -s ../lib/koreader/koreader.sh "$PKG/usr/bin/koreader"
find "$PKG" -name '*.dbg' -delete
rm -rf "$PKG/usr/lib/koreader/spec"
echo "v$version" > "$PKG/usr/lib/koreader/git-rev"

find "$PKG/usr/lib/koreader/l10n" -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} +

install -Dm644 platform/linux/koreader.1 "$PKG/usr/share/man/man1/koreader.1"

for s in 48 64 128 256; do
	install -d "$PKG/usr/share/icons/hicolor/${s}x${s}/apps"
	rsvg-convert -w $s -h $s resources/koreader.svg \
		-o "$PKG/usr/share/icons/hicolor/${s}x${s}/apps/rocks.koreader.KOReader.png"
done

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/rocks.koreader.KOReader.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=KOReader
GenericName=E-book Reader
Comment=Read EPUB, PDF, DjVu, FB2, MOBI and comic books
TryExec=koreader
Exec=koreader %f
Icon=rocks.koreader.KOReader
Terminal=false
StartupWMClass=rocks.koreader.KOReader
Categories=Office;Viewer;
Keywords=ebook;epub;pdf;djvu;fb2;mobi;comic;cbz;reader;book;
DESKTOP
chmod 644 "$PKG/usr/share/applications/rocks.koreader.KOReader.desktop"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/koreader, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf koreader-2026.07.2-2.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/koreader, and runs the triggers its paths call for.

Contents

Installed programs: koreader.

Installed directories: /usr/lib/koreader, /usr/share/licenses/koreader.

Short descriptions

koreader document viewer

Notes