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

16. Coreutils

GNU coreutils is the basic command line: ls, cp, mv, rm, cat, mkdir, chmod, sort, install and about a hundred more. Every build.sh that 20_selfhost runs uses them, so they are built here with no optional library at all, and replaced by the full port in 30_foundation. This page shows the commands of script/phases/10_bootstrap/062_coreutils.sh and explains each switch.

Source: the archive of the coreutils port
Installs into: build/fs/usr
Approximate build time: 0.9 SBU

Installation of coreutils

COREUTILS_SRC=$(extract_port_source coreutils)

cd "$COREUTILS_SRC"

FORCE_UNSAFE_CONFIGURE=1 fu_cv_sys_stat_statvfs=n ./configure \
    --host=$KDOS_TARGET \
    --build=$(build-aux/config.guess) \
    --prefix=/usr \
    --disable-nls \
    --without-openssl \
    --without-selinux \
    --without-libgmp \
    --disable-acl \
    --disable-xattr \
    --disable-libcap \
    --enable-install-program=arch,hostname

make
make DESTDIR=$SYSROOT install

script/phases/10_bootstrap/062_coreutils.sh, lines 23–41

The meaning of the configure options

FORCE_UNSAFE_CONFIGURE=1
coreutils’ configure refuses to run as root unless this is set. As for tar, the refusal comes out of a test program a cross build never runs, so here it changes nothing; the port, built natively as root, needs it.
fu_cv_sys_stat_statvfs=n
Answer configure’s statvfs check in advance with “no”, so df and stat -f read file system figures with statfs instead. musl’s statvfs keeps only 32 bits of the file system id, so with it stat -f -c %i would print an id whose high half is zero, matching no other tool’s id for the same file system. The port sets the same answer; see The base userland.
--host=$KDOS_TARGET, --build=$(build-aux/config.guess), --prefix=/usr
A cross build, installed under /usr (see Part III).
--disable-nls
Build no message catalogues.
--without-openssl
Use gnulib’s own digest code in md5sum, the sha*sum programs and cksum, and in sort --random-sort. Left to its default, configure takes those hashes from OpenSSL’s libcrypto whenever it finds OpenSSL 3 or later. OpenSSL is not in the root, and the port passes the same switch, so the two builds compute digests with the same code.
--without-selinux
Build no SELinux support.
--without-libgmp
Build expr and factor with gnulib’s own arbitrary-precision arithmetic. GMP is not in the root.
--disable-acl, --disable-xattr, --disable-libcap
Build without access control lists, extended attributes and file capabilities. Their libraries, libacl, libattr and libcap, are not in the root. cp -a from this build copies data, modes, owners and times, and nothing more.
--enable-install-program=arch,hostname
Also install arch and hostname, which coreutils leaves out by default.

Contents of coreutils

Installed programs: [, arch, b2sum, base32, base64, basename, basenc, cat, chgrp, chmod, chown, chroot, cksum, comm, cp, csplit, cut, date, dd, df, dir, dircolors, dirname, du, echo, env, expand, expr, factor, false, fmt, fold, groups, head, hostid, hostname, id, install, join, link, ln, logname, ls, md5sum, mkdir, mkfifo, mknod, mktemp, mv, nice, nl, nohup, nproc, numfmt, od, paste, pathchk, pinky, pr, printenv, printf, ptx, pwd, readlink, realpath, rm, rmdir, seq, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, shred, shuf, sleep, sort, split, stat, stdbuf, stty, sum, sync, tac, tail, tee, test, timeout, touch, tr, true, truncate, tsort, tty, uname, unexpand, uniq, unlink, users, vdir, wc, who, whoami and yes, each a program of its own.

Installed library: libstdbuf.so in /usr/libexec/coreutils, which stdbuf preloads into the command it runs to change that command’s buffering.

The coreutils port’s page describes each program.

Built again later

The coreutils port, in 30_foundation, installs the same programs under the same names, and kpkg adopts the files this step installed. It keeps fu_cv_sys_stat_statvfs=n, --without-openssl, --without-selinux and the two extra programs, and turns on what this build leaves out:

The reasons for each are in The base userland.

See also