8.13. File-5.46

The File package contains a utility for determining the type of a given file or files.

Approximate build time: less than 0.1 SBU
Required disk space: 19 MB

8.13.1. Installation of File

Prepare File for compilation:

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

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

pkgname="file"
pkgver="5.46"
pkgrel="1"
pkgdesc="The File package contains a utility for determining the type of a given file or files."
arch=('x86'
      'x86_64')
url="https://www.darwinsys.com/file/"
groups=('core')
license=('BSD3C'
         'custom')
depends=('bzip2'
         'glibc'
         'xz'
         'zlib')
makedepends=('bash'
             'binutils'
             'coreutils'
             'diffutils'
             'gawk'
             'gcc'
             'grep'
             'make'
             'sed')
optdepends=('libseccomp')
source=('https://astron.com/pub/file/file-5.46.tar.gz')
md5sums=('459da2d4b534801e2e2861611d823864')

build() {
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr
  make
}

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

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

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 file-5.46-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/file-5.46-1-$(uname -m).pkg.tar.xz

Update the local cache and install the File package:

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

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

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

8.13.2. Contents of File

Installed programs: file
Installed library: libmagic.so

Short Descriptions

file

Tries to classify each given file; it does this by performing several tests—file system tests, magic number tests, and language tests

libmagic

Contains routines for magic number recognition, used by the file program