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

95.21. bolt-0.9.11

Thunderbolt device manager, so a dock behind firmware security is authorised

Version 0.9.11, release 1
Shelf hardware — Device access, bus and sensor tools, power management, and Bluetooth
Phase 41_system (System), 667 of 1047 in build order
Licence LGPL-2.1-or-later
Homepage https://gitlab.freedesktop.org/bolt/bolt
Build time 0.2 SBU
Installed size 605.5 KiB in 13 files
Recipe ports/core/hardware/bolt/kpkgbuild

About

bolt manages Thunderbolt devices: boltd authorises a device the kernel has enumerated, by its stored policy, and boltctl lists, enrolls and authorises devices by hand. Where the firmware’s Thunderbolt security level is user or secure, the shipping default on most business laptops, a Thunderbolt 3 or 4 dock is enumerated and then never authorised without it, and the dock’s ports stay dead. An enrolled device is authorised only while boltd runs.

Why it is in KDOS

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

Thunderbolt authorisation. Where the firmware's security level is user or secure — the shipping default on most business laptops — a TB3/TB4 dock is enumerated and then never authorised, so the dock's ports stay dead.

Sources

Dependencies

Depends on: meson, ninja, glib, polkit, eudev, dbus, asciidoc.

Required by (1): plasma-thunderbolt.

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

What kpkg does

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

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/hardware/bolt
echo 'cde4fc6d4a188e37d088cf59a5b2d174ac4b03d57bf9d084d711ba92105c33c0  bolt-0.9.11.tar.gz' | 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/bolt
SRC=$SRC_ROOT/bolt-0.9.11
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf bolt-0.9.11.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:

meson setup build --prefix=/usr --sysconfdir=/etc --libdir=lib \
	--localstatedir=/var \
	--buildtype=release \
	-Dman=true \
	-Dinstall-tests=false \
	-Dprivileged-group=wheel
meson compile -C build
DESTDIR=$PKG meson install --no-rebuild -C build

install -d "$PKG/usr/lib/udev/rules.d"
cat > "$PKG/usr/lib/udev/rules.d/91-kdos-bolt.rules" <<'RULES'
ACTION=="add", SUBSYSTEM=="thunderbolt", RUN+="/usr/bin/dbus-send --system --type=method_call --dest=org.freedesktop.bolt /org/freedesktop/bolt org.freedesktop.DBus.Peer.Ping"
RULES
install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/43_boltd.sh" <<'KDOS_SH'
#!/bin/bash
NAME="boltd"

case "$1" in
    start)
        # No controller, nothing to authorise; the udev rule starts boltd if
        # one appears later.
        if [ -z "$(ls -A /sys/bus/thunderbolt/devices 2>/dev/null)" ]; then
            echo "[SKIP] $NAME: no thunderbolt controller"
            exit 0
        fi
        echo "[KDOS] Starting $NAME..."
        dbus-send --system --type=method_call \
            --dest=org.freedesktop.bolt /org/freedesktop/bolt \
            org.freedesktop.DBus.Peer.Ping
        ;;
    stop)
        # Started by the bus, so not ours to stop; it ends with the machine.
        ;;
    status)
        # Running is owning the bus name, which is also what a client needs.
        if dbus-send --system --print-reply --dest=org.freedesktop.DBus \
            / org.freedesktop.DBus.NameHasOwner string:org.freedesktop.bolt \
            2>/dev/null | grep -q 'boolean true'; then
            echo "$NAME is running"
        else
            echo "$NAME is not running"
            exit 1
        fi
        ;;
    *)
        echo "Usage: $0 {start|stop|status}"
        exit 1
        ;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/43_boltd.sh"

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

Contents

Installed programs: boltctl.

Installed directories: /usr/share/licenses/bolt, /var/lib/boltd.

Short descriptions

boltctl control the thunderbolt device manager

Notes

No switch turns systemd off, because none is needed. bolt’s systemd meson option is marked DEPRECATED and read nowhere; the build installs a unit file only when dependency('systemd', required: false) finds systemd.pc, which the tree does not have, and in that case it creates the device database directory at install instead. Nothing links sd-bus either: boltd uses GDBus, and its readiness notifications are its own write to $NOTIFY_SOCKET, which is unset here, so they do nothing.

boltd is installed in /usr/libexec, the meson default, and the same path is written into the D-Bus service file’s Exec=.

Starting boltd. D-Bus activation is the only way boltd starts. Upstream’s 90-bolt.rules starts it through SYSTEMD_WANTS, which eudev ignores. build.sh adds two pokes for the two moments a controller can appear, each a D-Bus Ping to org.freedesktop.bolt, which activates boltd when it is not running and is answered by it when it is, so neither can start a second daemon:

The udev rule cannot start the daemon itself: udevd kills whatever a rule runs once the event is handled. The init script’s stop does nothing, since the bus started the daemon, and its status reports whether the bus name has an owner.