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

92.17. lnav-0.14.1

Log navigator with SQL over log lines

Version 0.14.1, release 1
Shelf cli — Command-line productivity utilities: search, view, navigation and text wrangling in the terminal
Phase 41_system (System), 298 of 1047 in build order
Licence BSD-2-Clause
Homepage https://lnav.org/
Build time 17.6 SBU
Installed size 39.1 MiB in 4 files
Recipe ports/core/cli/lnav/kpkgbuild

About

lnav, the Logfile Navigator, opens many log files at once and merges them into one view in time order, recognising the common formats (syslog, web server access logs, JSON lines and more) so it can colour, filter and jump between errors. Each recognised format is also a table, so a question about the logs can be put to them in SQL, or in PRQL through the Rust extension. On KDOS it is the tool for asking questions of this machine’s own logs. The port installs lnav and a desktop entry that opens it in a terminal as Log Viewer.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/cli.txt:

lnav is the only thing on this machine that can answer a question about its own logs in SQL, which matters when there is no search box to paste them into.

Sources

Dependencies

Depends on: autoconf, automake, libtool, pkgconf, ncurses, pcre2, sqlite, zlib, bzip2, libarchive, curl, libunistring, rust.

Required by: no port names it.

Patches

build.sh applies these; kpkg applies nothing by itself.

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

What kpkg does

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

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/cli/lnav
echo '9eddf42dbbbd59af423cd25f49e744969c95a3901f9aba07e48481d4c41c4c4e  lnav-0.14.1.tar.gz' | sha256sum -c -
echo '5690aa4ef2b9515d8039091751c640c5b57b31bc88d5d5017718473278596494  lnav-vendor-0.14.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/lnav
SRC=$SRC_ROOT/lnav-0.14.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lnav-0.14.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 recipe’s helpers vendordir 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 -C src
export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
export CARGO_NET_OFFLINE=true

patch -p1 -i $PORT_SRC/lnav-tailer-static.patch

./autogen.sh

./configure --prefix=/usr --sysconfdir=/etc --disable-static \
	--with-libarchive \
	--with-cargo \
	--disable-system-paths \
	ac_cv_path_RE2C_CMD= \
	ac_cv_path_CXXBRIDGE=
make
make DESTDIR=$PKG install

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/lnav.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Log Viewer
GenericName=Log Viewer
Comment=Merge, filter and search log files
Exec=lnav %F
Icon=text-x-generic
Terminal=true
Categories=System;Monitor;Utility;
Keywords=log;journal;syslog;filter;lnav;
EOF
chmod 644 "$PKG/usr/share/applications/lnav.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/lnav, 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 lnav-0.14.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/lnav, and runs the triggers its paths call for.

Contents

Installed programs: lnav.

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

Short descriptions

lnav log file viewer for the terminal

Notes

The Rust extension’s crates come from a vendor bundle, lnav-vendor-<version>.tar.xz. Its vendordir = src/third-party/lnav-rs-ext tells ports/fetch to run cargo vendor beside the extension’s manifest, and the bundle replaces both crates.io and the extension’s one git dependency, log2src, with the vendored copies. build.sh unpacks the bundle into src/, not beside the manifest: the Makefile runs cargo build --manifest-path … from src/, and cargo finds the bundle’s .cargo/config.toml only by walking up from the directory it runs in, so a bundle placed anywhere else leaves cargo trying to clone the git dependency in a build with no network. See Where the bundle goes.

The source is GitHub’s archive of the tag, which carries no configure, so build.sh runs ./autogen.sh first, with the autoconf, automake and libtool in depends. That also regenerates src/tailer/Makefile.in from the patched Makefile.am, so the patch is applied before it.