#!/bin/bash
# $Id: gen-special.sh 21 2012-02-16 15:06:19Z labastie $
#-------------------------------------------------------------------------
# generates an xsl stylesheet containing a template for special
# cases in the book:
# - If the version does not begin with a number, it is impossible to know
# where the package name ends and where the version begins. We therefore
# use the ENTITY at the beginning of the validated full-xml.
# - If a package is part of a group of xorg packages (proto, fonts, etc)
# there is no easy way to extract it from the xml. We use the ENTITY at
# the top of each file x7*.xml
# - Some non-versioned packages are needed as dependencies of others: we
# attribute version 1.0.0 to them. It is just used to know if the package
# is installed, by checking inst-version.
# - If a package is versioned but the version is not mentioned in the book
# (currently only udev), we retrieve the version by other means
#-------------------------------------------------------------------------
# Arguments:
# $1 contains the name of the validated xml book
# $2 contains the name of the ouput xsl file
# $3 contains the name of the book sources directory
#-------------------------------------------------------------------------
BLFS_XML=$1
if ! test -f ${BLFS_XML}; then
echo File \`${BLFS_XML}\' does not exist
exit 1
fi
SPECIAL_FILE=$2
if test -z "${SPECIAL_FILE}"; then SPECIAL_FILE=specialCases.xsl;fi
BLFS_DIR=$3
if test -z "${BLFS_DIR}"; then BLFS_DIR=$(cd $(dirname ${BLFS_XML})/.. ; pwd);fi
# Packages whose version does not begin with a number
EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' ${BLFS_DIR}/packages.ent |
sed 's@^[^"]*"\([^"]*\)".*@\1@')
# Non-versioned packages:
NV_LIST="cacerts xorg-env kde-pre-install-config kf5-intro lxqt-pre-install \
ojdk-conf tex-path"
# Set PATH to be sure to find udevadm
SAVPATH=$PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin
UDEVVERSION=$(udevadm --version)
cat >$SPECIAL_FILE << EOF