8.117. Libxml2-2.13.6

8.117.1. Introduction to libxml2

The libxml2 package contains libraries and utilities used for parsing XML files.

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

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

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

pkgname="libxml2"
pkgver="2.13.6"
pkgrel="1"
pkgdesc="The libxml2 package contains libraries and utilities used for parsing XML files."
arch=('x86'
      'x86_64')
url="http://xmlsof.org/"
license=('GPL3')
groups=('core')
depends=('glibc')
makedepends=('bash'
             'binutils'
             'coreutils'
             'gcc'
             'make')
source=('https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.6.tar.xz')
md5sums=('85dffa2387ff756bdf8b3b247594914a')

build(){
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr    \
              --disable-static \
              --with-history   \
              --with-python=/usr/bin/python3
  make
}

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

Update the local cache and install the libxml2 package:

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

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

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

8.117.3. Command Explanations

--with-history: This switch enables Readline support when running xmlcatalog or xmllint in shell mode.

--with-python=/usr/bin/python3: Allows building the libxml2 module with Python3 instead of Python2.

--with-threads: Add this switch to enable multithread support.

8.117.4. Contents

Installed Programs: xml2-config, xmlcatalog, and xmllint
Installed Libraries: libxml2.so and libxml2mod.so (Python3 module)
Installed Directories: /usr/include/libxml2, /usr/lib/cmake/libxml2, /usr/share/doc/libxml2-2.13.6, /usr/share/doc/libxml2-python-2.13.6, and /usr/share/gtk-doc/html/libxml2

Short Descriptions

xml2-config

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

xmlcatalog

is used to monitor and manipulate XML and SGML catalogs.

xmllint

parses XML files and outputs reports (based upon options) to detect errors in XML coding.

libxml2.so

provides functions for programs to parse files that use the XML format.

libxml2mod.so

is the interface for Python3 to use libxml2.so.