8.119.1. Installation of SGML Common
Create the PKGBUILD for the sgml-common package with the following
commands:
mkdir /sources/sgml-common
cd /sources/sgml-common
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>
pkgname="sgml-common"
pkgver="0.6.3"
pkgrel="1"
pkgdesc="The SGML Common package contains install-catalog. This is useful for creating and maintaining centralized SGML catalogs."
arch=('any')
url="https:///sourceware.org/"
install=sgml-common.install
depends=('rootfs')
makedepends=('autoconf'
'automake'
'bash'
'binutils'
'coreutils'
'make'
'patch')
source=('https://sourceware.org/ftp/docbook-tools/new-trials/SOURCES/sgml-common-0.6.3.tgz'
'https://www.linuxfromscratch.org/patches/lfs/development/sgml-common-0.6.3-manpage-1.patch')
md5sums=('103c9828f24820df86e55e7862e28974'
'https://www.linuxfromscratch.org/patches/lfs/development/645f3c898abd270a9143036824ae121a')
prepare(){
cd "${pkgname}-${pkgver}"
# Instead of the normal convention of including the autotools files
# in the package, the maintainers included symlinks to the files in
# /usr/share/automake. For previous versions of Automake this convention
# is correct, but recent versions of Automake install the internal files
# in version specific directories. This causes the configure script to
# abort. To fix this error, the autotools are regenerated. Since the
# included Makefile.am file uses a syntax not supported by current
# versions of Automake, a patch is required to fix the syntax.
patch -Np1 -i "${srcdir}/${pkgname}-${pkgver}-manpage-1.patch
autoreconf -fi
}
build(){
cd "${pkgname}-${pkgver}"
./configure --prefix=/usr --sysconfdir=/etc
make
}
package(){
cd "${pkgname}-${pkgver}"
make DESTDIR="${pkgdir}" docdir=/usr/share/doc install
}
REALEOF
Create the install file to install catalogs after intallation:
cat > PKGBUILD << "REALEOF"
# sgml-common.install
# Taken from Arch Linux - Thanks
# arg 1: the new package version
pre_install() {
/bin/true
}
# arg 1: the new package version
post_install() {
add_catalog "${1%-*}"
}
# arg 1: the new package version
# arg 2: the old package version
pre_upgrade() {
remove_catalog "${2%-*}"
}
# arg 1: the new package version
# arg 2: the old package version
post_upgrade() {
add_catalog "${1%-*}"
}
# arg 1: the old package version
pre_remove() {
remove_catalog "${1%-*}"
}
# arg 1: the old package version
post_remove() {
/bin/true
}
add_catalog() {
install-catalog --add /etc/sgml/sgml-ent.cat \
/usr/share/sgml/sgml-iso-entities-8879.1986/catalog > /dev/null 2>&1
install-catalog --add /etc/sgml/sgml-docbook.cat \
/etc/sgml/sgml-ent.cat > /dev/null 2>&1
}
remove_catalog() {
install-catalog --remove /etc/sgml/sgml-ent.cat \
/usr/share/sgml/sgml-iso-entities-8879.1986/catalog > /dev/null 2>&1
install-catalog --remove /etc/sgml/sgml-docbook.cat \
/etc/sgml/sgml-ent.cat > /dev/null 2>&1
}
op=$1
shift
$op "$@"
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 sgml-common-0.6.3-1-any.pkg.tar.xz \
/srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
/srv/pacman/repos/LFS/sgml-common-0.6.3-1-any.pkg.tar.xz
Update the local cache and install the sgml-common package:
pacman -Syu
pacman -S sgml-common --overwrite \* -dd --noconfirm
Finally, copy the source files into the source repository and clean
up the build directory:
mkdir /srv/pacman/source/LFS/sgml-common
cp PKGBUILD /srv/pacman/source/LFS/sgml-common
cd /sources
rm -rf sgml-common