173.5. kdos-installer-5.0
KDOS installer — the terminal wizard and the headless backend, C with no libraries
| Version | 5.0, release 1 |
| Source tree | src/system/kdos-installer/ |
| Phase | 41_system (System), 964 of 1047 in build order |
| Licence | MIT |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.3 SBU |
| Installed size | 550.8 KiB in 1 file |
| Recipe | src/system/kdos-installer/kpkgbuild |
About
kdos-installer is kinstall, the installer. It is two things in one binary:
- the full-screen terminal wizard that copies the running live system onto a disk and makes it bootable;
- the headless backend the graphical installer (kdos-installer-gui) runs through pkexec with
--unattended --events json.
It is written in C and links no library beyond musl, not even a terminal library. The work itself — the probe, the answers, the install steps, the files that make the machine a KDOS Plasma desktop and the event stream — is kinstall-core in src/system/kinstall-core, which uses libkbase and libkcolor alone. This port’s own sources are the wizard, drawn with libktui. All of it is compiled from source into the binary, together with kdos-appbox’s catalogue.c, so the installer reads the application catalogue itself instead of calling a program that may not exist yet. Its pages, steps, answer files and event stream are in kinstall.
41_system builds this port, the last name in its src-system.txt, and the image and the binhost carry its package. 10_bootstrap’s 130_kinstall.sh compiles the same sources first with the cross compiler, so that every tree from the first bootable one onward has an installer, and installs /usr/bin/kinstall as a file no package owns; this package adopts it (see Who owns a file).
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/src-system.txt:
kinstall as a package, so the binhost carries the installer a one-slot machine updates in place. 10_bootstrap compiles the same sources first, for the trees before kpkg can install anything; this package adopts that file.
Sources
None: the port builds from its own directory, /kdos/src/system/kdos-installer.
Dependencies
Depends on: sysvinit.
Required by: no port names it.
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/41_system/phase.env && kpkg install kdos-installer'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/system/kdos-installer.
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-installer
SRC=$SRC_ROOT/kdos-installer-5.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"
CORE="$PORT_SRC/../kinstall-core"
APPBOX="$PORT_SRC/../kdos-appbox"
mkdir -p core
for f in "$CORE"/*.c "$APPBOX"/catalogue.c; do
gcc $CFLAGS -O2 -std=gnu11 -D_GNU_SOURCE -Wall -Wextra \
-I"$LIBS/libkbase" -I"$LIBS/libkcolor" -I"$CORE" -I"$APPBOX" \
-c -o "core/$(basename "$f" .c).o" "$f"
done
ar rcs libkinstall-core.a core/*.o
gcc $CFLAGS -O2 -std=gnu11 -D_GNU_SOURCE -Wall -Wextra \
-I"$LIBS/libkbase" -I"$LIBS/libktui" -I"$LIBS/libkcolor" \
-I"$CORE" -I"$PORT_SRC" \
-o kinstall \
"$PORT_SRC"/*.c libkinstall-core.a \
"$LIBS"/libkbase/*.c "$LIBS"/libktui/*.c "$LIBS"/libkcolor/*.c $LDFLAGS
install -Dm755 kinstall "$PKG/usr/bin/kinstall"
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-installer, 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-installer-5.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-installer, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: kinstall.h, main.c, pages.c.
Contents
Installed programs: kinstall.
Notes
- The two builds must compile the same sources. Both take every
.cfile in this directory and in../kinstall-coreby glob, never by name, pluscatalogue.c, so a file added on one side is on the other. Only the compiler flags differ: the port takes the tree’sCFLAGSandLDFLAGS, and the bootstrap step writes its hardening flags out itself. See How it is built. - kinstall-core is compiled without
libktuion its include path and archived aslibkinstall-core.abefore the wizard links it, so aktui.hinclude or alibktuicall in the backend fails this build, not onlytesting/selftest.sh, which links the backend alone too. -I"$APPBOX"is forcatalogue.c’s header, which lives withkdos-appbox; nothing else of that program is compiled in.- The recipe hash does not cover
catalogue.corkinstall-core. It covers this directory andsrc/libs, so a build counts an edit to either alone as nothing to do until--rebuild kdos-installernames the port; see The installer’s recipe hash leaves out its backend and the catalogue reader. sysvinitis a dependency forreboot, which the installer runs at the end of an install that asks for it.- A library added to its compile line must be compiled from source. One that needs a real
-lcannot be cross-compiled in the bootstrap, so the bootstrap step would have to move to a package phase, and every tree before that phase would lose its installer.