8.17.1. Installation of Flex
Create the PKGBUILD for the Flex package with the following
commands:
mkdir /sources/flex
cd /sources/flex
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>
pkgname="flex"
pkgver="2.6.4"
pkgrel="1"
pkgdesc="The Flex package contains a utility for generating programs that recognize patterns in text."
arch=('x86'
'x86_64')
url="https://github.com/westes/flex"
license=('BSD3C'
'custom')
groups=('core')
makedepends=('binutils'
'coreutils'
'gcc'
'gettext'
'grep'
'make'
'patch'
'sed'
'texinfo')
depends=('bash'
'glibc'
'm4')
checkdepends=('bison'
'gawk')
optdepends=('help2man')
source=('https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz')
md5sums=('2882e3179748cc9f9c23ec593d6adc8d')
build(){
cd "${pkgname}-${pkgver}"
./configure --prefix=/usr \
--disable-static \
--docdir="/usr/share/doc/${pkgname}-${pkgver}"
make
}
check(){
cd "${pkgname}-${pkgver}"
make check
}
package(){
cd "${pkgname}-${pkgver}"
make DESTDIR="${pkgdir}" install
ln -svf flex "${pkgdir}/usr/bin/lex"
ln -svf flex.1 "${pkgdir}/usr/share/man/man1/lex.1"
}
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 flex-2.6.4-1-$(uname -m).pkg.tar.xz \
/srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
/srv/pacman/repos/LFS/flex-2.6.4-1-$(uname -m).pkg.tar.xz
Update the local cache and install the Flex package:
pacman -Syu
pacman -S flex --overwrite \* -dd --noconfirm
Finally, copy the source files into the source repository and clean
up the build directory:
mkdir /srv/pacman/source/LFS/flex
cp PKGBUILD /srv/pacman/source/LFS/flex
cd /sources
rm -rf flex