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
statvfscheck in advance with “no”, sodfandstat -fread file system figures withstatfsinstead. musl’sstatvfskeeps only 32 bits of the file system id, so with itstat -f -c %iwould 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, thesha*sumprograms andcksum, and insort --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
exprandfactorwith 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 -afrom this build copies data, modes, owners and times, and nothing more. --enable-install-program=arch,hostname-
Also install
archandhostname, 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:
--with-libgmpbuildsexprandfactoragainst GMP, and stops configure if GMP is missing.--enable-acl,--enable-xattrand--enable-libcapletcp -aandmvcarry ACLs and extended attributes, andlsshow file capabilities.CPPFLAGS=-I/usr/include/utmpsandLIBS="-lutmps -lskarnet"buildwho,usersandpinkyagainst utmps, so they read the login recordsutmpdkeeps. In this build they use musl’s own utmp functions, which are stubs and report no one.
The reasons for each are in The base userland.
See also
- Part III: the bootstrap
- The base userland: the constraints on the port’s configure line
- Login records: utmps and
utmpd