199.1. xdg-desktop-portal-1.22.1
Desktop portal D-Bus framework (Wayland screencast / file-picker integration)
| Version | 1.22.1, release 2 |
| Shelf | xdg — freedesktop desktop integration: portals, MIME, desktop entries, AppStream, tray and indicators, notifications, event sounds, script dialogs |
| Phase | 42_graphics (Graphics Stack), 189 of 189 in build order |
| Licence | LGPL-2.1-or-later |
| Homepage | https://github.com/flatpak/xdg-desktop-portal |
| Build time | 0.4 SBU |
| Installed size | 3.0 MiB in 70 files |
| Recipe | ports/core/xdg/xdg-desktop-portal/kpkgbuild |
About
xdg-desktop-portal is the portal front end: it owns org.freedesktop.portal.Desktop on the session bus and forwards each request to the backend kde-portals.conf names for it in a Plasma session: xdg-desktop-portal-kde by default, with xdg-desktop-portal-gtk beside it for Settings, KWallet for the Secret portal and Plasma’s plasmanotify backend, from plasma-workspace, for the Notification portal. Sandboxed applications and boxes reach the desktop through it: file pickers, screen capture, the camera and opening links. It also names the application behind each request, and the permission store keeps a grant per application id.
Sources
xdg-desktop-portal-1.22.1.tar.xz(1.2 MiB)
sha256d4879ddb3d65ff1a8f19187497e6f13dc5d267bcac404a5d501218be355753d3
upstream: https://github.com/flatpak/xdg-desktop-portal/releases/download/1.22.1/xdg-desktop-portal-1.22.1.tar.xz
archive copy: sources-4/xdg--xdg-desktop-portal-1.22.1.tar.xz
Dependencies
Depends on: meson, glib, dbus, pipewire, fuse, json-glib, gst-plugins-base, gdk-pixbuf, python3-docutils, libgudev, bubblewrap, geoclue.
Required by (2): xdg-desktop-portal-gtk, xdg-desktop-portal-kde.
Patches
build.sh applies these; kpkg applies nothing by itself.
camera-leave-pipewire-loop.patch— leave the camera's PipeWire loop before destroying itThe camera portal's GSource enters the PipeWire loop when it is created and leaves it only in its finalize. Nothing drops the camera's own reference, so finalize never runs, and the loop is destroyed still entered: its recursive mutex freed while the main thread holds it. musl keeps every recursive and error-checking mutex a thread holds on that thread's robust list, so the next such lock by the main thread writes through the freed mutex, and faults when its memory has been unmapped. The portal hits it on exit, after losing its bus name or on SIGHUP, and on a PipeWire restart.
Leave the loop and drop the reference in pipewire_remote_destroy_source(), called before the remote is destroyed. The leave is not left to finalize: on a PipeWire restart the source is destroyed from its own dispatch, glib holds a reference until dispatch returns, and finalize would then read the remote already freed.
cgroup-app-id.patch— app-info: read a host app's id from its cgroup without libsystemdA host process's app id comes from the systemd unit it runs in, app[-<launcher>]-<id>-<n>.scope and the like, read with sd_pid_get_user_unit(); built without libsystemd, no host app has an id and the permission store records nothing per application. Without libsystemd the unit is the deepest component of the process's cgroup2 path (/proc/<pid>/cgroup) named the way systemd names an application's unit, and the same parser turns it into the id. The unit-name parser and sd-escape are built whatever the libsystemd option says.
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/42_graphics/phase.env && kpkg install xdg-desktop-portal'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/xdg/xdg-desktop-portal.
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/xdg/xdg-desktop-portal
echo 'd4879ddb3d65ff1a8f19187497e6f13dc5d267bcac404a5d501218be355753d3 xdg-desktop-portal-1.22.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/xdg-desktop-portal
SRC=$SRC_ROOT/xdg-desktop-portal-1.22.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf xdg-desktop-portal-1.22.1.tar.xz -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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 --no-backup-if-mismatch -i "$PORT_SRC/camera-leave-pipewire-loop.patch"
patch -p1 --no-backup-if-mismatch -i "$PORT_SRC/cgroup-app-id.patch"
meson setup build --buildtype=release \
--prefix=/usr --sysconfdir=/etc --libdir=lib --libexecdir=/usr/lib \
-Ddocumentation=disabled \
-Dman-pages=enabled \
-Dgeoclue=enabled \
-Dgudev=enabled \
-Dsystemd=disabled \
-Dflatpak-interfaces=disabled \
-Dtests=disabled \
-Dinstalled-tests=false \
-Dsandboxed-image-validation=enabled \
-Dsandboxed-sound-validation=enabled
meson compile -C build
DESTDIR=$PKG meson install --no-rebuild -C build
rm -rf "$PKG/usr/lib/systemd"
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/xdg-desktop-portal, 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 xdg-desktop-portal-1.22.1-2.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/xdg-desktop-portal, and runs the triggers its paths call for.
Contents
Installed directories: /usr/share/licenses/xdg-desktop-portal.
Short descriptions
xdg-desktop-portal.pc |
Desktop integration portal |
Notes
The camera portal keeps a PipeWire connection whose loop it enters when it attaches the loop’s source to the main context. Upstream leaves the loop only when that source is finalized, which never happens, because nothing drops the camera’s own reference. camera-leave-pipewire-loop.patch leaves the loop and drops the reference in one call, made before the connection is destroyed. Without it the loop’s recursive mutex is freed while the main thread holds it; musl keeps such a mutex on the holding thread’s robust list, and the next recursive lock on the main thread writes into the freed memory. The front end then faults in libc.so as it exits after losing its bus name or on SIGHUP, and when PipeWire restarts under it.
The leave is not left to the source’s finalize. On a PipeWire restart the camera destroys the source from inside that source’s own dispatch, glib keeps a reference until the dispatch returns, and a finalize run then would read the connection the camera has already freed: the front end would fault on every PipeWire restart.
Built without libsystemd, the front end names a host caller’s application from the cgroup its process is in: the deepest component of its cgroup2 path named the way systemd names an application’s unit (app-<launcher>-<id>-<n>.scope), parsed by upstream’s own unit-name parser, which cgroup-app-id.patch builds whatever the systemd option says, so -Dsystemd=disabled stays. Upstream reads the unit with sd_pid_get_user_unit() only, so without the patch every host application has an empty id. With it, a caller still has an empty id unless something placed it in such a scope, and on KDOS nothing does: Plasma starts an application in the login’s own cgroup, and a box’s app-kdos-<box>-<n>.scope is never made because elogind leaves the session’s cgroup.procs root’s. Every caller then shares the empty id and one stored answer; see Host applications and boxes reach the portals unidentified.