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

39.12. findutils-4.11.0

GNU utilities to locate files

Version 4.11.0, release 1
Shelf base — The minimal userland and system daemons that every KDOS image boots with
Phase 30_foundation (Build Foundation), 73 of 127 in build order
Licence GPL-3.0-or-later
Homepage https://www.gnu.org/software/findutils/
Build time 1.0 SBU
Installed size 996.9 KiB in 7 files
Recipe ports/core/base/findutils/kpkgbuild

About

GNU findutils, of which KDOS installs find, which walks a directory tree and tests or acts on each file, and xargs, which builds command lines from its input. They are part of the GNU command line every KDOS system carries (see The base userland).

The other half of the package, locate, updatedb and their helper frcode, is deleted after the install. locate and updatedb on KDOS are plocate’s, which read and write a different index format (see Finding a file by name).

Why it is in KDOS

The comment above the 8 ports from skalibs to sed in script/phases/30_foundation/packages.txt:

utmps, the utmp and wtmp service over skalibs (shelves auth and base-libs): coreutils, sysvinit, util-linux and shadow build against it, and coreutils' depends installs both in the pinned run above, ahead of the other three.

Sources

Dependencies

Depends on: nothing a recipe names.

Required by (1): koreader.

Patches

build.sh applies these; kpkg applies nothing by itself.

Differs from the bootstrap build. Findutils builds this source too, in script/phases/10_bootstrap/064_findutils.sh, before kpkg exists.

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

Only in this build: --without-selinux.

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 findutils'

What kpkg does

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

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/findutils
echo 'bfd19cb06cc71f3352d567e90284d8cdac02ac89774bbeadf0b533b0c11432fd  findutils-4.11.0.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/findutils
SRC=$SRC_ROOT/findutils-4.11.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf findutils-4.11.0.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:

patch -p1 -i $PORT_SRC/updatedb-copyright-pipe.patch
./configure --prefix=/usr \
            --localstatedir=/var/lib/locate \
            --disable-nls \
            --without-selinux
make
make DESTDIR=$PKG install

rm -f "$PKG/usr/bin/locate" "$PKG/usr/bin/updatedb" "$PKG/usr/libexec/frcode" \
	"$PKG/usr/share/man/man1/locate.1" "$PKG/usr/share/man/man1/updatedb.1" \
	"$PKG/usr/share/man/man5/locatedb.5"
rmdir "$PKG/usr/libexec" "$PKG/usr/share/man/man5"
rm -rf "$PKG/var"

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

Contents

Installed programs: find, xargs.

Installed directories: /usr/share/licenses/findutils.

Short descriptions

find search for files in a directory hierarchy
xargs build and execute command lines from standard input

Notes

The rule the patch touches runs during make even though the program it generates is deleted from the package afterwards.

The rm and rmdir lines after the install must match what upstream installs. A locate left in the package would own /usr/bin/locate, which plocate installs in a later phase, and kpkg refuses a package that installs over a path another package owns (see Who owns a file). rmdir fails, and the build with it, if /usr/libexec or /usr/share/man/man5 still holds a file after the deletions.