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

84.1. delta-0.19.2

A syntax-highlighting pager for git, diff, and grep output

Version 0.19.2, release 1
Shelf devtools — Debuggers, tracers, profilers, analysers, linters, language servers and developer utilities
Phase 41_system (System), 371 of 1047 in build order
Licence MIT
Homepage https://github.com/dandavison/delta
Build time 1.6 SBU
Installed size 7.0 MiB in 2 files
Recipe ports/core/devtools/delta/kpkgbuild

About

delta is a pager for git diff, git show, git log -p, diff and grep output: it highlights the syntax of the changed code, marks the changed words within a line, and can lay the two sides out next to each other. Git uses it once core.pager and interactive.diffFilter name it. It is a Rust program built from a vendored crate bundle, and it does its highlighting with bat’s library and bat’s compiled syntax and theme sets.

Sources

Dependencies

Depends on: rust, zlib, bat, libgit2, oniguruma.

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

What kpkg does

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

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/devtools/delta
echo 'f59b86f8c8dda4d76a3ba34b8553777a20c3b461646917d8e480fac6531bba9f  delta-0.19.2.tar.gz' | sha256sum -c -
echo '2798d16686c839da0b112a1579432e55a1d08d2bd4c03ce0d508ab94ce65b36a  delta-vendor-0.19.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/delta
SRC=$SRC_ROOT/delta-0.19.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf delta-0.19.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/${name}-vendor-${version}.tar.xz

_batver=$(sed -n 's/^version = "\(.*\)"$/\1/p' vendor/bat/Cargo.toml | head -n 1)
_have=$(bat --version)
if [ "$_have" != "bat $_batver" ]; then
	echo "delta vendors bat $_batver; the installed sets are from '$_have'" >&2
	exit 1
fi
_sum=$(< vendor/bat/.cargo-checksum.json)
for _f in syntaxes.bin themes.bin acknowledgements.bin; do
	install -m644 /usr/share/bat/assets/$_f vendor/bat/assets/$_f
	[[ $_sum =~ \"assets/$_f\":\"([0-9a-f]{64})\" ]] || {
		echo "vendor/bat/.cargo-checksum.json lists no assets/$_f" >&2
		exit 1
	}
	_new=$(sha256sum vendor/bat/assets/$_f)
	_sum=${_sum/\"assets\/$_f\":\"${BASH_REMATCH[1]}\"/\"assets\/$_f\":\"${_new%% *}\"}
done
printf '%s' "$_sum" > vendor/bat/.cargo-checksum.json

export RUSTFLAGS="-C target-feature=-crt-static"

cargo build --release --frozen --offline
readelf -d target/release/delta | grep -q 'NEEDED.*\[libgit2\.so\.1\.9\]'
readelf -d target/release/delta | grep -q 'NEEDED.*\[libonig\.so\.5\]'
install -Dm755 target/release/delta $PKG/usr/bin/delta

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/delta, 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 delta-0.19.2-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/delta, and runs the triggers its paths call for.

Contents

Installed programs: delta.

Installed directories: /usr/share/licenses/delta.

Notes