6.32. Findutils-4.4.2

The Findutils package contains programs to find files. These programs are provided to recursively search through a directory tree and to create, maintain, and search a database (often faster than the recursive find, but unreliable if the database has not been recently updated).

6.32.1. Environment Settings

This package requires compiler variables to be set for the target in the environment.

export CC="${CLFS_TARGET}-gcc"
export CXX="${CLFS_TARGET}-g++"
export AR="${CLFS_TARGET}-ar"
export AS="${CLFS_TARGET}-as"
export RANLIB="${CLFS_TARGET}-ranlib"
export LD="${CLFS_TARGET}-ld"
export STRIP="${CLFS_TARGET}-strip"

6.32.2. Installation of Findutils

When Cross Compiling the configure script does not run a select few tests, Set the values manually:

cat > config.cache << EOF
gl_cv_func_wcwidth_works=yes
gl_cv_header_working_fcntl_h=yes
ac_cv_func_fnmatch_gnu=yes
EOF

Prepare Findutils for compilation:

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --prefix=/usr --cache-file=config.cache \
    --libexecdir=/usr/lib/locate \
    --localstatedir=/var/lib/locate

The meaning of the configure options:

--localstatedir

This option changes the location of the locate database to be in /var/lib/locate, which is FHS-compliant.

Compile the package:

make

Install the package:

make DESTDIR=${CLFS} install

The find program is used by some of the scripts in the CLFS-Bootscripts package. As /usr may not be available during the early stages of booting, the find binary needs to be on the root partition:

mv -v ${CLFS}/usr/bin/find ${CLFS}/bin

The updatedb script needs to be modified to point to the new location for find:

cp ${CLFS}/usr/bin/updatedb{,.orig}
sed 's@find:=${BINDIR}@find:=/bin@' ${CLFS}/usr/bin/updatedb.orig > \
    ${CLFS}/usr/bin/updatedb
rm ${CLFS}/usr/bin/updatedb.orig

6.32.3. Contents of Findutils

Installed programs: bigram, code, find, frcode, locate, updatedb, and xargs

Short Descriptions

bigram

Was formerly used to produce locate databases

code

Was formerly used to produce locate databases; it is the ancestor of frcode.

find

Searches given directory trees for files matching the specified criteria

frcode

Is called by updatedb to compress the list of file names; it uses front-compression, reducing the database size by a factor of four to five.

locate

Searches through a database of file names and reports the names that contain a given string or match a given pattern

updatedb

Updates the locate database; it scans the entire file system (including other file systems that are currently mounted, unless told not to) and puts every file name it finds into the database

xargs

Can be used to apply a given command to a list of files