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

105.1. avahi-0.9rc5

mDNS/DNS-SD stack — what makes network printers discoverable

Version 0.9rc5, release 2
Shelf net-libs — Networking and protocol libraries
Phase 41_system (System), 44 of 1047 in build order
Licence LGPL-2.1-or-later
Homepage https://avahi.org
Build time 1.3 SBU
Installed size 1.3 MiB in 105 files
Recipe ports/core/net-libs/avahi/kpkgbuild

About

Avahi is an mDNS/DNS-SD implementation: avahi-daemon answers and sends multicast DNS on the local network, and programs browse for and publish services through its D-Bus API with libavahi-client. CUPS uses it to find driverless printers. Other ports link it for service discovery too, among them gvfs and geoclue through libavahi-glib and mumble through the libdns_sd compatibility library. On KDOS the daemon is started by /etc/init.d/45_avahi.sh once the system bus is up.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/net-libs.txt:

mDNS: CUPS' driverless printer discovery is compiled out without it, and kdos-mdnsd (50_desktop) answers .local names in DNS from this daemon, since musl has no NSS module system for nss-mdns.

Sources

Dependencies

Depends on: libdaemon, expat, dbus, glib, gdbm, gettext, autoconf, automake, libtool, pkgconf, xmltoman, libcap.

Required by (22): cups, cups-browsed, direwolf, geoclue, gvfs, hplip, ipp-usb, kdenetwork-filesharing, kdnssd, kdos-mdnsd, kio-zeroconf, kodi, libiio, liblxi, mumble, nut, phodav, pipewire, samba, sane-airscan, sane-backends, vlc.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

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

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/net-libs/avahi.

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/net-libs/avahi
echo '5b0a9d88110b0fc8aaafc5cc0a26e83e7d2a4aca3a36bc27c9b626db7ead27b0  avahi-0.9rc5.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/avahi
SRC=$SRC_ROOT/avahi-0.9rc5
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf avahi-0.9rc5.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 _tag and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

autoreconf -fi
./configure \
	--prefix=/usr \
	--sysconfdir=/etc \
	--localstatedir=/var \
	--libdir=/usr/lib \
	--with-distro=none \
	--with-systemdsystemunitdir=no \
	--with-xml=expat \
	--with-avahi-user=avahi \
	--with-avahi-group=avahi \
	--with-autoipd-user=avahi-autoipd \
	--with-autoipd-group=avahi-autoipd \
	--with-avahi-priv-access-group=wheel \
	--disable-static \
	--enable-dbus \
	--enable-gdbm \
	--enable-glib \
	--enable-gobject \
	--disable-qt3 \
	--disable-qt4 \
	--disable-qt5 \
	--disable-gtk \
	--disable-gtk3 \
	--disable-mono \
	--disable-monodoc \
	--disable-python \
	--disable-pygobject \
	--disable-introspection \
	--disable-libevent \
	--disable-libsystemd \
	--disable-doxygen-doc \
	--enable-compat-libdns_sd \
	--disable-compat-howl \
	--disable-tests \
	--enable-libdaemon

make
make DESTDIR=$PKG install
rm -rf "$PKG/run" "$PKG/var/run"
rm -f "$PKG/etc/avahi/services/ssh.service" "$PKG/etc/avahi/services/sftp-ssh.service"
install -dm755 "$PKG/var/lib/avahi-autoipd"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

postinstall.sh runs on the installed system after the package is adopted:

# avahi-daemon drops to `avahi` and avahi-autoipd to `avahi-autoipd`. Both are
# created here rather than in fs/etc/passwd because 00_file_system.sh MERGES
# those files: a runtime-added service user survives a re-sync, a repo-added one
# would need the repo edited for every package that wants a uid.
#
# Everything is written under PKG_ROOT, the root kpkgadd is installing into:
# --root and an A/B update install into a tree that is not the running one, and
# an account made in / instead would be missing from the system that needs it.
#
# The guard reads PKG_ROOT's files: getent answers for the running root, not
# the tree being installed, and would let useradd run against an account the
# target already has.
root="${PKG_ROOT:-/}"
grep -q '^avahi:' "$root/etc/group" 2>/dev/null || groupadd -R "$root" -r avahi
grep -q '^avahi:' "$root/etc/passwd" 2>/dev/null || \
	useradd -R "$root" -r -g avahi -d /run/avahi-daemon -s /sbin/nologin avahi
grep -q '^avahi-autoipd:' "$root/etc/group" 2>/dev/null || \
	groupadd -R "$root" -r avahi-autoipd
grep -q '^avahi-autoipd:' "$root/etc/passwd" 2>/dev/null || \
	useradd -R "$root" -r -g avahi-autoipd -d /var/lib/avahi-autoipd \
		-s /sbin/nologin avahi-autoipd

# chown resolves a name against the running root's passwd, so the ids are read
# out of PKG_ROOT's. The directory is avahi-autoipd's home and the root it
# chroots into; it must belong to that account.
while IFS=: read -r n _ uid gid _; do
	[ "$n" = avahi-autoipd ] || continue
	chown "$uid:$gid" "$root/var/lib/avahi-autoipd"
done < "$root/etc/passwd"

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/avahi, 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 avahi-0.9rc5-2.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/avahi, and runs the triggers its paths call for.

Contents

Installed programs: avahi-autoipd, avahi-browse, avahi-browse-domains, avahi-daemon, avahi-dnsconfd, avahi-publish, avahi-publish-address, avahi-publish-service, avahi-resolve, avahi-resolve-address, avahi-resolve-host-name, avahi-set-host-name.

Installed libraries: libavahi-client.so, libavahi-common.so, libavahi-core.so, libavahi-glib.so, libavahi-gobject.so, libdns_sd.so.

Installed directories: /etc/avahi, /usr/include/avahi-client, /usr/include/avahi-common, /usr/include/avahi-compat-libdns_sd, /usr/include/avahi-core, /usr/include/avahi-glib, /usr/include/avahi-gobject, /usr/share/avahi, /usr/share/licenses/avahi, /var/lib/avahi-autoipd.

Short descriptions

avahi-autoipd IPv4LL network address configuration daemon
avahi-browse Browse for mDNS/DNS-SD services using the Avahi daemon
avahi-daemon The Avahi mDNS/DNS-SD daemon
avahi-dnsconfd Unicast DNS server from mDNS/DNS-SD configuration daemon
avahi-publish Register an mDNS/DNS-SD service or host name or address mapping using the Avahi daemon
avahi-resolve Resolve one or more mDNS/DNS host name(s) to IP address(es) (and vice versa) using the Avahi daemon
avahi-set-host-name Change mDNS host name
avahi-client.pc Avahi Multicast DNS Responder (Client Support)
avahi-compat-libdns_sd.pc Avahi Multicast DNS Responder (libdns_sd Compatibility)
avahi-core.pc Avahi Multicast DNS Responder (Embeddable Stack)
avahi-glib.pc Avahi Multicast DNS Responder (GLib Support)
avahi-gobject.pc Avahi Multicast DNS Responder (GLib GObject Support)

Notes

build.sh runs autoreconf -fi first: the source is a tag archive from GitHub, not a release tarball, and carries no generated configure.

/run and /var/run are removed from the staged tree, because both are tmpfs on a running system and the package lint refuses files there; the init script creates /run/avahi-daemon and gives it to avahi before it starts the daemon. ssh.service and sftp-ssh.service are removed from /etc/avahi/services, so a KDOS machine does not announce an SSH server on the local network. /var/lib/avahi-autoipd is created in the package and given to avahi-autoipd by postinstall.sh: it is that account’s home and the directory the daemon chroots into.

With --disable-python the service type database service-types.db is not generated, because upstream builds it with a Python script. avahi-browse, built with GDBM, then finds no database and prints each service’s type as the raw DNS-SD string.

postinstall.sh creates the two system accounts in the root being installed into. The daemon exits at once if it cannot claim org.freedesktop.Avahi on the system bus, which is why 45_avahi starts after 40_dbus.