357.1. kdos-sysupdated-0.1.0
org.freedesktop.sysupdate1 and io.kdos.Slots1 over the A/B root slots, for Discover
| Version | 0.1.0, release 1 |
| Source tree | src/daemons/kdos-sysupdated/ |
| Phase | 50_desktop (Desktop), 61 of 92 in build order |
| Licence | MIT |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.1 SBU |
| Installed size | 139.5 KiB in 5 files |
| Recipe | src/daemons/kdos-sysupdated/kpkgbuild |
About
kdos-sysupdated is the root daemon that lets Plasma’s Discover install a KDOS system update. It owns org.freedesktop.sysupdate1 on the system bus and answers the calls Discover’s stock SystemdSysupdate backend makes: one target, host; its version; an AppStream file describing the update; the newest version (CheckNew); then Acquire, which does all the long work and reports its progress, and Install, which arms the filled slot for the next boot. It does none of that work itself. Every check, download and install is a kdos update run (check --fetch, apply --acquire --mount, apply --arm --mount) and every boot decision a kdos-bootctl run, each exec’d with an argument vector and read through a progress pipe while the bus keeps answering. See Updating a machine and A/B slot selection.
It also serves io.kdos.Slots1, whose contract is the System Versions page’s io.kdos.Slots1.xml: the slots, the armed trial, the update channel, the install route (install = and build-deps = of /etc/kdos/update.conf), Try, CancelTry, SetChannel, SetInstallRoute and Bless. And it is the root half of the session-confirmed boot: it runs kdos-bootctl mark-good once /run/kdos/bless/ holds both the mark the end of rcS writes and the one a Plasma session (through Bless) or a login greeter that stayed up for a minute earns.
The port is KDOS’s own C on basu, with no upstream source; build.sh compiles the daemon with libkbase and installs it beside its bus policy, its two polkit action files and the packaged AppStream file.
Why it is in KDOS
The comment above it in script/phases/50_desktop/packages.txt:
org.freedesktop.sysupdate1 and io.kdos.Slots1 over the A/B root slots: what Discover's system updates and the slots page ask.
Sources
None: the port builds from its own directory, /kdos/src/daemons/kdos-sysupdated.
Dependencies
Depends on: basu, dbus, polkit, kdos-tools.
Required by (2): kcm-kdos-system, kde-plasma.
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/50_desktop/phase.env && kpkg install kdos-sysupdated'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/daemons/kdos-sysupdated.
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.
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/kdos-sysupdated
SRC=$SRC_ROOT/kdos-sysupdated-0.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
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:
LIBS="$PORT_SRC/../../libs"
gcc $CFLAGS -O2 -std=gnu11 -D_GNU_SOURCE -Wall -Wextra \
$(pkg-config --cflags basu) -I"$LIBS/libkbase" \
-o kdos-sysupdated "$PORT_SRC"/*.c "$LIBS"/libkbase/*.c \
$(pkg-config --libs basu) $LDFLAGS
install -Dm755 kdos-sysupdated "$PKG/usr/sbin/kdos-sysupdated"
install -Dm644 "$PORT_SRC/kdos-sysupdated.conf" \
"$PKG/usr/share/dbus-1/system.d/kdos-sysupdated.conf"
install -Dm644 "$PORT_SRC/org.freedesktop.sysupdate1.policy" \
"$PKG/usr/share/polkit-1/actions/org.freedesktop.sysupdate1.policy"
install -Dm644 "$PORT_SRC/io.kdos.slots.policy" \
"$PKG/usr/share/polkit-1/actions/io.kdos.slots.policy"
install -Dm644 "$PORT_SRC/io.kdos.system.metainfo.xml" \
"$PKG/usr/share/kdos/update/io.kdos.system.metainfo.xml"
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/kdos-sysupdated, 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 kdos-sysupdated-0.1.0-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/kdos-sysupdated, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: appstream.c, bless.c, bus.c, io.kdos.slots.policy, io.kdos.system.metainfo.xml, job.c, json.c, kdos-sysupdated.conf, main.c, org.freedesktop.sysupdate1.policy, polkit.c, state.c, sysupdated.h, tests/.
Contents
Installed programs: kdos-sysupdated.
Installed directories: /usr/share/kdos/update.
Notes
- It is tested against Discover’s own XML.
tests/org.freedesktop.sysupdate1.xmlis discover-6.8.2’slibdiscover/backends/SystemdSysupdateBackend/org.freedesktop.sysupdate1.xml, byte for byte, the file Discover generates its proxies from.testing/selftest.shruns the daemon on a private bus with--session --rootover fixture slots and diffs its introspection against that file and against the Slots1 contract. The sysupdate1 API is not stable upstream, so every Plasma bump replaces the vendored copy with the new Discover’s and reruns the selftest. - Acquire answers only after
kdos updatehas saidverifiedorrefused. Discover shows a failed call’s message and a failed job as nothing but “failed”, so a release index, binhost index or image manifest no trusted key signed, a package the binhost does not cover, or a slot that cannot be mounted reaches the person as the call’s error, and only an update that can go ahead becomes a job. - A
CheckNewthat polkit does not allow is answered from the document on disk. The offer is the update document’s, which every account reads, soorg.freedesktop.sysupdate1.checkguards only the fetch: a caller it denies or challenges is answered without one, never with an error Discover would raise as “Update Issue”. CheckNewoffers only what the release index named. A fetch takes the release’s signedkdos-update.idxfirst and the binhost index and slot image manifest only where it says, with the hash it gives; the offer in the update document is made from those alone. See Packaging.- The update is a slot image or binhost packages, whichever
kdos update checkoffered. The daemon passes no lane tokdos update apply; the update document’slaneonly changes the AppStream text, which names the signed system image or the packages. - The size travels in the AppStream file. The size still to download is in the update document; the AppStream text Discover shows above the release notes states it, and the offered release carries it as an artifact’s download size, which discover’s
sysupdate-size.patchreads for the Updates list. Nothing listens on localhost:3129, the size service Discover asks when no artifact names a size. - A trial boot is offered nothing. While this boot is the trial of the other slot, the slot an update would fill is the confirmed way back;
CheckNewanswers empty andAcquireis refused until the trial is confirmed or rolled back. - No D-Bus activation file.
/etc/init.d/46_sysupdated.shsupervises the daemon, and a bus that started a second, unsupervised copy for an early caller would keep the supervised one from its names. - Discover reaches it on the session bus with
DISCOVER_TEST_SYSUPDATE=1, which is wherekdos-sysupdated --session --root <dir>serves it, so the whole flow can be driven without root. - The update document belongs to the root that wrote it.
/var/lib/kdos/update.jsonis in each slot, so the first boot of a slot, or the boot a rollback returns to, finds one written before that root was what it is now. A document whoseinstalledis not the running version offers nothing, and the daemon rewrites it at start withkdos update check --out, which reads the tree and index already on the machine and downloads nothing. - The AppStream file lives on
/run./run/kdos/sysupdate/io.kdos.system.metainfo.xmlis regenerated whenever/var/lib/kdos/update.jsonchanges; the copy in/usr/share/kdos/update/is the fallback that names the system and offers nothing.