18. Findutils
GNU findutils provides find, which walks a directory tree and acts on what it finds, and xargs, which turns a list into command lines. Build systems and install scripts use both. The source also carries locate and updatedb, which KDOS takes from plocate instead, so this step deletes them after the install. This page shows the commands of script/phases/10_bootstrap/064_findutils.sh and explains them.
Source: the archive of the findutils port
Installs into: build/fs/usr
Approximate build time: 0.5 SBU
Installation of findutils
FINDUTILS_SRC=$(extract_port_source findutils)
cd "$FINDUTILS_SRC"
./configure \
--host=$KDOS_TARGET \
--build=$(build-aux/config.guess) \
--prefix=/usr \
--localstatedir=/var/lib/locate \
--disable-nls
make
make DESTDIR=$SYSROOT install
# locate and updatedb are plocate's. The findutils port leaves its own pair
# out of the package, so updatedb, frcode and the manual pages installed here
# would be owned by nothing and never replaced, and this updatedb would be
# found on $PATH ahead of /usr/sbin/updatedb.
rm -f $SYSROOT/usr/bin/locate $SYSROOT/usr/bin/updatedb $SYSROOT/usr/libexec/frcode \
$SYSROOT/usr/share/man/man1/locate.1 $SYSROOT/usr/share/man/man1/updatedb.1 \
$SYSROOT/usr/share/man/man5/locatedb.5
rmdir $SYSROOT/var/lib/locate 2>/dev/null || true
script/phases/10_bootstrap/064_findutils.sh, lines 23–44
The meaning of the configure options
--host=$KDOS_TARGET,--build=$(build-aux/config.guess),--prefix=/usr-
A cross build, installed under
/usr(see Part III). --localstatedir=/var/lib/locate-
Where
updatedbwould keep its database. Thelocatehalf is deleted below, so the only trace of this switch is the empty directory, which thermdirremoves. --disable-nls- Build no message catalogues.
Removing locate
locate, updatedb and their helper frcode are deleted with their manual pages. The plocate port provides /usr/bin/locate and /usr/sbin/updatedb. The findutils port leaves its own copies out of its package, so a file installed here would be adopted by no package (see What the bootstrap leaves behind). plocate’s locate would take over a /usr/bin/locate left here, but nothing would ever replace /usr/bin/updatedb, frcode or the manual pages, and the profile’s PATH lists /usr/bin before /usr/sbin, so findutils’ updatedb would run in place of plocate’s.
rmdir removes /var/lib/locate only when it is empty, and its || true keeps a missing or non-empty directory from stopping the step.
Contents of findutils
Installed programs: find and xargs.
The findutils port’s page describes each program.
Built again later
The findutils port, in 30_foundation, installs the same two programs, and kpkg adopts the files this step installed. It differs in three ways:
- It applies
updatedb-copyright-pipe.patch. The rule that generatesupdatedbmeans to pipesed’s output intogrep, but as released it handsgrepand.tosedas file names; the patch adds the missing|. - It adds
--without-selinux. - It deletes the same
locatefiles from its package, and with them the directories they leave empty:/usr/libexec,/usr/share/man/man5and/var.
See also
- Part III: the bootstrap, and why an unowned file must not be left behind
- Finding a file by name: the
locateandupdatedbKDOS ships - Gawk: the next step