282.1. kdos-appbox-1.3.0
KDOS alien app runtime and appbox manager
| Version | 1.3.0, release 1 |
| Source tree | src/system/kdos-appbox/ |
| Phase | 43_toolkits (Toolkits), 321 of 344 in build order |
| Licence | MIT |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.3 SBU |
| Installed size | 530.7 KiB in 4 files |
| Recipe | src/system/kdos-appbox/kpkgbuild |
About
kdos-appbox is the KDOS program that runs alien apps, the graphical applications this tree does not compile, each in a rootless podman container of its own. It builds them from the catalogue it ships, creates and enters their boxes, writes the launchers that make them appear in the Start menu as if they were native, and opens files and links in whatever handles them, boxed or native.
One binary dispatches on the name it was started under:
| Name | What it does |
|---|---|
kdos-appbox |
Installs and launches applications |
kdos-box |
Manages boxes |
xdg-open |
Opens files and links |
| any other name | A shim: a link named after an application, which runs it in its box |
The kdos app subcommands run it, every generated launcher calls it, and the session’s warm-up calls it at login.
Under KWin it is also what confines a box. Each box sees a private runtime directory of its own as /run/user/<uid>, holding the tagged Wayland socket kdos-boxsock serves, a bus filtered by xdg-dbus-proxy and the audio sockets, and never the session’s Wayland socket (KWin’s wayland-1) or bus. It also writes
- each boxed launcher, under the id KWin gives the box’s windows;
- one KWin window rule per box, which tints its title bar in the box’s accent;
- a Dolphin service menu that opens a file in a throwaway box;
- the record that brings a session’s boxes back at the next login.
Everything it does is described in kdos-appbox.
The port has no upstream source. build.sh compiles the program’s own files in this directory together with the sources of four KDOS libraries, libkbase, libktui, libkcolor and libkxdg, into one binary that links no library outside the C library; see How the libraries are built.
Why it is in KDOS
The comment above it in script/phases/43_toolkits/packages.d/src-system.txt:
Alien app runtime + appbox manager (src/system, ours); the 91 launchers and the login's box warmup call it. Not a leaf: the Boxes settings page and the Discover backend depend on it.
Sources
None: the port builds from its own directory, /kdos/src/system/kdos-appbox.
Dependencies
Depends on: podman, distrobox, xdg-dbus-proxy, kdos-boxsock, kdos-boxinit, shared-mime-info, xdg-utils.
Required by (2): kcm-kdos-boxes, kdos-discover.
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/43_toolkits/phase.env && kpkg install kdos-appbox'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/system/kdos-appbox.
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-appbox
SRC=$SRC_ROOT/kdos-appbox-1.3.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=c11 -D_GNU_SOURCE -Wall -Wextra \
-I"$LIBS/libkbase" -I"$LIBS/libktui" -I"$LIBS/libkcolor" \
-I"$LIBS/libkxdg" -I"$PORT_SRC" -o kdos-appbox \
"$PORT_SRC/main.c" "$PORT_SRC/util.c" "$PORT_SRC/box.c" \
"$PORT_SRC/catalogue.c" "$PORT_SRC/store.c" \
"$PORT_SRC/app.c" "$PORT_SRC/launchers.c" \
"$PORT_SRC/open.c" "$PORT_SRC/pack.c" \
"$PORT_SRC/box_cmd.c" "$PORT_SRC/rundir.c" "$PORT_SRC/keeper.c" \
"$PORT_SRC/rules.c" "$PORT_SRC/session.c" "$PORT_SRC/throwaway.c" \
"$PORT_SRC/boxtest.c" \
"$LIBS"/libkbase/*.c "$LIBS"/libktui/*.c "$LIBS"/libkcolor/*.c \
"$LIBS"/libkxdg/*.c $LDFLAGS
install -Dm755 kdos-appbox "$PKG/usr/local/bin/kdos-appbox"
install -Dm644 "$PORT_SRC/catalogue" \
"$PKG/usr/share/kdos/appstore/catalogue"
ln -s kdos-appbox "$PKG/usr/local/bin/kdos-box"
ln -s kdos-appbox "$PKG/usr/local/bin/xdg-open"
The switches, and why each is set:
-std=c11— Compiles as ISO C11. It comes after$CFLAGS, so it replaces the tree’s-std=gnu11;-D_GNU_SOURCEbeside it keeps the POSIX and GNU declarations of musl’s headers visible.
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-appbox, 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-appbox-1.3.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-appbox, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: app.c, box.c, box_cmd.c, boxtest.c, catalogue, catalogue.c, kdos-appbox.h, keeper.c, launchers.c, main.c, open.c, pack.c, rules.c, rundir.c, session.c, store.c, throwaway.c, util.c.
Contents
Installed programs: kdos-appbox, kdos-box, xdg-open.
Installed directories: /usr/share/kdos/appstore.
Notes
The binary goes to /usr/local/bin, and so do its two links. /etc/profile puts /usr/local/bin ahead of /usr/bin, and that order is the only thing that makes this xdg-open answer before the script of the same name from xdg-utils, which the port depends on: when it finds no handler at all for a file or a link, it runs that script as /usr/bin/xdg-open. A PATH with /usr/bin first gets the xdg-utils script for every link a program opens. The xdg-open link belongs to this package rather than to the fs/ overlay, so a root never holds the link without the binary that answers to it.
The catalogue, /usr/share/kdos/appstore/catalogue, is data the program reads, and it ships in this package for the same reason: with the file missing, kdos-appbox catalogue, install, export and import stop with cannot read the catalogue, and Discover’s KDOS backend, which asks kdos-appbox catalogue, lists no boxed applications. Editing the catalogue is editing this port, and it rebuilds it.
Three of its depends are programs it runs rather than links: kdos-boxsock for every launch’s tagged socket, kdos-boxinit, which every pack box is created with as its init, and xdg-dbus-proxy, which the box’s keeper runs as its bus. Without any one of them a box does not start, and the launch says which is missing; there is no unconfined fallback. kbuildsycoca6 is run after the launchers are written when it is installed, and is not a dependency: without it the Start menu sees the launchers when kded next rebuilds its cache.
The program is built in the work directory, never in $PORT_SRC, which is the program’s directory in the repository. A port under src/ hashes its whole directory and all of src/libs as its recipe, so editing any of the four libraries, or any other, rebuilds it; see the recipe hash.