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

108.6. prosody-13.0.6

XMPP chat server, written in Lua

Version 13.0.6, release 1
Shelf servers — Daemons that serve other machines: remote shell, web, mail, XMPP, IRC, CalDAV/CardDAV, SMB and DLNA
Phase 41_system (System), 944 of 1047 in build order
Licence MIT
Homepage https://prosody.im/
Build time 0.1 SBU
Installed size 2.2 MiB in 280 files
Recipe ports/core/servers/prosody/kpkgbuild

About

Prosody is an XMPP (Jabber) chat server written in Lua. On a LAN with no route beyond it, it lets people on the same network talk to each other; dino is the graphical client that speaks to it. The package adds a service script, 74_prosody, which runs the server under the supervisor as the prosody account; other machines reach it once the firewall’s xmpp name is on (see Opening a service).

Prosody’s configure accepts none of the Lua versions as new as the tree’s main lua, so it is built against and runs on the parallel lua54 port, with the Lua libraries it needs built for that version (lua54-luasocket, lua54-luasec, lua54-luaexpat, lua54-luafilesystem).

Why it is in KDOS

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

The only entry in this tree that CREATES comms rather than reading somebody else's archive: a LAN XMPP server, two people on one stick with no network beyond the room. Dino is the graphical client.

Sources

Dependencies

Depends on: lua54, lua54-luasocket, lua54-luasec, lua54-luaexpat, lua54-luafilesystem, openssl, libidn.

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

What kpkg does

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

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/servers/prosody
echo 'ec696f9cf562c3af4a04b07d3fb36a1cedcc4e69a392fddcfc524bc67d93050f  prosody-13.0.6.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/prosody
SRC=$SRC_ROOT/prosody-13.0.6
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf prosody-13.0.6.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 _lv and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

./configure --prefix=/usr --sysconfdir=/etc/prosody \
	--datadir=/var/lib/prosody \
	--lua-version=$_lv \
	--with-lua-bin=/usr/bin \
	--with-lua-include=/usr/include/lua$_lv \
	--with-lua-lib=/usr/lib \
	--lua-suffix=$_lv \
	--idn-library=idn \
	--with-random=getrandom \
	--no-example-certs \
	--add-cflags="$CFLAGS" \
	--add-ldflags="$LDFLAGS"
make
make DESTDIR=$PKG install

install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/74_prosody.sh" <<'KDOS_SH'
#!/bin/bash
. /etc/init.d/service_helper

NAME="prosody"
DAEMON="/usr/bin/prosody"

case "$1" in
    start)
        [ ! -x "$DAEMON" ] && { echo "[SKIP] $NAME: $DAEMON not found"; exit 0; }
        if ! getent passwd prosody >/dev/null; then
            echo "[SKIP] $NAME: no prosody account (the port's postinstall makes it)"
            exit 0
        fi
        # Accounts live at <data>/<host>/accounts/<user>.dat; the first is
        # made with `prosodyctl adduser <user>@<host>`.
        if ! compgen -G '/var/lib/prosody/*/accounts/*.dat' >/dev/null; then
            echo "[SKIP] $NAME: no account yet (prosodyctl adduser makes one)"
            exit 0
        fi
        echo "[KDOS] Starting $NAME..."
        supervise "$NAME" setpriv --reuid=prosody --regid=prosody \
            --init-groups "$DAEMON" -F
        ;;
    stop)   stop_service "$NAME" ;;
    status) check_status "$NAME" ;;
    *)      echo "Usage: $0 {start|stop|status}"; exit 1 ;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/74_prosody.sh"

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:

# 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 '^prosody:' "$root/etc/group" 2>/dev/null || groupadd -R "$root" -r prosody
grep -q '^prosody:' "$root/etc/passwd" 2>/dev/null || \
	useradd -R "$root" -r -g prosody -d /var/lib/prosody -s /sbin/nologin prosody

# chown resolves a name against the running root's passwd, so the ids are read
# out of PKG_ROOT's.
while IFS=: read -r n _ uid gid _; do
	[ "$n" = prosody ] || continue
	chown "$uid:$gid" "$root/var/lib/prosody"
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/prosody, 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 prosody-13.0.6-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/prosody, and runs the triggers its paths call for.

Contents

Installed programs: prosody, prosodyctl.

Installed directories: /etc/prosody, /usr/lib/prosody, /usr/share/licenses/prosody, /var/lib/prosody.

Short descriptions

prosodyctl Manage a Prosody XMPP server

Notes

prosody refuses to start as root and never drops privileges itself (only prosodyctl does), so the service script runs it through setpriv --reuid=prosody --regid=prosody --init-groups, with -F to keep it in the foreground where the supervisor can watch it.

The service skips itself, with a [SKIP] line, until the prosody account exists and until at least one XMPP account does, as a file under /var/lib/prosody/<host>/accounts/. The first is made with prosodyctl adduser <user>@<host>. The shipped configuration serves localhost with registration off, so a server with no account has nobody to let in, and every machine carrying the port would otherwise hold ports 5222 and 5269 open behind the firewall for nothing.

postinstall.sh creates the prosody group and system account unless they exist and gives it /var/lib/prosody. It writes under PKG_ROOT, reads that root’s /etc/passwd and /etc/group itself rather than asking getent, which would answer for the running system, and takes the numeric ids from PKG_ROOT’s own passwd, because chown would resolve a name against the running system’s.