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
delta-0.19.2.tar.gz(531.3 KiB)
sha256f59b86f8c8dda4d76a3ba34b8553777a20c3b461646917d8e480fac6531bba9f
upstream: https://github.com/dandavison/delta/archive/refs/tags/0.19.2.tar.gz
archive copy: sources-1/devtools--delta-0.19.2.tar.gzdelta-vendor-0.19.2.tar.xz(51.5 MiB)
sha2562798d16686c839da0b112a1579432e55a1d08d2bd4c03ce0d508ab94ce65b36a
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/devtools--delta-vendor-0.19.2.tar.xz
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
- The highlighting sets are bat’s, not the bundle’s. bat embeds
syntaxes.bin,themes.binandacknowledgements.bininto any program that links it, and delta’s copy of them sits in the vendoredbatcrate. Before cargo runs,build.shcopies the three files the bat port installed in/usr/share/bat/assetsover those copies, sodeltaandbathighlight with the same sets. Cargo checks every vendored file against the crate’s.cargo-checksum.json, sobuild.shalso rewrites the three entries there with the new files’ sha256; the rest of the crate is still verified. Why the sets are built by thebatport, and how its asset bundle is made, is in A bundle no tool writes. - The vendored bat must be the installed bat. The sets are bincode dumps of syntect’s types with no version tag, so a set from another bat may not load.
build.shreads the version of the vendored crate fromvendor/bat/Cargo.tomland stops unlessbat --versionreports the same one. A bump of bat that delta’s lock file does not follow stops this build, and the two have to move together. - libgit2 and oniguruma are the system’s. The tree’s environment sets
LIBGIT2_NO_VENDOR=1andRUSTONIG_SYSTEM_LIBONIG=1for every Rust build from40_langon (see rust), so the-syscrates link libgit2 and oniguruma instead of compiling their own copies. The tworeadelf -dlines aftercargo buildmake that a condition of the build: the binary must NEED the libgit2 and oniguruma sonames they spell out in full, so a libgit2 release with a new soname stops this build until the check names it.