376. The software catalogue
This page explains how Discover, the Plasma software centre, knows what the image has installed. Read it if Discover lists no installed software on a fresh machine, or offers an application it then refuses to build.
Discover lists the ports a machine has installed from an AppStream catalogue, /usr/share/swcatalog/xml/kdos-ports.xml, together with kpkg’s database. script/phases/70_image/086_swcatalog.sh writes that catalogue over the finished tree with kdos-discover-catalog, from the kdos-discover port.
On a running system the same program rewrites the file after every install Discover makes. The build installs with kpkg directly and never runs it, so without this step the image would carry no catalogue and Discover would list no installed port.
Under KDOS_IMAGE=base the finished tree is the image stage, so the catalogue names what the base installed. The ports a machine can add are in the binhost’s own catalogue, which 010_binhost.sh writes.
Writing the catalogue
OUT=/usr/share/swcatalog/xml/kdos-ports.xml
if ! command -v kdos-discover-catalog >/dev/null 2>&1; then
echo "[swcatalog] kdos-discover-catalog is not installed — skipping" >&2
exit 0
fi
kdos-discover-catalog --root / --origin kdos-ports --out "$OUT"
script/phases/70_image/086_swcatalog.sh, lines 41–48
Without kdos-discover-catalog the step says so and exits 0: a tree built without the desktop phase has no Discover to read the file.
--root / reads kpkg’s manifests under /var/lib/kpkg/db, which name every file each package installed. From them:
- a package that ships a metainfo file under
/usr/share/metainfogives that component; - a desktop entry that no metainfo of the same package launches becomes a component of its own;
- a desktop entry that is
NoDisplayorHiddenis skipped.
Every component carries the package that owns it, and that package’s version and release. The whole file is written each run, to a temporary name that is then renamed into place.
Checking it
n=$(grep -c '<component[ >]' "$OUT" || true)
if [ "$n" -eq 0 ]; then
echo "FATAL: $OUT lists no application." >&2
exit 1
fi
echo "[swcatalog] $n components in $OUT"
script/phases/70_image/086_swcatalog.sh, lines 50–55
A catalogue with no component means the manifests or the metainfo were not read, and stops the phase. The log ends with the number of components.
Taking excluded Debian applications out of the pool
Discover’s Debian lane builds some applications from Debian’s packages, and refuses the ones that /usr/share/kdos/discover/debian-exclude names. The step’s last command keeps those applications out of every other place that offers software, by writing /usr/share/swcatalog/xml/kdos-debian-exclude.xml:
- It holds one
remove-componentmerge for each desktop application of debian-dep11’s catalogue whose package the exclude list names. - It leaves out an application whose id
kdos-ports.xmlalso has, because a merge removes every component of its id, and would remove the host’s own application with it. - libappstream applies the merges once every catalogue has loaded, so no AppStream pool on the machine holds those applications. KRunner’s software results, which read the pool and nothing else, therefore do not offer one that Discover’s Debian lane would refuse to build.
The writer fails, and the phase with it, when no DEP-11 catalogue is installed or the list names nothing the catalogue has.
Why it runs here
After 040_orphans.sh, so a removed package is not offered as installed, and before 087_gates.sh, 090_initramfs.sh and 110_iso.sh.
What it leaves
/usr/share/swcatalog/xml/kdos-ports.xml and kdos-debian-exclude.xml on the image, files no package owns, which the unowned report subtracts as generated.
See also
- Host software: how Discover reads the catalogue