8.8. Zlib-1.3.1

The Zlib package contains compression and decompression routines used by some programs.

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

8.8.1. Installation of Zlib

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

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

pkgname="zlib"
pkgver="1.3.1"
pkgrel="1"
pkgdesc="The Zlib package contains compression and decompression routines used by some programs."
arch=('x86'
      'x86_64')
url="https://zlib.net/"
license=('custom'
         'MIT')
groups=('core')
depends=('glibc')
makedepends=('bash'
             'binutils'
             'coreutils'
             'gcc'
             'make'
             'sed')
source=('https://zlib.net/fossils/zlib-1.3.1.tar.gz')
md5sums=('9855b6d802d7fe5b7bd5b196a2271655')

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

Update the local cache and install the Zlib package:

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

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

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

8.8.2. Contents of Zlib

Installed libraries: libz.so

Short Descriptions

libz

Contains compression and decompression functions used by some programs