29. kinstall
kinstall is the KDOS installer: the terminal wizard that partitions a disk, copies the system onto it and writes the boot loader. It is the last step of the bootstrap, compiled by hand the same way as kpkg, so that every tree from this phase onward, and every image made from one, has an installer. 130_kinstall.sh builds it from src/system/kdos-installer and src/system/kinstall-core with the cross compiler and installs it as /usr/bin/kinstall.
Source: src/system/kdos-installer, src/system/kinstall-core, src/system/kdos-appbox/catalogue.c and src/libs in this repository
Installs into: build/fs/usr/bin
Approximate build time: 0.2 SBU
What it is built from
kinstall links no library at all beyond musl, not even ncurses. Its sources are:
- every
.cfile insrc/system/kdos-installer, the terminal wizard, by glob; - every
.cfile insrc/system/kinstall-core, by glob: the probe, the answers and their check, the install steps, the dumps and the event stream, which every front end of the installer uses; catalogue.cfromsrc/system/kdos-appbox, the reader for the application catalogue. The installer runs before anything it could call exists, so it reads the catalogue itself, and the file needs nothing fromlibkbasethe installer does not already carry. Its header lives beside it, which is why that directory is on the include path;- three of KDOS’s libraries, as source:
libkbase,libktui, the terminal toolkit the wizard is drawn with, andlibkcolor, which holds the palette numberslibktui’s theme code includes.
Each of the three keeps the constraint of linking nothing but the C library. A library on this line that needed a real -l would move the installer to a package phase and take it off every tree before that phase.
Installation of kinstall
The step names its sources and its output:
SRC=$WORKSPACE/src/system/kdos-installer
CORE=$WORKSPACE/src/system/kinstall-core
LIBS=$WORKSPACE/src/libs
OUT=$BUILD_DIR/tmp/kinstall
script/phases/10_bootstrap/130_kinstall.sh, lines 36–39
and compiles everything in one invocation:
$KDOS_TARGET-gcc \
-O2 -pipe -std=gnu11 -D_GNU_SOURCE -Wall -Wextra \
-fstack-protector-strong -fstack-clash-protection \
-Wl,-O1,--as-needed,-z,now,-z,pack-relative-relocs -Wl,--build-id=sha1 \
-I"$LIBS"/libkbase -I"$LIBS"/libktui -I"$LIBS"/libkcolor -I"$SRC" \
-I"$CORE" -I"$WORKSPACE"/src/system/kdos-appbox \
-o "$OUT" \
"$SRC"/*.c "$CORE"/*.c \
"$WORKSPACE"/src/system/kdos-appbox/catalogue.c \
"$LIBS"/libkbase/*.c "$LIBS"/libktui/*.c "$LIBS"/libkcolor/*.c
script/phases/10_bootstrap/130_kinstall.sh, lines 55–64
The flags are those of kpkg’s compile line: the binary is every tree’s installer until 41_system builds the package, so the line carries the tree’s hardening itself. The include paths are the three libraries, the installer’s own directory, src/system/kinstall-core for kinstall-core.h, and src/system/kdos-appbox for catalogue.c’s header.
Every .c file in src/system/kdos-installer and src/system/kinstall-core is compiled by glob, never by a list of names. The port recipe beside the sources builds the same program from the same two directories, and the two must compile the same files; a name list in either place would miss the next file added on one side only, and the two installers would stop being the same program.
install -Dm755 places the result at /usr/bin/kinstall. The step touches build/mark/bootstrap/kinstall and is skipped while that file exists. Unlike kpkg’s, this mark is empty, so a change to the installer reaches this copy only when a build plan names the step; the image’s copy comes from the package, rebuilt with --rebuild kdos-installer. See Rebuilding one thing.
Contents of kinstall
Installed program: kinstall
Built again later
In 41_system. src/system/kdos-installer has a recipe, the kdos-installer port, the last name in that phase’s src-system.txt. Its package adopts the /usr/bin/kinstall this step installed, a file no package owned, so the kinstall on the image and on the binhost is the package’s. The port compiles the installer’s backend, every .c file in src/system/kinstall-core with catalogue.c, into a static archive first, the backend the graphical installer kdos-installer-gui shares, and then the terminal front end over it, with native gcc and the chroot’s release flags ($CFLAGS before its own options and $LDFLAGS after the sources) instead of this step’s fixed line. It depends on sysvinit.
See also
- kpkg, the step before this one, and what you have when the phase ends
- kinstall: the installer’s pages, steps and answer files
- libktui: the toolkit the wizard is drawn with