8.51. Less-668

The Less package contains a text file viewer.

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

8.51.1. Installation of Less

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

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

pkgname="less"
pkgver="668"
pkgrel="1"
pkgdesc="The Less package contains a text file viewer."
arch=('x86'
      'x86_64')
url="https://www.greenwoodsoftware.com/less/"
license=('GPLv3')
groups=('core')
depends=('glibc'
         'ncurses'
         'rootfs')
makedepends=('bash'
             'binutils'
             'coreutils'
             'diffutils'
             'gcc'
             'grep'
             'make'
             'sed')
optdepends=('pcre')
source=('https://www.greenwoodsoftware.com/less/less-668.tar.gz')
md5sums=('d72760386c5f80702890340d2f66c302')
    
build(){
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr --sysconfdir=/etc
  make
}

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

Update the local cache and install the Less package:

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

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

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

The meaning of the configure options:

--sysconfdir=/etc

This option tells the programs created by the package to look in /etc for the configuration files.

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

Update the local cache and install the Less package:

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

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

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

8.51.2. Contents of Less

Installed programs: less, lessecho, and lesskey

Short Descriptions

less

A file viewer or pager; it displays the contents of the given file, letting the user scroll, find strings, and jump to marks

lessecho

Needed to expand meta-characters, such as * and ?, in filenames on Unix systems

lesskey

Used to specify the key bindings for less