8.83. Patch-2.7.6

The Patch package contains a program for modifying or creating files by applying a patch file typically created by the diff program.

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

8.83.1. Installation of Patch

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

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

pkgname="patch"
pkgver="2.7.6"
pkgrel="1"
pkgdesc="The Patch package contains a program for modifying or creating files via patch file."
arch=('x86'
      'x86_64')
url="https://savannah.gnu.org/projects/patch/"
license=('GPLv3')
groups=('core')
depends=('attr'
         'glibc'
         'rootfs')
makedepends=('bash'
             'binutils'
             'coreutils'
             'gcc'
             'grep'
             'make'
             'sed')
checkdepends=('diffutils')
optdepends=('ed')
source=('https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz')
md5sums=('78ad9937e4caadcba1526ef1853730d5')
 
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 patch-2.7.6-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/patch-2.7.6-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Patch package:

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

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

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

8.83.2. Contents of Patch

Installed program: patch

Short Descriptions

patch

Modifies files according to a patch file (A patch file is normally a difference listing created with the diff program. By applying these differences to the original files, patch creates the patched versions.)