8.102. Libgcrypt-1.11.0

The libgcrypt package contains a general purpose crypto library based on the code used in GnuPG. The library provides a high level interface to cryptographic building blocks using an extendable and flexible API.

Approximate build time: 0.6 SBU
Required disk space: 146 MB

8.102.1. Installation of Libgcrypt

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

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

pkgname="libgcrypt"
pkgver="1.11.0
pkgrel="1"
pkgdesc="The libgcrypt package contains a general purpose crypto library based on the code used in GnuPG."
arch=('x86'
      x86_64')
license=('GPLv2'
         'LGPLv2.1')
url="https://www.gnupg.org/gcrypt/"
groups=('core')
depends=('glibc'
         'libcap'
         'libgpg-error'
         'rootfs')
makedepends=('bash'
         'binutils'
         'coreutils'
         'gawk'
         'gcc'
         'gettext'
         'glibc'
         'grep'
         'make'
         'sed')
source=('https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.11.0.tar.bz2)
md5sums=('321c4975cfd6a496f0530b65a673f9a4')

build(){
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr --with-capabilities
  make
  make -C doc html
  makeinfo --html --no-split -o doc/gcrypt_nochunks.html doc/gcrypt.texi
  makeinfo --plaintext       -o doc/gcrypt.txt           doc/gcrypt.texi
}

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

package(){
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  install -vdm755 "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
  install -vm644  README doc/{README.apichanges,fips*,libgcrypt*} \
                  "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
  install -vdm755 "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/html"
  install -vm644  doc/gcrypt.html/* \
                  "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/html"
  install -vm644  doc/gcrypt_nochunks.html \
                  "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
  install -vm644  doc/gcrypt.{txt,texi} \
                  "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
}
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 libgcrypt-1.11.0-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/libgcrypt-1.11.0-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Libgcrypt package:

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

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

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

8.102.2. Command Explanations

--with-capabilities: This option enables libcap2 support.

8.102.3. Contents

Installed Programs: dumpsexp, hmac256, libgcrypt-config, and mpicalc
Installed Library: libgcrypt.so
Installed Directory: /usr/share/doc/libgcrypt-1.11.0

Short Descriptions

dumpsexp

is a debug tool for S-expressions.

hmac256

is a standalone HMAC-SHA-256 implementation used to compute an HMAC-SHA-256 authentication code.

libgcrypt-config

determines the compile and linker flags that should be used to compile and link programs that use libgcrypt.

mpicalc

is a RPN (Reverse Polish Notation) calculator.

libgcrypt.so

contains the cryptographic API functions.