8.9.1. Installation of Bzip2
Create the PKGBUILD for the Bzip2 package with the following
commands:
mkdir /sources/bzip2
cd /sources/bzip2
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>
pkgname="bzip2"
pkgver="1.0.8"
pkgrel="2"
pkgdesc="The Bzip2 package contains programs for compressing and decompressing files with bzip2 compression."
arch=('x86'
'x86_64')
url="https://sourceware.org/bzip2/"
groups=('core')
license=('BSD3C'
'custom')
depends=('glibc')
makedepends=('bash'
'binutils'
'coreutils'
'diffutils'
'gcc'
'make'
'patch')
source=('https://www.sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz'
'https://www.linuxfromscratch.org/patches/lfs/development/bzip2-1.0.8-install_docs-1.patch')
md5sums=('67e051268d0c475ea773822f7500d0e5'
'6a5ac7e89b791aae556de0f745916f7f')
prepare(){
cd ${srcdir}/${pkgname}-${pkgver}
patch -Np1 -i ${srcdir}/${pkgname}-${pkgver}-install_docs-1.patch
sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile
# Add largefile support to libbz2
sed -e 's/^CFLAGS=\(.*\)$/CFLAGS=\1 \$(BIGFILES)/' \
-i Makefile-libbz2_so
# Use makepkg's CFLAGS
sed "s|-O2|${CFLAGS}|g" -i Makefile
sed "s|-O2|${CFLAGS}|g" -i Makefile-libbz2_so
}
build(){
cd ${srcdir}/${pkgname}-${pkgver}
make -f Makefile-libbz2_so
make clean
make
}
check(){
cd ${srcdir}/${pkgname}-${pkgver}
make test
}
package(){
cd "${srcdir}/${pkgname}-${pkgver}"
make PREFIX="${pkgdir}/usr" install
install -vm755 libbz2.so.* "${pkgdir}/usr/lib"
ln -sv "libbz2.so.${pgkver}" "${pkgdir}/usr/lib/libbz2.so"
install -vm755 bzip2-shared "${pkgdir}/usr/bin/bzip2"
rm -v "${pkgdir}"/usr/bin/{bunzip2,bzcat}
ln -sv bzip2 "${pkgdir}/usr/bin/bunzip2"
ln -sv bsip2 "${pkgdir}/usr/bin/bzcat"
}
REALEOF
The meaning of the make parameter:
-
-f
Makefile-libbz2_so
-
This will cause Bzip2 to be built using a different
Makefile file, in this case the
Makefile-libbz2_so file, which
creates a dynamic libbz2.so
library and links the Bzip2 utilities against 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 bzip2-1.0.8-2-$(uname -m).pkg.tar.xz \
/srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
/srv/pacman/repos/LFS/bzip2-1.0.8-2-$(uname -m).pkg.tar.xz
Update the local cache and install the Bzip2 package:
pacman -Syu
pacman -S bzip2 --overwrite \* -dd --noconfirm
Finally, copy the source files into the source repository and clean
up the build directory:
mkdir /srv/pacman/source/LFS/bzip2
cp PKGBUILD /srv/pacman/source/LFS/bzip2
cd /sources
rm -rf bzip2