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
.localnames in DNS from this daemon, since musl has no NSS module system for nss-mdns.
Sources
avahi-0.9rc5.tar.gz(1.1 MiB)
sha2565b0a9d88110b0fc8aaafc5cc0a26e83e7d2a4aca3a36bc27c9b626db7ead27b0
upstream: https://github.com/avahi/avahi/archive/refs/tags/v0.9-rc5.tar.gz
archive copy: sources-3/net-libs--avahi-0.9rc5.tar.gz
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.
--disable-qt5, line 33: qt5-qtbase--disable-gtk, line 34: gtk3--disable-gtk3, line 35: gtk3--disable-python, line 38: python3 (explained with the switches below)--disable-pygobject, line 39: python3-gobject--disable-libevent, line 41: libevent (explained with the switches below)
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:
--with-distro=none— Install no distribution init script. configure detects the distribution from a release file such as/etc/arch-releaseand, finding none, stops with “Linux distribution autodetection failed”;noneis the documented way past that. The daemon’s start-up script is KDOS’s own, underfs/etc/init.d.--with-systemdsystemunitdir=no— Install no systemd unit files. Without it configure asks pkg-config for systemd’s unit directory. KDOS has no systemd.--with-xml=expat— Parse.servicefiles in/etc/avahi/serviceswith expat, and fail configure if it is missing, instead of taking whichever of expat and bsdxml it finds first.--with-avahi-user=avahi— The accountavahi-daemondrops to, with--with-avahi-group,--with-autoipd-userand--with-autoipd-groupnaming the rest:avahiandavahi-autoipd, the names upstream defaults to, stated so the build matches the two accountspostinstall.shcreates.--with-avahi-priv-access-group=wheel— The group whose members the daemon’s D-Bus policy lets call every method,SetHostNameamong them; anyone else may browse, resolve and publish. Upstream’s default isnetdev, a Debian group KDOS does not have, so the policy would name a group that does not exist and the bus would log the unknown group at every start.wheelis the group of the users who administer the machine.--enable-dbus— Build the daemon’s D-Bus interface andlibavahi-client, which talks to it. CUPS, gvfs, geoclue and thelibdns_sdcompatibility library all reach the daemon throughlibavahi-client.--enable-gdbm— Buildavahi-browse’s lookup of human-readable service type names in a GDBM database. configure stops if GDBM is missing.--enable-glib— Buildlibavahi-glib, the adapter that runs Avahi’s callbacks on a GLib main loop, and with--enable-gobjectlibavahi-gobject, its GObject wrapper.--disable-qt3— Build none of the toolkit front ends: neither the Qt 3, Qt 4 nor Qt 5 main loop adapters (--disable-qt4,--disable-qt5) nor the GTK 2 and GTK 3 libraries and programs (--disable-gtk,--disable-gtk3). The GTK 3 one cannot be built at all, because GTK 3 depends on CUPS, which depends on Avahi.--disable-mono— Build no Mono (.NET) bindings, and with--disable-monodocno documentation for them. The tree has no Mono.--disable-python— Install none of Avahi’s Python programs (avahi-discover,avahi-bookmarks) and, with--disable-pygobject, nothing that needs PyGObject.--disable-introspection— Generate no GObject introspection data forlibavahi-gobject.--disable-libevent— Build nolibavahi-libeventmain loop adapter; configure would otherwise require libevent through pkg-config.--disable-libsystemd— Do not link libsystemd, through which the daemon would take its sockets from socket activation and report its state withsd_notify.--disable-doxygen-doc— Generate no API reference with Doxygen.--enable-compat-libdns_sd— Installlibdns_sdanddns_sd.h, an implementation of Apple’s Bonjour (mDNSResponder) client API on top of Avahi. Upstream leaves it off; mumble’s zeroconf support finds it asavahi-compat-libdns_sd.--disable-compat-howl— Build no compatibility library for the HOWL API. It is upstream’s default.--disable-tests— Build no test or example programs. It is upstream’s default.--enable-libdaemon— Linkavahi-daemonagainst libdaemon for its PID file and signal handling. It is the default, and configure fails without libdaemon.
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.