8.71. Gawk-5.3.1

The Gawk package contains programs for manipulating text files.

Approximate build time: 0.2 SBU
Required disk space: 43 MB

8.71.1. Installation of Gawk

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

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

pkgname="gawk"
pkgver="5.3.1"
pkgrel="1"
pkgdesc="The Gawk package contains programs for manipulating text files."
arch=('x86'
      'x86_64')
url="https://www.gnu.org/software/gawk/"
license=('GPLv3')
groups=('core')
depends=('bash'
         'glibc'
         'mpfr'
         'rootfs')
makedepends=('binutils'
             'coreutils'
             'gcc'
             'gettext'
             'gmp'
             'grep'
             'make'
             'patch'
             'readline'
             'sed'
             'texinfo')
checkdepends=('diffutils')
optdepends=('libsigsegv')
source=('https://ftp.gnu.org/gnu/gawk/gawk-5.3.1.tar.xz')
md5sums=('4e9292a06b43694500e0620851762eec')

prepare(){
  cd ${pkgname}-${pkgver}
  # Enusre some unneeded files are not installed
  sed -i 's/extras//' Makefile.in
}

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

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

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

  # awk symlink is arleady installed, do the same with the man page
  ln -sv gawk.1 "${pkgdir}/usr/share/man/man1/awk.1"
  # Install the documentation
  mkdir -v "${pkgdir}/usr/share/doc/gawk-${pkgver}"
  cp    -v doc/{awkforai.txt,*.{eps,pdf,jpg}} "${pkgdir}/usr/share/doc/gawk-${pkgver}"
}
REALEOF

The meaning of the command:

rm -f /usr/bin/gawk-5.3.1

The building system will not recreate the hard link gawk-5.3.1 if it already exists. Remove it to ensure that the previous hard link installed in Section 6.9, “Gawk-5.3.1” is updated here.

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

Update the local cache and install the Gawk package:

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

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

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

8.71.2. Contents of Gawk

Installed programs: awk (link to gawk), gawk, and gawk-5.3.1
Installed libraries: filefuncs.so, fnmatch.so, fork.so, inplace.so, intdiv.so, ordchr.so, readdir.so, readfile.so, revoutput.so, revtwoway.so, rwarray.so, and time.so (all in /usr/lib/gawk)
Installed directories: /usr/lib/gawk, /usr/libexec/awk, /usr/share/awk, and /usr/share/doc/gawk-5.3.1

Short Descriptions

awk

A link to gawk

gawk

A program for manipulating text files; it is the GNU implementation of awk

gawk-5.3.1

A hard link to gawk