8.12. Zstd-1.5.7

Zstandard is a real-time compression algorithm, providing high compression ratios. It offers a very wide range of compression / speed trade-offs, while being backed by a very fast decoder.

Approximate build time: 0.4 SBU
Required disk space: 85 MB

8.12.1. Installation of Zstd

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

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

pkgname="zstd"
pkgver="1.5.7"
pkgrel="1"
pkgdesc="Zstandard is a real-time compression algorithm, providing high compression ratios."
arch=('x86'
      'x86_64')
url="https://facebook.github.io/zstd/"
groups=('core')
license=('GPLv2')
depends=('glibc')
makedepends=('binutils'
             'coreutils'
             'gcc'
             'gzip'
             'lz4'
             'make'
             'xz'
             'zlib')
source=('https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz')
md5sums=('780fc1896922b1bc52a4e90980cdda48')

build(){
  cd ${srcdir}/${pkgname}-${pkgver}
  make prefix=/usr
}

check(){
  cd ${srcdir}/${pkgname}-${pkgver}
  make check
}

package(){
  cd ${srcdir}/${pkgname}-${pkgver}
  make prefix=/usr DESTDIR=${pkgdir} install
  rm -v ${pkgdir}/usr/lib/libzstd.a
}
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 zstd-1.5.7-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/zstd-1.5.7-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Zstd package:

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

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

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

8.12.2. Contents of Zstd

Installed programs: zstd, zstdcat (link to zstd), zstdgrep, zstdless, zstdmt (link to zstd), and unzstd (link to zstd)
Installed library: libzstd.so

Short Descriptions

zstd

Compresses or decompresses files using the ZSTD format

zstdgrep

Runs grep on ZSTD compressed files

zstdless

Runs less on ZSTD compressed files

libzstd

The library implementing lossless data compression, using the ZSTD algorithm