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

212.2. mupdf-1.28.4

mutool — the PDF the command line can take apart — and the mupdf-gl and mupdf-x11 viewers

Version 1.28.4, release 1
Shelf documents — PDF, PostScript, DjVu, EPUB, CHM and DOCX viewers, libraries and tools, and ebook managers
Phase 42_graphics (Graphics Stack), 83 of 189 in build order
Licence AGPL-3.0-or-later
Homepage https://mupdf.com/
Build time 1.8 SBU
Installed size 54.9 MiB in 127 files
Recipe ports/core/documents/mupdf/kpkgbuild

About

MuPDF is a library and set of programs for PDF, XPS, EPUB, FictionBook, comic book archives and images. The port installs libmupdf, mutool (split, merge, draw, extract, clean, sign, run scripts, and dump text a grep can reach), and two viewers: mupdf-gl, the full one with search, annotations, forms and a file dialog, and mupdf-x11, a plain Xlib viewer. Both viewers are X11 programs and run under Xwayland. aerc names the port in depends.

Why it is in KDOS

The comment above it in script/phases/42_graphics/packages.d/documents.txt:

mutool splits, merges, draws and extracts, and dumps text a grep can reach; mupdf-gl is the light PDF and EPUB viewer, under Xwayland.

Sources

Dependencies

Depends on: freetype2, libjpeg-turbo, openjpeg, harfbuzz, zlib, jbig2dec, curl, brotli, leptonica, tesseract, libarchive, zxing-cpp, openssl, python3, freeglut, glu, libglvnd, mesa, libX11, libXext, libXrandr.

Required by (1): aerc.

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 mupdf'

What kpkg does

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

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/mupdf
echo '2d97e043a616f96b148657c9c3d81ad71c4bd2052c59a2a3315ad842599340f9  mupdf-1.28.4.tar.gz' | 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/mupdf
SRC=$SRC_ROOT/mupdf-1.28.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf mupdf-1.28.4.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:

MUPDF_SYS="USE_SYSTEM_LIBS=yes USE_SYSTEM_GUMBO=no USE_SYSTEM_MUJS=no \
	USE_SYSTEM_ZXINGCPP=yes USE_SYSTEM_LCMS2=no USE_SYSTEM_GLUT=yes"
MUPDF_OPT="tesseract=yes archive=yes barcode=yes HAVE_LIBCRYPTO=yes \
	HAVE_X11=yes HAVE_GLUT=yes HAVE_OBJCOPY=yes"

rm -f resources/hyphen/hyph-std.zip resources/hyphen/hyph-all.zip \
	generated/resources/hyphen/*.zip.c
python3 - <<'PY'
import glob, zipfile
for out, dirs in (("hyph-std.zip", ("core",)), ("hyph-all.zip", ("core", "extra"))):
    files = sorted(f for d in dirs for f in glob.glob(f"resources/hyphen/{d}/*"))
    with zipfile.ZipFile(f"resources/hyphen/{out}", "w") as z:
        for f in files:
            info = zipfile.ZipInfo(f.rsplit("/", 1)[1], (1997, 8, 29, 2, 14, 0))
            info.compress_type = zipfile.ZIP_DEFLATED
            with open(f, "rb") as src:
                z.writestr(info, src.read(), compresslevel=9)
PY

export CC="gcc -std=gnu11" CFLAGS="${CFLAGS/-std=gnu11/}"
make $MUPDF_SYS $MUPDF_OPT build=release prefix=/usr shared=yes
make $MUPDF_SYS $MUPDF_OPT build=release prefix=/usr shared=yes \
	DESTDIR=$PKG install

for s in 16 24 32 48 72 128 256 512; do
	install -Dm644 docs/logo/mupdf-icon-$s.png \
		"$PKG/usr/share/icons/hicolor/${s}x$s/apps/mupdf.png"
done
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/mupdf-gl.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=PDF Viewer (MuPDF)
GenericName=Document Viewer
Comment=Read, search and annotate PDF, EPUB, XPS and comic book files
Exec=mupdf-gl %f
Icon=mupdf
Terminal=false
Categories=Office;Viewer;Graphics;
Keywords=pdf;epub;xps;cbz;document;reader;annotate;mupdf;
DESKTOP
chmod 644 "$PKG/usr/share/applications/mupdf-gl.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/mupdf, 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 mupdf-1.28.4-1.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/mupdf, and runs the triggers its paths call for.

Contents

Installed programs: mupdf-gl, mupdf-x11, mutool.

Installed libraries: libmupdf.so.

Installed directories: /usr/include/mupdf, /usr/share/doc/mupdf, /usr/share/licenses/mupdf.

Short descriptions

mutool all purpose tool for dealing with PDF files

Notes