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

147.5. chess-tui-2.7.1

Chess in a terminal, against Stockfish or a second player

Version 2.7.1, release 1
Shelf games-board — Board, card, puzzle, chess and classic small games, whatever toolkit or desktop project they come from
Phase 41_system (System), 570 of 1047 in build order
Licence MIT
Homepage https://thomas-mauran.github.io/chess-tui/
Build time 4.6 SBU
Installed size 7.0 MiB in 3 files
Recipe ports/core/games-board/chess-tui/kpkgbuild

About

chess-tui is a chess game drawn in a terminal, written in Rust. It plays a second player at the same keyboard, a second player over TCP, any UCI chess engine, or an opponent on Lichess. KDOS pairs it with stockfish: the desktop entry the recipe writes starts it as chess-tui -e /usr/bin/stockfish, because chess-tui has no default engine, and a game against the computer with none configured stops at “Chess engine path not configured”. A path given with -e is also written into the player’s ~/.config/chess-tui/config.toml.

The build is the standard Rust recipe described in writing-ports.md, with no switch of its own, and the crates come from the vendor bundle described below.

Sources

Dependencies

Depends on: rust, pkgconf, cmake, alsa-lib, stockfish.

Required by: no port names it.

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/41_system/phase.env && kpkg install chess-tui'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/games-board/chess-tui.

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/games-board/chess-tui
echo '471b6280c8aa0979956b85d54dfd216855a47f8517a9a1d3e5286e4044adaac5  chess-tui-2.7.1.tar.gz' | sha256sum -c -
echo 'c12350c04e769be046cd8b23e9b4752d3f57bd8ff484fc4bf602ba4abad34c97  chess-tui-vendor-2.7.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/chess-tui
SRC=$SRC_ROOT/chess-tui-2.7.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf chess-tui-2.7.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 LIBCLANG_PATH=/usr/lib
export CARGO_NET_OFFLINE=true

cargo build --release --frozen --offline
install -Dm755 target/release/chess-tui "$PKG/usr/bin/chess-tui"

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/chess-tui.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=Chess (chess-tui)
GenericName=Chess Game
Comment=Play chess against Stockfish or a second player
Exec=chess-tui -e /usr/bin/stockfish
Icon=input-gaming
Terminal=true
Categories=Game;BoardGame;
Keywords=chess;stockfish;board;game;uci;
DESKTOP
chmod 644 "$PKG/usr/share/applications/chess-tui.desktop"

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/chess-tui, 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 chess-tui-2.7.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/chess-tui, and runs the triggers its paths call for.

Contents

Installed programs: chess-tui.

Installed directories: /usr/share/licenses/chess-tui.

Notes

The crates are not downloaded at build time. ports/fetch runs cargo vendor against the release and packs the result into chess-tui-vendor-<version>.tar.xz, whose sha256 = line in the recipe holds it like any other source; build.sh unpacks it and builds with --frozen --offline (see Vendoring).

The default feature set is kept, and it is the sound: moves play through the rodio crate, which reaches ALSA through cpal, so alsa-lib is a dependency and PipeWire answers the ALSA device.

The Lichess mode makes HTTPS requests through reqwest on rustls, whose crypto is AWS-LC compiled into the binary from the vendored aws-lc-sys crate. No package database sees that copy, so it has a row in src/system/kdos-tools/secdb/bundled.txt that names its version; a bump of the vendor bundle that moves the crate changes the row in the same change (see Bundled copies). Only the Lichess mode and the TCP game need a network; the others work without one.