39.5. coreutils-9.12
The GNU core utilities — the file, text and shell commands, one program each
| Version | 9.12, release 4 |
| Shelf | base — The minimal userland and system daemons that every KDOS image boots with |
| Phase | 30_foundation (Build Foundation), 65 of 127 in build order |
| Licence | GPL-3.0-or-later |
| Homepage | https://www.gnu.org/software/coreutils/ |
| Build time | 1.3 SBU |
| Installed size | 12.3 MiB in 210 files |
| Recipe | ports/core/base/coreutils/kpkgbuild |
About
GNU coreutils is the everyday command line: ls, cp, mv, install, sort, stat, date, df and the rest, each installed as a program of its own. KDOS has no multi-call userland, so every one of these names on the image is GNU’s, and every configure script and build.sh meets the behaviour upstream build systems were written against (The base userland).
10_bootstrap cross-compiles the same source with no optional libraries (Coreutils). This port rebuilds it natively in the first run of 30_foundation, with GMP, ACLs, extended attributes, capabilities and utmps, and takes over the files the bootstrap installed.
Why it is in KDOS
The comment above the 24 ports from fortify-headers to musl-utils in script/phases/30_foundation/packages.txt is quoted in The build foundation.
Sources
coreutils-9.12.tar.xz(6.4 MiB)
sha256a480198559733e9b3da999e90543ac6f888a2caa544d8d664c5a1f17e528e210
upstream: https://mirrors.ocf.berkeley.edu/gnu/coreutils/coreutils-9.12.tar.xz
archive copy: sources-1/base--coreutils-9.12.tar.xz
Dependencies
Depends on: gmp, acl, attr, libcap, utmps.
Required by (10): brltty, elogind, kdf, koreader, libretro-core-info, libretro-database, openjdk, retroarch-assets, retroarch-joypad-autoconfig, sshfs.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
--without-openssl, line 13: openssl (explained with the switches below)
Differs from the bootstrap build. Coreutils builds this source too, in script/phases/10_bootstrap/062_coreutils.sh, before kpkg exists.
Only in the bootstrap build: --build=$(build-aux/config.guess), --disable-acl, --disable-libcap, --disable-xattr, --host=$KDOS_TARGET, --without-libgmp.
Only in this build: --enable-acl, --enable-libcap, --enable-xattr, --with-libgmp.
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/30_foundation/phase.env && kpkg install coreutils'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base/coreutils.
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/coreutils
echo 'a480198559733e9b3da999e90543ac6f888a2caa544d8d664c5a1f17e528e210 coreutils-9.12.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/coreutils
SRC=$SRC_ROOT/coreutils-9.12
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf coreutils-9.12.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:
export FORCE_UNSAFE_CONFIGURE=1
fu_cv_sys_stat_statvfs=n ./configure --prefix=/usr --disable-nls --without-openssl \
--without-selinux --with-libgmp --enable-acl --enable-xattr --enable-libcap \
--enable-install-program=arch,hostname \
CPPFLAGS=-I/usr/include/utmps LIBS="-lutmps -lskarnet"
make
make DESTDIR=$PKG install
The switches, and why each is set:
FORCE_UNSAFE_CONFIGURE=1— Let configure run as root. Itsmknodtest stops with “you should not run configure as root” unless this is set, and kpkg builds every port as root inside the chroot.fu_cv_sys_stat_statvfs=n— Answer configure’sstatvfscheck with “no”, sodfandstat -fusestatfs. musl’sstatvfskeeps only 32 bits of the file system id, andstat -f -c %iwould print an id no other tool agrees with.--disable-nls— Install no message catalogues; the programs speak English only.--without-openssl— Use gnulib’s own digest code inmd5sum,sha256sum,cksumand the other checksum programs, and insort --random-sort. Left at its default,auto-gpl-compat, configure takes those hashes from OpenSSL’slibcryptowhenever it finds OpenSSL 3 or later.--without-selinux— No SELinux contexts inls -Z,cp --contextand the rest.--with-libgmp— Buildexprandfactoragainst gmp, and stop configure if GMP is missing rather than build them against gnulib’s smaller arbitrary-precision copy.--enable-acl— Preserve POSIX ACLs incp -a,cp --preserveandmvacross file systems, through acl, and letls -lmark a file that carries one with+.--enable-xattr— Preserve extended attributes in the same copies. Without it they copy the data and drop the attributes without a message.--enable-libcap— Letls --colorcolour files that carry file capabilities (thecaentry ofLS_COLORS), through libcap.--enable-install-program=arch,hostname— Also installarchandhostname. coreutils builds five programs only when asked for; the other three,kill,uptimeand the multi-callcoreutils, stay out, and must: util-linux installskilland procps-ng installsuptime, and kpkg refuses a package that installs over a path another package owns.CPPFLAGS=-I/usr/include/utmps,LIBS="-lutmps -lskarnet"— Buildwho,usersandpinkyagainst utmps, so they read the login records its daemon keeps. musl’s own utmp functions are stubs that report no one (Login records).
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/coreutils, 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 coreutils-9.12-4.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/coreutils, and runs the triggers its paths call for.
Contents
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, yes.
Installed directories: /usr/libexec/coreutils, /usr/share/licenses/coreutils.
Short descriptions
arch |
print machine hardware name (same as uname -m) |
b2sum |
compute and check BLAKE2 message digest |
base32 |
base32 encode/decode data and print to standard output |
base64 |
base64 encode/decode data and print to standard output |
basename |
strip directory and suffix from filenames |
basenc |
Encode/decode data and print to standard output |
cat |
concatenate files and print on the standard output |
chgrp |
change group ownership |
chmod |
change file mode bits |
chown |
change file owner and group |
chroot |
run command or interactive shell with special root directory |
cksum |
compute and verify file checksums |
comm |
compare two sorted files line by line |
cp |
copy files and directories |
csplit |
split a file into sections determined by context lines |
cut |
remove sections from each line of files |
date |
print or set the system date and time |
dd |
convert and copy a file |
df |
report file system space usage |
dir |
list directory contents |
dircolors |
color setup for ls |
dirname |
strip last component from file name |
du |
estimate file space usage |
echo |
display a line of text |
env |
run a program in a modified environment |
expand |
convert tabs to spaces |
expr |
evaluate expressions |
factor |
factor numbers |
false |
do nothing, unsuccessfully |
fmt |
simple optimal text formatter |
fold |
wrap each input line to fit in specified width |
groups |
print the groups a user is in |
head |
output the first part of files |
hostid |
print the numeric identifier for the current host |
hostname |
set or print the name of the current host system |
id |
print real and effective user and group IDs |
install |
copy files and set attributes |
join |
join lines of two files on a common field |
link |
call the link function to create a link to a file |
ln |
make links between files |
logname |
print users login name |
ls |
list directory contents |
md5sum |
compute and check MD5 message digest |
mkdir |
make directories |
mkfifo |
make FIFOs (named pipes) |
mknod |
make block or character special files |
mktemp |
create a temporary file or directory |
mv |
move (rename) files |
nice |
run a program with modified scheduling priority |
nl |
number lines of files |
nohup |
run a command immune to hangups, with output to a non-tty |
nproc |
print the number of processing units available |
numfmt |
Convert numbers from/to human-readable strings |
od |
dump files in octal and other formats |
paste |
merge lines of files |
pathchk |
check whether file names are valid or portable |
pinky |
lightweight finger |
pr |
convert text files for printing |
printenv |
print all or part of environment |
printf |
format and print data |
ptx |
produce a permuted index of file contents |
pwd |
print name of current/working directory |
readlink |
print resolved symbolic links or canonical file names |
realpath |
print the resolved path |
rm |
remove files or directories |
rmdir |
remove empty directories |
seq |
print a sequence of numbers |
sha1sum |
compute and check SHA1 message digest |
sha224sum |
compute and check SHA224 message digest |
sha256sum |
compute and check SHA256 message digest |
sha384sum |
compute and check SHA384 message digest |
sha512sum |
compute and check SHA512 message digest |
shred |
overwrite a file to hide its contents, and optionally delete it |
shuf |
generate random permutations |
sleep |
delay for a specified amount of time |
sort |
sort lines of text files |
split |
split a file into pieces |
stat |
display file or file system status |
stdbuf |
Run COMMAND, with modified buffering operations for its standard streams. |
stty |
change and print terminal line settings |
sum |
checksum and count the blocks in a file |
sync |
Synchronize cached writes to persistent storage |
tac |
concatenate and print files in reverse |
tail |
output the last part of files |
tee |
read from standard input and write to standard output and files |
test |
check file types and compare values |
timeout |
run a command with a time limit |
touch |
create file, or change file timestamps |
tr |
translate or delete characters |
true |
do nothing, successfully |
truncate |
shrink or extend the size of a file to the specified size |
tsort |
perform topological sort |
tty |
print the file name of the terminal connected to standard input |
uname |
print system information |
unexpand |
convert spaces to tabs |
uniq |
report or omit repeated lines |
unlink |
call the unlink function to remove the specified file |
users |
print the user names of users currently logged in to the current host |
vdir |
list directory contents |
wc |
word, line, and byte or character count |
who |
show who is logged on |
whoami |
print effective user name |
yes |
output a string repeatedly until killed |
Notes
The libraries the bootstrap build goes without (GMP, acl, attr, libcap, utmps) are not in build/fs while 10_bootstrap runs: that build switches off the first four and passes no utmps flags. The recipe’s depends installs all five before this port in 30_foundation.