69.5. typst-0.15.1
Markup-based typesetting system
| Version | 0.15.1, release 1 |
| Shelf | doctools — Documentation toolchains, man pages, markup converters and TeX typesetting |
| Phase | 40_lang (Languages), 40 of 186 in build order |
| Licence | Apache-2.0 |
| Homepage | https://typst.app/ |
| Build time | 7.3 SBU |
| Installed size | 48.1 MiB in 16 files |
| Recipe | ports/core/doctools/typst/kpkgbuild |
About
Typst is a markup-based typesetting system: one program that compiles a .typ source to PDF, PNG, SVG or HTML, and reports an error with the line it is on. It is a single small program, where TeX Live is gigabytes to install. kdos-kfs, the port that ships this book, needs it to typeset the book’s PDF.
System fonts are found through fontconfig’s configuration, which the fontdb crate reads itself (typst does not link libfontconfig), so typst sees the font directories the rest of the system does, plus the few fonts it embeds. typst links the system openssl (libssl.so, libcrypto.so) for its HTTPS downloads of Typst Universe packages, which a document asks for with an @preview/ import.
Why it is in KDOS
The comment above it in script/phases/40_lang/packages.d/doctools.txt:
A TeX Live install is gigabytes and answers a mistake with forty lines of macro expansion; this is one binary that says which line is wrong. Where nobody can search for the error text, that is whether a document gets written.
Sources
typst-0.15.1.tar.gz(4.6 MiB)
sha256c07909e01a2a6941e52c9b616e48c209c755eed416d62bcf5583c37a4aca01a3
upstream: https://github.com/typst/typst/archive/refs/tags/v0.15.1.tar.gz
archive copy: sources-1/doctools--typst-0.15.1.tar.gztypst-vendor-0.15.1.tar.xz(68.0 MiB)
sha2569ca92c3e18b586dbfee7bd0c1160038d104fe6ce4a4cf1212179ff3a96c142c7
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/doctools--typst-vendor-0.15.1.tar.xz
Dependencies
Depends on: rust, openssl, zlib, pkgconf.
Required by (1): kdos-kfs.
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/40_lang/phase.env && kpkg install typst'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/doctools/typst.
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/doctools/typst
echo 'c07909e01a2a6941e52c9b616e48c209c755eed416d62bcf5583c37a4aca01a3 typst-0.15.1.tar.gz' | sha256sum -c -
echo '9ca92c3e18b586dbfee7bd0c1160038d104fe6ce4a4cf1212179ff3a96c142c7 typst-vendor-0.15.1.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/typst
SRC=$SRC_ROOT/typst-0.15.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf typst-0.15.1.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/${name}-vendor-${version}.tar.xz
export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
export CARGO_NET_OFFLINE=true
export GEN_ARTIFACTS="$PWD/gen"
cargo build --release --frozen --offline --bin typst \
--no-default-features --features embedded-fonts,http-server
install -Dm755 target/release/typst $PKG/usr/bin/typst
install -Dm644 gen/*.1 -t "$PKG/usr/share/man/man1"
install -Dm644 gen/typst.bash "$PKG/usr/share/bash-completion/completions/typst"
install -Dm644 gen/_typst -t "$PKG/usr/share/zsh/site-functions"
install -Dm644 gen/typst.fish -t "$PKG/usr/share/fish/vendor_completions.d"
The switches, and why each is set:
--bin typst— Build only thetypstexecutable of the workspace.--no-default-features,--features embedded-fonts,http-server— Name the features instead of taking the defaults. The two named aretypst-cli’s default set:http-serveris the local live-reload server behindtypst watchand HTML export, andembedded-fontsbuilds in typst’s own fonts, whichtypst-clialso asks oftypst-kitdirectly, so they are in the binary either way.self-update, which lets the program replace itself, andvendor-openssl, which compiles a private OpenSSL, stay off, and so does any feature upstream adds to its defaults until the recipe names it.GEN_ARTIFACTS="$PWD/gen"—typst-cli’s build script writes the manual pages and the bash, zsh and fish completions into this directory when it is set, and the install lines take them from there.
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/typst, 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 typst-0.15.1-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/typst, and runs the triggers its paths call for.
Contents
Installed programs: typst.
Installed directories: /usr/share/licenses/typst.
Short descriptions
typst |
The Typst compiler |
Notes
-C target-feature=-crt-static matters here beyond the usual reason. Linked statically, openssl-sys takes libcrypto.a, whose compression code calls zlib, and a static archive records no dependency of its own, so the link fails on zlib’s symbols. Linked dynamically, libcrypto.so names libz itself. See rust.