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
koreader-2026.07.2.tar.gz(54.9 MiB)
sha25667e3d2cd432ccfcfb29f4f3203376d595704b0cb562274086eb3bb25a1bc662d
upstream: https://distfiles.alpinelinux.org/distfiles/edge/koreader-v2026.07.2.tar.gz
archive copy: sources-1/documents--koreader-2026.07.2.tar.gzkoreader-thirdparty-2026.07.2.tar.xz(193.6 MiB)
sha2566f67b8f0276d870967acc4a918f6035b34bea2a14b389b419cd5fe6771d4e9d0
archive copy: sources-1/documents--koreader-thirdparty-2026.07.2.tar.xz
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.
koreader-sdl-app-id.patch— ExportsSDL_APP_ID=rocks.koreader.KOReaderin the launcher. The process SDL runs in isluajit, whose name would otherwise be the window’s app_id; the menu entry’sStartupWMClassnames the same id.koreader-sh-enable-ko-multiuser.patch— ExportsKO_MULTIUSER=1in thekoreader.shlauncher, so settings, history and caches go to~/.config/koreaderinstead of the read-only install directory.
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:
TARGET=— An empty target is upstream’s desktop build, which it calls the emulator: SDL for the window, input and audio, against the system’s SDL3.KODEBUG=— An emptyKODEBUGis a release build; the desktop build defaults to a debug one (-Og, noNDEBUG).VERBOSE=— Override anyVERBOSEin the environment with an empty one. WithVERBOSEandVboth empty,basemarks its makefiles.SILENTand adds no make trace orninja -v.TARGET_CFLAGS=— Replace the desktop build’s-march=native, which would tune every library to the processor of the machine that built it, with nothing.QFLAGS=-fstack-clash-protection,COMPAT_LDFLAGS=-Wl,-z,now—baseassigns its ownCFLAGS,CXXFLAGSandLDFLAGSand does not read the tree’s, so the tree’s hardening would be lost.QFLAGS(empty under GCC) is part of every C and C++ compile line, andCOMPAT_LDFLAGSis appended to every link, so these two carry the tree’s-fstack-clash-protectionand-z nowinto the third-party libraries and KOReader’s own code.unset PKG_CONFIG_PATH—basepointsPKG_CONFIG_LIBDIRat its staging directory and, for the desktop build, leavesPKG_CONFIG_PATHalone, which pkg-config searches first. The chroot’sPKG_CONFIG_PATHnames/usr/lib/pkgconfig, so the system’s Leptonica and Tesseract would be found beforebase’s patched copies, and k2pdfopt, which calls their additions, stops compiling.
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
- Two sources, one made by hand. The first is the KOReader superproject with its submodules (
base, crengine, fonts and translations), as Alpine mirrors it.basebuilds its third-party libraries (LuaJIT, MuPDF, the libraries crengine needs, DjVuLibre, HarfBuzz, SQLite and the rest) at pinned versions, each downloaded at build time intobase/thirdparty/<project>/build/downloads, as a tarball checked by MD5 or a git clone at a pinned revision. The second source is those downloads, packed by hand aftermake TARGET= KODEBUG= download-all; with each archive present and each clone at its revision, the download step reaches nothing and git checks the revisions out offline. How to rebuild it on a version bump is in A bundle no tool writes.build.shunpacks it over the source tree before anything else. - What ships as upstream made it. The fonts in the tree and the certifi CA bundle are installed as they come; both are exempt under What is built from source.
- The install is the emulator tree.
makeleaves the finished program inkoreader-emulator-*/koreader;build.shcopies it with links resolved to/usr/lib/koreader, links/usr/bin/koreaderto itskoreader.sh, and removes the debug files (*.dbg) and the test suite (spec).git-revis written by hand, because the tarball is not a git checkout and KOReader shows that file as its version. - English only. Every translation is a directory under
l10n, read as.poat run time, which the tree-wide language prune does not match;build.shremoves them, and the interface falls back to its built-in English strings. - The menu entry is KDOS’s own.
build.shwritesrocks.koreader.KOReader.desktop, which claims no MIME type, and rasterises upstream’s SVG icon to PNGs, which the session’s icon lookup reads. Upstream’s own entry claims PDF, PNG, ZIP, HTML and plain text among many types that belong to other programs.