39.8. musl-utils-20261006
getconf, getent and iconv for musl, from Alpine's musl package
| Version | 20261006, release 1 |
| Shelf | base — The minimal userland and system daemons that every KDOS image boots with |
| Phase | 30_foundation (Build Foundation), 69 of 127 in build order |
| Licence | BSD-2-Clause AND GPL-2.0-or-later |
| Homepage | https://gitlab.alpinelinux.org/alpine/aports/-/tree/master/main/musl |
| Build time | 0.1 SBU |
| Installed size | 88.1 KiB in 6 files |
| Recipe | ports/core/base/musl-utils/kpkgbuild |
About
musl’s source carries the C library and nothing else, so three commands that glibc’s own package installs have no source in it: getconf, which prints system configuration values such as _NPROCESSORS_ONLN or PAGESIZE; getent, which looks entries up in passwd, group, shadow, hosts, services, protocols, networks, ethers and shells, and shows what getaddrinfo returns as ahosts, ahostsv4 and ahostsv6; and iconv, which converts text between character encodings. This port builds the three from the C files Alpine Linux keeps beside its musl package, pinned by the aports revision in the helper _aports_rev. getconf and getent come from NetBSD, iconv from musl’s author.
They answer for musl itself, not for glibc: getconf reports musl’s limits, getent sees what musl’s lookup functions see, and iconv offers exactly the conversions musl’s iconv_open knows (The base userland). Build systems call these programs (the sysvinit Makefile, for one, runs getconf), so the port is in the first run of 30_foundation, with the rest of the userland every build.sh runs in.
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
getconf.c
sha256d87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c
upstream: https://gitlab.alpinelinux.org/alpine/aports/-/raw/d72a964d7f68bb113225a61d9425ba48005a99e0/main/musl/getconf.c
archive copy: sources-1/base--getconf.cgetent.c
sha256a6171c2db641cdd99c164169d3c5c6ca323617483cedec4cbbe3eb39c5834df0
upstream: https://gitlab.alpinelinux.org/alpine/aports/-/raw/d72a964d7f68bb113225a61d9425ba48005a99e0/main/musl/getent.c
archive copy: sources-1/base--getent.ciconv.c
sha256f79a2930a2e5bb0624321589edf8b889d1e9b603e01e6b7ae214616605b3fdd7
upstream: https://gitlab.alpinelinux.org/alpine/aports/-/raw/d72a964d7f68bb113225a61d9425ba48005a99e0/main/musl/iconv.c
archive copy: sources-1/base--iconv.c
Dependencies
Depends on: nothing a recipe names.
Required by: no port names it.
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 musl-utils'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base/musl-utils.
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/musl-utils
echo 'd87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c getconf.c' | sha256sum -c -
echo 'a6171c2db641cdd99c164169d3c5c6ca323617483cedec4cbbe3eb39c5834df0 getent.c' | sha256sum -c -
echo 'f79a2930a2e5bb0624321589edf8b889d1e9b603e01e6b7ae214616605b3fdd7 iconv.c' | 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/musl-utils
SRC=$SRC_ROOT/musl-utils-20261006
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
cp getconf.c "$SRC"
cp getent.c "$SRC"
cp iconv.c "$SRC"
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 recipe’s helpers _aports_rev and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
for prog in getconf getent iconv; do
$CC $CFLAGS $LDFLAGS -o $prog $prog.c
install -Dm755 $prog "$PKG/usr/bin/$prog"
done
install -Dm644 "$SRC/getconf.c" "$PKG/usr/share/licenses/$name/getconf.c"
install -Dm644 "$SRC/getent.c" "$PKG/usr/share/licenses/$name/getent.c"
install -Dm644 "$SRC/iconv.c" "$PKG/usr/share/licenses/$name/iconv.c"
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/musl-utils, 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 musl-utils-20261006-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/musl-utils, and runs the triggers its paths call for.
Contents
Installed programs: getconf, getent, iconv.
Installed directories: /usr/share/licenses/musl-utils.
Notes
There is no upstream build system. build.sh compiles each file to a program of the same name with the chroot’s $CC, $CFLAGS and $LDFLAGS, so the three get the same release flags as every other port, and installs them in /usr/bin. The sources are three single files rather than a tarball, so kpkg copies each into the work directory as it is.