Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

33.3. gawk-5.4.1

GNU awk pattern scanning and processing language

Version 5.4.1, release 1
Shelf base — The minimal userland and system daemons that every KDOS image boots with
Phase 20_selfhost (Self-Hosting Bootstrap), 13 of 15 in build order
Licence GPL-3.0-or-later
Homepage https://www.gnu.org/software/gawk/
Build time 0.4 SBU
Installed size 5.3 MiB in 76 files
Recipe ports/core/base/gawk/kpkgbuild

About

GNU awk is the pattern-scanning language most shell scripts and build files reach for to cut a field out of a line or total a column. On KDOS it is the only awk: the package installs /usr/bin/awk as a link to gawk (see The base userland). Configure scripts and makefiles call it as plain awk without the port naming it in depends, and the GMP and GCC builds of 20_selfhost are among them, which is why that phase rebuilds it as a package. A few ports do name it, among them tzdata and iana-etc, whose builds generate files with gawk programs.

The bootstrap build in Part III has neither readline nor MPFR. This one links both, so 20_selfhost installs gmp, mpfr, ncurses and readline before it.

Sources

Dependencies

Depends on: mpfr, gmp, readline.

Required by (4): aerc, iana-etc, thin-provisioning-tools, tzdata.

Differs from the bootstrap build. Gawk builds this source too, in script/phases/10_bootstrap/065_gawk.sh, before kpkg exists.

Only in the bootstrap build: --build=$(build-aux/config.guess), --host=$KDOS_TARGET, --without-mpfr, --without-readline.

Only in this build: --with-mpfr, --with-readline.

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/20_selfhost/phase.env && kpkg install gawk'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base/gawk.

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/base/gawk
echo '07f6f7342b7febe4313fc2c2542ad93d64fe20ad8717200109f105a826f5fd37  gawk-5.4.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/gawk
SRC=$SRC_ROOT/gawk-5.4.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf gawk-5.4.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:

./configure --prefix=/usr \
	--sysconfdir=/etc \
	--with-mpfr \
	--with-readline \
	--disable-nls
make
make DESTDIR=$PKG install
rm -f "$PKG/etc/profile.d/gawk.csh"
rm -f "$PKG/usr/share/info/gawknotes.info"

The switches, and why each is set:

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/gawk, 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 gawk-5.4.1-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/gawk, and runs the triggers its paths call for.

Contents

Installed programs: awk, gawk, gawk-5.4.1, gawkbug.

Installed directories: /usr/lib/gawk, /usr/libexec/awk, /usr/share/awk, /usr/share/licenses/gawk.

Short descriptions

gawk pattern scanning and processing language
gawkbug report a bug in gawk

Notes

The two rm lines leave out two files the install writes. gawk.csh is the C-shell version of the profile script, and no csh or tcsh is a port. gawknotes.info is GNU Awk Maintainer Notes, a manual for people who work on gawk’s own source.

Every optional library gawk can use is either named in depends or switched off (--disable-nls). A library left to configure’s detection would turn its feature on or off according to what is installed when the port builds, and the same recipe builds in 20_selfhost and again in 30_foundation whenever its hash changes.