358.4. kdos-discover-0.1.0
Discover backend for packs, boxes and ports, and the A/B update tray notifier
| Version | 0.1.0, release 1 |
| Source tree | src/desktop/kdos-discover/ |
| Phase | 50_desktop (Desktop), 57 of 92 in build order |
| Licence | MIT |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.6 SBU |
| Installed size | 1.2 MiB in 12 files |
| Recipe | src/desktop/kdos-discover/kpkgbuild |
About
kdos-discover is what makes Discover KDOS’s software centre. It installs five things:
kdos-backend.so, a Discover backend in/usr/lib/qt6/plugins/discover/. It lists software under six origins:Origin What it lists kdos-packsthe packs in the pack store, and the catalogue rows whose pack is there mediumthe packs and .ktarsets on the boot medium, and the rows whose pack is only therekdos-storethe rows with no pack anywhere, the catalogue’s sets, and the Debian desktop applications the catalogue does not name kdos-boxesboxes nothing else accounts for kdos-portshost software kdos-ports-sourceeach binhost port not installed, offered built on this computer It also opens a
.ktaror.kpackhanded to Discover from a file manager. Every answer comes from the tool that owns it:kdos-appbox cataloguesays what is installed,kdos-box listwhat each box is made of, kdos-packd’s socket what the pack store and the medium hold,kpkg listwhich ports are installed,kdos-box profilewhat a box is allowed, asked only when its page opens. An install or a removal is a list of argument vectors and kdos-packd requests, run one transaction at a time, with no shell. A catalogue row whose pack is already in the store or on the medium becomes a box over that pack, offline; only a row with no pack anywhere is built by the store lane, which reaches the Debian archive and says so before it starts.KdosNotifier.so, indiscover-notifier/, the plugin that puts the A/B system update in Discover’s tray. It reads kdos-sysupdated’s io.kdos.Slots1 State for the offered version, the update job in progress and a slot armed with a newer version and waiting for a restart, with the running slot’s version from its ListSlots,kdos cve --jsonfor the known vulnerabilities an update closes, and, when kdos-sysupdated does not answer,/var/lib/kdos/update.jsonandkdos-bootctl status --jsonin its place; it fetches nothing.kdos-discover-catalog, which writes/usr/share/swcatalog/xml/kdos-ports.xml, the AppStream catalogue of the host’s ports, from kpkg’s manifests, and, with--debian-exclude,kdos-debian-exclude.xml, theremove-componentmerges that take the applicationsdebian-excludenames out of every AppStream pool.kdos-ports-helper, the root step behind installing host software prebuilt from the signed binhost, run throughpkexecunder the polkit actionio.kdos.ports.install, and behind removing a port installed on request, underio.kdos.ports.remove.kdos-ports-builder, the root step behind building host software on this computer, thekdos-ports-sourceorigin, run throughpkexecunderio.kdos.ports.build.
It also points Discover’s featured list at /usr/share/kdos/discover/featured.json, ships /usr/share/kdos/discover/debian-exclude, the Debian packages the backend never offers to build in a box, and defines the MIME types application/vnd.kdos.ktar and application/vnd.kdos.kpack with a hidden desktop entry that opens both in Discover. How Discover, the backend and the system update fit together is in Discover.
Why it is in KDOS
The comment above it in script/phases/50_desktop/packages.txt:
Discover's backend for packs, boxes and ports, and the A/B update notifier.
Sources
None: the port builds from its own directory, /kdos/src/desktop/kdos-discover.
Dependencies
Depends on: cmake, ninja, extra-cmake-modules, qt6-qtbase, kcoreaddons, kconfig, ki18n, karchive, kservice, kio, kjobwidgets, appstream, debian-dep11, qcoro, discover, polkit, kdos-appbox, kdos-pack, kdos-tools.
Required by (2): kde-plasma, kdos-welcome.
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-discover'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/desktop/kdos-discover.
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-discover
SRC=$SRC_ROOT/kdos-discover-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"
cmake -S "$PORT_SRC" -B build -G Ninja \
-D CMAKE_INSTALL_PREFIX=/usr \
-D KDE_INSTALL_LIBDIR=lib \
-D CMAKE_BUILD_TYPE=Release \
-D KDE_INSTALL_USE_QT_SYS_PATHS=ON \
-D BUILD_TESTING=OFF \
-D KF_SKIP_PO_PROCESSING=ON \
-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build
gcc $CFLAGS -O2 -std=gnu11 -D_GNU_SOURCE -Wall -Wextra \
-I"$LIBS/libkbase" \
-o kdos-ports-helper "$PORT_SRC"/helper/kdos-ports-helper.c "$LIBS"/libkbase/*.c $LDFLAGS
gcc $CFLAGS -O2 -std=gnu11 -D_GNU_SOURCE -Wall -Wextra -DKPH_BUILD \
-I"$LIBS/libkbase" \
-o kdos-ports-builder "$PORT_SRC"/helper/kdos-ports-helper.c "$LIBS"/libkbase/*.c $LDFLAGS
install -Dm755 kdos-ports-helper "$PKG/usr/libexec/kdos-discover/kdos-ports-helper"
install -Dm755 kdos-ports-builder "$PKG/usr/libexec/kdos-discover/kdos-ports-builder"
install -Dm644 "$PORT_SRC"/helper/io.kdos.ports.policy "$PKG/usr/share/polkit-1/actions/io.kdos.ports.policy"
The switches, and why each is set:
-D BUILD_TESTING=OFF— Build no tests here. The tests intests/read fixtures of every tool’s output and need Qt’s test library;testing/plasmatest.shbuilds and runs them in the development container.-D KF_SKIP_PO_PROCESSING=ON— Install no translations; the image is English only. Every string still goes throughi18n()under the domainkdos-discover.-D KDE_INSTALL_USE_QT_SYS_PATHS=ON— Install the two plugins under Qt’s own plugin directory,/usr/lib/qt6/plugins, where Discover’s loaders look fordiscover/anddiscover-notifier/.-I"$LIBS/libkbase","$LIBS"/libkbase/*.c—kdos-ports-helperandkdos-ports-builderare C, compiled with libkbase for its argument-vector runner, and link no Qt.$LIBSissrc/libs.-DKPH_BUILD— Compileshelper/kdos-ports-helper.ca second time askdos-ports-builder, which runskdos update install --sourcewhere the helper runs--prebuilt. pkexec picks the polkit action by the program’s path, so the two routes are two programs, each under its own action:io.kdos.ports.buildasks for the password every time, because the build runs a recipe’sbuild.shas root, and a grant kept from a prebuilt install must not cover it.
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-discover, 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-discover-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-discover, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: CMakeLists.txt, backend/, catalog/, data/, helper/, model/, notifier/, tests/.
Contents
Installed programs: kdos-discover-catalog.
Installed directories: /usr/lib/qt6/plugins/discover-notifier, /usr/libexec/kdos-discover, /usr/share/discover, /usr/share/kdos/discover.
Notes
It is locked to one discover release. libdiscover is private: Discover installs no header and promises no ABI, and both plugin interfaces carry discover’s full version in their IID (
org.kde.discover.6.8.2.AbstractResourcesBackendFactory). Discover’s loaders skip a plugin whose IID differs with nothing but a debug line, so a stale build simply vanishes from Discover. The discover recipe copies libdiscover’s headers to/usr/include/discover, andCMakeLists.txtrefuses to configure against any discover butKDOS_DISCOVER_VERSION. A discover bump, a point release included, therefore rebuilds this port: re-test the backend and the notifier against the new headers and change that line.Nothing downloads. A refresh asks local tools and reads local files, and Discover’s “Check for updates” is the same refresh. Screenshots are shown only when they are files on the machine. The Debian lane’s metadata is the DEP-11 catalogue debian-dep11 installs under
/usr/share/swcatalog, read lazily: a resource is made for a Debian application only when a search or a category asks for it, or when its box exists.A link waits for the machine to be read. Discover asks for the featured list’s
kdos-backend://links and for KRunner’sappstream://links as soon as the backend loads, before its first refresh lands; the backend answers each once that refresh has, and anappstream://link once the AppStream pool has loaded too, so neither is answered “no entry”.Every resource has an
appstreamId. Discover’s lists drop every resource whoseappstreamIdan earlier one in the list has, so a resource with no AppStream component getsio.kdos.<lane>.<id>; its link stayskdos-backend://<lane>/<id>.Debian applications need kdos-appbox’s
deb:form.install deb:<package>anduninstall deb:<package>build and remove a box nameddeb.<package>, with each+in the package name spelled_; the backend reads that name back to tell a Debian application installed.Host software is read-only here until a binhost is fetched, and removable only when asked for. The
kdos-portslane lists what is installed. A port of the image has no line in/var/lib/kdos/worldand is part of the system, as is one an installed package depends on; only a world port nothing installed needs, whichkdos update removable --jsonnames at each refresh, gets Remove, which runskdos update remove --dry-runas the user, asks “Remove?” when it prints remove <port>, and only on a yes runskdos-ports-helper removeunderio.kdos.ports.remove. Oncekdos update fetchhas put the release’s signed binhost index and its catalogue in/var/lib/kdos/binhost, a port that catalogue lists can be installed, prebuilt or built here.A port the binhost holds is two resources with one AppStream id,
kdos-portsandkdos-ports-source, installed or not, so Discover lists one application with two origins in its source picker; Discover’s application page keeps the most sources it has seen while it is open, and a twin that came and went with the install would leave it after a removal with no picker. Which of two resources with one id a Discover list keeps is its sort’s, not the backend’s, so a list carries only the oneinstall =in/etc/kdos/update.confprefers, thekdos-portsone once the port is installed, and a link answers both, that one first.Before
pkexec, the plan runs the install’s--dry-runas the user and asks throughTransaction::proceedRequest, so the counts come before the password.kdos-ports-helperchecks the name, clears the environment pkexec handed it and runskdos update install --prebuilt <port>;kdos-ports-builderdoes the same with--source, passing--build-deps=only when given one, sobuild-deps =in/etc/kdos/update.confdecides otherwise. Both setKDOS_UPDATE_FRONT=discover, so a cut download’s words name the Install button, and the builder copies the run’s output into/var/log/kdos-build/<port>.log, kept on a failure and named underKDOS_UPDATE_LOGat the end of the failed build’s line, since a failed build’s work directory is removed.kdos update installowns the route: the binhost download and its checks, the build under/etc/kdos/chroot.env’s environment, the origin file and the world set. Then the helper writes the catalogue again. The helpers are separate programs because pkexec’s grant names a program and at most its first argument: granting/usr/bin/kdoswould grant every subcommand. The helper’s two actions each name their verb inexec.argv1, since pkexec takes the first action that matches and one naming the path alone would match either verb.The helper’s standard input is its cancel. After pkexec the helper is root, and Discover’s SIGTERM to its process group is refused, so a build would go on until its next write met a closed pipe. The transaction starts every step with an open stdin pipe and Cancel closes it; the helper runs
kdos updatein a process group of its own with/dev/nullfor input, and on end of file or a hang-up on stdin (or SIGTERM, SIGINT, SIGHUP to itself) sends SIGTERM to that group, SIGKILL after 60 seconds, waits for the group to be gone, writes no catalogue and exits 130 with==> <port>: cancelled. The transaction ends Cancelled only on the process’s exit, so the backend’s refresh never meets a run still holding the package lock.Before the helper’s first line pkexec itself may end the step: 126 for a dismissed password dialog, which ends the transaction Cancelled, and 127 with “Error executing command as another user: Not authorized”, which ends it Cancelled with a passive message: KDE’s agent answers Cancel with that line, and so does polkit refusing the account, so the message names both. Any other 127, “No authentication agent found.” among them, is a failure with pkexec’s line, and the SetupStatus guard keeps a 126 or 127 from the helper itself a failure. A helper started with stdin on
/dev/nullcancels at once. The backend test’s fake helper ignores SIGTERM, as a root one does, and leaves only when stdin closes.Host software is read from its two catalogue files, not from the AppStream pool. The pool keys every component of the OS catalogue by a data id with the origin
os, soorg.kde.katefromkdos-ports.xmlandorg.kde.katefrom Debian’s DEP-11 file would be one component, whichever loaded last. The backend parseskdos-ports.xmland each binhost’skdos-binhost.xmldirectly at every refresh, keeps the pool for the Debian lane’s search and categories, and never offers in a box a Debian application whose component id a host port already has.The exclusion list reaches KRunner only through the pool. KRunner’s software results search the AppStream pool themselves, so the backend’s own filter does not reach them; the image step
086_swcatalog.shrunskdos-discover-catalog --debian-excludeto write theremove-componentmerges that take each listed application out of the pool. A merge removes every lower-priority component of its id, a host port’s inkdos-ports.xmlincluded, which costs nothing: the backend readskdos-ports.xmlitself, and KRunner offers no installed application. It is written at the image step and not inbuild.sh, because the DEP-11 catalogue it reads is in the build tree but not in the development container that builds this port forplasmatest.The catalogue is written wherever packages change.
kdos-discover-catalogrewrites the whole ofkdos-ports.xmlfrom kpkg’s manifests: a port’s own metainfo is its component, given the package name, and a desktop entry no metainfo launches is read by libappstream’s desktop-entry reader. The image step runs it once over the finished tree. A component with no licence or homepage takes its recipe’slicense =andhomepage =from the firstkpkgbuildof the port under<root>/ports/core,<root>/ports/srcor<root>/kdos/src(the 70_image chroot binds the ports tree at/portsand the repository at/kdos). A component with no untranslated name takes its desktop entry’sName(for metainfo, the first entry it launches); one with no summary takes the entry’sComment, else aGenericNamethat is not its name, else the recipe’sdescription =, read from the samekpkgbuild. Every component read from a bare desktop entry carries the custom valueKDOS::BareEntry=1and no other component carries the key, and in a catalogue with any such value the backend tells a suite’s face, LibreOffice’s start centre, by that mark alone, never by a missing licence, which no component with a recipe lacks. A catalogue with no mark anywhere, which is what the published binhost’s is and what a freshly installed machine reads untilkdos update fetchbrings its own release’s, is read by what a desktop entry lacks: a desktop application with a.desktopid and no description, which the desktop-entry reader never writes, is a bare entry; read by the mark alone, it would list LibreOffice as Base. The developer is copied only from a metainfo file the package installs, never made up; Discover says “Unknown author” otherwise.The install confirmation counts the cache.
kdos update install --dry-run’stotalcounts every prebuilt package and only the bytes not yet in/var/lib/kdos/binhost, so a total with no bytes is said as “already downloaded”, never as a download of 0 bytes.