8.72. Findutils-4.10.0

The Findutils package contains programs to find files. Programs are provided to search through all the files in a directory tree and to create, maintain, and search a database (often faster than the recursive find, but unreliable unless the database has been updated recently). Findutils also supplies the xargs program, which can be used to run a specified command on each file selected by a search.

Approximate build time: 0.7 SBU
Required disk space: 63 MB

8.72.1. Installation of Findutils

Create the PKGBUILD for the Findutils package with the following commands:

mkdir /sources/findutils
cd /sources/findutils
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="findutils"
pkgver="4.10.0"
pkgrel="1"
pkgdesc="The Findutils package contains programs to find files."
arch=('x86'
      'x86_64')
url="https://www.gnu.org/software/findutils/"
license=('GPLv3')
groups=('core')
depends=('bash'
         'glibc'
         'rootfs')
makedepends=('binutils'
             'coreutils'
             'gcc'
             'gettext'
             'grep'
             'make'
             'sed'
             'texinfo')
checkdepends=('dejagnu'
              'diffutils'
              'expect')
source=('https://ftp.gnu.org/gnu/findutils/findutils-4.10.0.tar.xz')
md5sums=('870cfd71c07d37ebe56f9f4aaf4ad872')
 
build(){
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr --localstatedir=/var/lib/locate
  make
}

check(){
  cd "${pkgname}-${pkgver}"
  make check
}

package(){
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
}
REALEOF

The meaning of the configure options:

--localstatedir

This option moves the locate database to /var/lib/locate, which is the FHS-compliant location.

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp findutils-4.10.0-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/findutils-4.10.0-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Findutils package:

pacman -Syu
pacman -S findutils --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/findutils
cp PKGBUILD /srv/pacman/source/LFS/findutils
cd /sources
rm -rf findutils

8.72.2. Contents of Findutils

Installed programs: find, locate, updatedb, and xargs
Installed directory: /var/lib/locate

Short Descriptions

find

Searches given directory trees for files matching the specified criteria

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