108.7. radicale-3.8.1
A CalDAV and CardDAV server — shared calendars and contacts on a LAN with no internet
| Version | 3.8.1, release 1 |
| Shelf | servers — Daemons that serve other machines: remote shell, web, mail, XMPP, IRC, CalDAV/CardDAV, SMB and DLNA |
| Phase | 41_system (System), 945 of 1047 in build order |
| Licence | GPL-3.0-or-later |
| Homepage | https://radicale.org/ |
| Build time | 0.3 SBU |
| Installed size | 4.5 MiB in 394 files |
| Recipe | ports/core/servers/radicale/kpkgbuild |
About
Radicale is a small CalDAV and CardDAV server written in Python: shared calendars, task lists and address books for the machines on a LAN, with no account anywhere outside it. It keeps everything as files under /var/lib/radicale/collections. The package adds a service script, 77_radicale, which runs it under the supervisor as the radicale account; other machines reach it on port 5232 once the firewall’s caldav name is on (see Opening a service).
Sources
radicale-3.8.1.tar.gz(263.4 KiB)
sha256a2668ebc35db2a87c7b1948374c7d3878a7047513c765775a0d1f250dc52ff30
upstream: https://files.pythonhosted.org/packages/source/r/radicale/radicale-3.8.1.tar.gz
archive copy: sources-4/servers--radicale-3.8.1.tar.gzradicale-vendor-3.8.1.tar.xz(3.4 MiB)
sha2565acce056695a622a018e82ac77e198085dc4ca1068a5e6c1a115e13fb086fe84
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-4/servers--radicale-vendor-3.8.1.tar.xz
Dependencies
Depends on: python3, python3-setuptools, python3-pip, python3-hatchling, python3-requests, python3-packaging, python3-dateutil, python3-pytz, python3-six, util-linux.
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 radicale'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/servers/radicale.
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/radicale
echo 'a2668ebc35db2a87c7b1948374c7d3878a7047513c765775a0d1f250dc52ff30 radicale-3.8.1.tar.gz' | sha256sum -c -
echo '5acce056695a622a018e82ac77e198085dc4ca1068a5e6c1a115e13fb086fe84 radicale-vendor-3.8.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/radicale
SRC=$SRC_ROOT/radicale-3.8.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf radicale-3.8.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 pyrequirements, pyruntime and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
_home=/usr/lib/radicale
mkdir -p vendor
tar -xf $PORT_SRC/$name-vendor-$version.tar.xz --strip-components=1 -C vendor
pip3 install --no-deps --no-index --find-links=vendor --no-build-isolation \
--ignore-installed --root=$PKG --prefix=$_home \
defusedxml libpass vobject .
install -d "$PKG/usr/bin"
cat > "$PKG/usr/bin/radicale" <<'KDOS_SH'
#!/bin/sh
home=/usr/lib/radicale
site=$(python3 -c 'import sys, sysconfig; print(sysconfig.get_path("purelib", vars={"base": sys.argv[1]}))' "$home") || exit 1
PYTHONPATH=$site${PYTHONPATH:+:$PYTHONPATH}
export PYTHONPATH
exec "$home/bin/radicale" "$@"
KDOS_SH
chmod 755 "$PKG/usr/bin/radicale"
install -Dm644 config "$PKG/usr/share/doc/radicale/config.example"
install -Dm644 rights "$PKG/usr/share/doc/radicale/rights.example"
install -Dm644 /dev/stdin "$PKG/etc/radicale/config" <<'CFG'
[server]
hosts = 0.0.0.0:5232, [::]:5232
[auth]
type = htpasswd
htpasswd_filename = /etc/radicale/users
htpasswd_encryption = autodetect
[rights]
type = owner_only
[storage]
filesystem_folder = /var/lib/radicale/collections
CFG
install -dm750 "$PKG/var/lib/radicale"
install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/77_radicale.sh" <<'KDOS_SH'
#!/bin/bash
. /etc/init.d/service_helper
NAME="radicale"
DAEMON="/usr/bin/radicale"
USERS="/etc/radicale/users"
case "$1" in
start)
[ ! -x "$DAEMON" ] && { echo "[SKIP] $NAME: $DAEMON not found"; exit 0; }
if ! getent passwd radicale >/dev/null; then
echo "[SKIP] $NAME: no radicale account (the port's postinstall makes it)"
exit 0
fi
if ! grep -q '^[^#].*:' "$USERS" 2>/dev/null; then
echo "[SKIP] $NAME: no account in $USERS (name:\$(openssl passwd -6))"
exit 0
fi
echo "[KDOS] Starting $NAME..."
supervise "$NAME" setpriv --reuid=radicale --regid=radicale \
--init-groups "$DAEMON" --config /etc/radicale/config
;;
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/77_radicale.sh"
The switches, and why each is set:
--prefix=$_home— Install Radicale and the three Python packages it needs from its bundle into a prefix of its own,/usr/lib/radicale, instead of the sharedsite-packages. vobject is also vendored intosite-packagesby khard, and two packages owning one path is a conflict that stops the install; under the prefix nothing else can own defusedxml, libpass or vobject (see Who owns a file).--no-deps,--no-index,--find-links=vendor— Install exactly the named distributions from the unpacked bundle and nothing from the network. requests, packaging, dateutil, pytz and six are ports, found in the sharedsite-packagesthroughdepends.--no-build-isolation— Build with the hatchling and setuptools already in the build root.
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 '^radicale:' "$root/etc/group" 2>/dev/null || groupadd -R "$root" -r radicale
grep -q '^radicale:' "$root/etc/passwd" 2>/dev/null || \
useradd -R "$root" -r -g radicale -d /var/lib/radicale -s /sbin/nologin radicale
# chown resolves a name against the running root's passwd, so the ids are read
# out of PKG_ROOT's.
# The mode is set as well: kpkgadd creates every directory 0755, whatever mode
# it was packaged with, because the package carries no group to give it.
while IFS=: read -r n _ uid gid _; do
[ "$n" = radicale ] || continue
chown "$uid:$gid" "$root/var/lib/radicale"
chmod 750 "$root/var/lib/radicale"
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/radicale, 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 radicale-3.8.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/radicale, and runs the triggers its paths call for.
Contents
Installed programs: radicale.
Installed directories: /etc/radicale, /usr/lib/radicale, /usr/share/doc/radicale, /usr/share/licenses/radicale, /var/lib/radicale.
Notes
The bundle, radicale-vendor-<version>.tar.xz, is what the recipe’s pypackages key names: defusedxml, libpass and a pinned vobject, downloaded without resolving dependencies, plus their build requirements (see The three Python keys). vobject is pinned below its latest release, which reads its own version by importing the package; that imports dateutil, and the isolated environment in which a source-only download builds metadata has no dateutil, so the fetch fails. The pinned release declares its version statically.
pika, which Radicale declares, is imported only by its RabbitMQ hook, a plugin loaded by name from the configuration. There is no RabbitMQ port for it to talk to, and pika is not installed.
/usr/bin/radicale is a wrapper script: it asks Python for the site-packages path under /usr/lib/radicale, puts it on PYTHONPATH, and runs the real entry point from /usr/lib/radicale/bin.
The shipped /etc/radicale/config serves the LAN with accounts. Upstream’s default listens on localhost and lets no one in; this one listens on every address on port 5232, takes accounts from /etc/radicale/users, one name:hash line each (a hash that openssl passwd -6 writes), and names upstream’s owner_only rights outright, so each account reaches only its own collections. Upstream’s full config and rights examples go to /usr/share/doc/radicale/.
The service skips itself until the radicale account exists and /etc/radicale/users has a line: with no account there is nobody to let in, and the port would otherwise be held open for nothing. setpriv runs Radicale as its account; it stays in the foreground and logs to standard error, which the supervisor keeps.
postinstall.sh creates the account and group and gives it /var/lib/radicale with mode 750. The mode is set there because kpkgadd creates every directory 0755, whatever mode it was packaged with. Like the other server ports it writes under PKG_ROOT and reads the ids from that root’s own passwd.