8.36. Libxcrypt-4.4.38

The Libxcrypt package contains a modern library for one-way hashing of passwords.

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

8.36.1. Installation of Libxcrypt

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

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

pkgname="libxcrypt"
pkgver="4.4.38"
pkgrel="1"
pkgdesc="The Libxcrypt package contains a modern library for one-way hashing of passwords."
arch=('x86'
      'x86_64')
url="https://github.com/besser82/libxcrypt/"
license=('LGPL2.1'
         'GPL2'
         'BSD0C'
         'BSD1C'
         'BSD3C'
         'PD')
groups=('core')
depends=('glibc')
makedepends=('bash'
             'binutils'
             'coreutils'
             'diffutils'
             'gawk'
             'gcc'
             'grep'
             'make'
             'perl'
             'sed')
source=('https://github.com/besser82/libxcrypt/releases/download/v4.4.38/libxcrypt-4.4.38.tar.xz')
md5sums=('1796a5d20098e9dd9e3f576803c83000')
    
build() {
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr                \
              --enable-hashes=strong,glibc \
              --enable-obsolete-api=no     \
              --disable-static             \
              --disable-failure-tokens
  make
}

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

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

The meaning of the new configure options:

--enable-hashes=strong,glibc

Build strong hash algorithms recommended for security use cases, and the hash algorithms provided by traditional Glibc libcrypt for compatibility.

--enable-obsolete-api=no

Disable obsolete API functions. They are not needed for a modern Linux system built from source.

--disable-failure-tokens

Disable failure token feature. It's needed for compatibility with the traditional hash libraries of some platforms, but a Linux system based on Glibc does not need it.

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

Update the local cache and install the Libxcrypt package:

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

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

mkdir /srv/pacman/source/LFS/libxcrypt
cp PKGBUILD /srv/pacman/source/LFS/libxcrypt
cd /sources
rm -rf libxcrypt
[Note]

Note

The instructions above disabled obsolete API functions since no package installed by compiling from sources would link against them at runtime. However, the only known binary-only applications that link against these functions require ABI version 1. If you must have such functions because of some binary-only application or to be compliant with LSB, build the package again with the following commands:

make distclean
./configure --prefix=/usr                \
            --enable-hashes=strong,glibc \
            --enable-obsolete-api=glibc  \
            --disable-static             \
            --disable-failure-tokens
make
cp -av --remove-destination .libs/libcrypt.so.1* /usr/lib

8.36.2. Contents of Libxcrypt

Installed libraries: libcrypt.so

Short Descriptions

libcrypt

Contains functions to hash passwords