| 1 |
agriffis |
1.1 |
#!/bin/bash
|
| 2 |
vapier |
1.17 |
# $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.16 2012/03/28 18:46:29 vapier Exp $
|
| 3 |
agriffis |
1.1 |
#
|
| 4 |
|
|
# build-docbook-catalog: populate /etc/xml/docbook based in
|
| 5 |
|
|
# installed docbook-xml-dtd versions.
|
| 6 |
|
|
#
|
| 7 |
vapier |
1.8 |
# Copyright 2004-2012 Gentoo Foundation
|
| 8 |
agriffis |
1.1 |
# Distributed under the terms of the GNU General Public License v2
|
| 9 |
|
|
# written by Aron Griffis
|
| 10 |
|
|
#
|
| 11 |
|
|
|
| 12 |
vapier |
1.13 |
ROOTCONFDIR=/etc/xml
|
| 13 |
|
|
ROOTCATALOG=${ROOTCONFDIR}/catalog
|
| 14 |
|
|
CATALOG=${ROOTCONFDIR}/docbook
|
| 15 |
agriffis |
1.1 |
DOCBOOKDIR=/usr/share/sgml/docbook
|
| 16 |
|
|
DTDS=
|
| 17 |
|
|
LATEST_DTD=
|
| 18 |
|
|
LATEST_DATE=
|
| 19 |
agriffis |
1.2 |
VERBOSE=false
|
| 20 |
|
|
ZERO=${0##*/}
|
| 21 |
agriffis |
1.1 |
|
| 22 |
|
|
#
|
| 23 |
vapier |
1.9 |
# usage!
|
| 24 |
|
|
#
|
| 25 |
|
|
usage() {
|
| 26 |
|
|
cat <<-EOF
|
| 27 |
|
|
Usage: ${ZERO} [options]
|
| 28 |
|
|
|
| 29 |
|
|
Options:
|
| 30 |
|
|
-v, --verbose Be verbose
|
| 31 |
|
|
-h, --help This!
|
| 32 |
|
|
EOF
|
| 33 |
|
|
[[ $# -gt 0 ]] && eerror "$*"
|
| 34 |
|
|
exit 0
|
| 35 |
|
|
}
|
| 36 |
|
|
|
| 37 |
|
|
#
|
| 38 |
agriffis |
1.1 |
# main (called from bottom)
|
| 39 |
|
|
#
|
| 40 |
|
|
main() {
|
| 41 |
vapier |
1.10 |
local d v opts
|
| 42 |
agriffis |
1.2 |
|
| 43 |
vapier |
1.16 |
opts=$(getopt -o hv --long help,verbose -n "${ZERO}" -- "$@") || exit 1
|
| 44 |
|
|
eval set -- "${opts}"
|
| 45 |
agriffis |
1.2 |
while true; do
|
| 46 |
vapier |
1.16 |
case $1 in
|
| 47 |
vapier |
1.9 |
-h|--help) usage ;;
|
| 48 |
|
|
-v|--verbose) VERBOSE=true ;;
|
| 49 |
|
|
--) break ;;
|
| 50 |
|
|
*) usage "options parsing failed on $1!" ;;
|
| 51 |
agriffis |
1.2 |
esac
|
| 52 |
vapier |
1.9 |
shift
|
| 53 |
agriffis |
1.2 |
done
|
| 54 |
agriffis |
1.1 |
|
| 55 |
|
|
create_catalogs # will exit on error
|
| 56 |
flameeyes |
1.3 |
for type in xsl xsl-ns xsl-saxon xsl-xalan; do
|
| 57 |
vapier |
1.16 |
populate_xsl ${type}
|
| 58 |
flameeyes |
1.3 |
done
|
| 59 |
agriffis |
1.1 |
|
| 60 |
|
|
# Clean out old dtds from catalog
|
| 61 |
agriffis |
1.2 |
verb "Cleaning out old DocBook XML versions from ${CATALOG} and ${ROOTCATALOG}"
|
| 62 |
vapier |
1.15 |
clean_catalog "${DOCBOOKDIR}/xml\(-simple\)*-dtd-[^/\"']*/[^/\"']*" "${CATALOG}"
|
| 63 |
|
|
clean_catalog "${DOCBOOKDIR}/xml\(-simple\)*-dtd-[^/\"']*/[^/\"']*" "${ROOTCATALOG}"
|
| 64 |
agriffis |
1.1 |
|
| 65 |
|
|
if set_dtds; then
|
| 66 |
|
|
for d in ${DTDS}; do
|
| 67 |
|
|
populate_dtd ${d}
|
| 68 |
|
|
done
|
| 69 |
flameeyes |
1.6 |
for d in ${SIMPLE_DTDS}; do
|
| 70 |
|
|
populate_simple_dtd ${d}
|
| 71 |
|
|
done
|
| 72 |
agriffis |
1.1 |
populate_entities
|
| 73 |
|
|
fi
|
| 74 |
|
|
|
| 75 |
|
|
exit 0
|
| 76 |
|
|
}
|
| 77 |
|
|
|
| 78 |
vapier |
1.7 |
#
|
| 79 |
agriffis |
1.2 |
# verbose echo -- only echo if called with --verbose
|
| 80 |
|
|
#
|
| 81 |
|
|
verb() {
|
| 82 |
vapier |
1.16 |
${VERBOSE} && echo "$*"
|
| 83 |
agriffis |
1.2 |
}
|
| 84 |
|
|
|
| 85 |
agriffis |
1.1 |
#
|
| 86 |
vapier |
1.8 |
# show an error and abort
|
| 87 |
|
|
#
|
| 88 |
|
|
error() {
|
| 89 |
|
|
printf '%s: %b, aborting\n' "${ZERO}" "$*" 1>&2
|
| 90 |
|
|
exit 1
|
| 91 |
|
|
}
|
| 92 |
|
|
|
| 93 |
|
|
#
|
| 94 |
agriffis |
1.1 |
# fill in the DTDS variable based on installed versions
|
| 95 |
vapier |
1.7 |
#
|
| 96 |
agriffis |
1.1 |
set_dtds() {
|
| 97 |
vapier |
1.11 |
DTDS= SIMPLE_DTS=
|
| 98 |
|
|
|
| 99 |
|
|
if [[ -d ${DOCBOOKDIR} ]] ; then
|
| 100 |
vapier |
1.15 |
DTDS=$(find "${DOCBOOKDIR}" -path '*/xml-dtd-*/docbookx.dtd')
|
| 101 |
|
|
SIMPLE_DTDS=$(find "${DOCBOOKDIR}" -path '*/xml-simple-dtd-*/sdocbook.dtd')
|
| 102 |
vapier |
1.11 |
fi
|
| 103 |
|
|
|
| 104 |
agriffis |
1.1 |
if [[ -z ${DTDS} ]]; then
|
| 105 |
|
|
echo "No installed DocBook XML DTDs found"
|
| 106 |
|
|
return 1
|
| 107 |
|
|
else
|
| 108 |
|
|
return 0
|
| 109 |
|
|
fi
|
| 110 |
|
|
}
|
| 111 |
|
|
|
| 112 |
|
|
#
|
| 113 |
vapier |
1.14 |
# multi_xmlcatalog_add <file> <opts array>
|
| 114 |
|
|
#
|
| 115 |
|
|
# the opts array is a set of three: what gets passed to --add
|
| 116 |
|
|
#
|
| 117 |
|
|
multi_xmlcatalog_add() {
|
| 118 |
|
|
local file=$1
|
| 119 |
|
|
shift
|
| 120 |
|
|
|
| 121 |
|
|
while [[ $# -gt 0 ]] ; do
|
| 122 |
|
|
xmlcatalog --noout --add "$1" "$2" "file://$3" "${file}"
|
| 123 |
|
|
shift 3
|
| 124 |
|
|
done
|
| 125 |
|
|
}
|
| 126 |
|
|
|
| 127 |
|
|
#
|
| 128 |
agriffis |
1.1 |
# create the catalogs root and docbook specific
|
| 129 |
|
|
#
|
| 130 |
|
|
create_catalogs() {
|
| 131 |
vapier |
1.14 |
local adds
|
| 132 |
|
|
|
| 133 |
vapier |
1.13 |
if [[ ! -d ${ROOTCONFDIR} ]] ; then
|
| 134 |
|
|
mkdir -p "${ROOTCONFDIR}" || error "could not create ${ROOTCONFDIR}"
|
| 135 |
|
|
fi
|
| 136 |
|
|
|
| 137 |
agriffis |
1.1 |
if [[ ! -r ${ROOTCATALOG} ]] ; then
|
| 138 |
|
|
echo "Creating XML Catalog root ${ROOTCATALOG}"
|
| 139 |
vapier |
1.15 |
xmlcatalog --noout --create "${ROOTCATALOG}"
|
| 140 |
agriffis |
1.1 |
if [[ ! -r ${ROOTCATALOG} ]] ; then
|
| 141 |
vapier |
1.8 |
error "failed creating ${ROOTCATALOG}"
|
| 142 |
agriffis |
1.1 |
fi
|
| 143 |
|
|
else
|
| 144 |
agriffis |
1.2 |
verb "Found XML Catalog root ${ROOTCATALOG}"
|
| 145 |
agriffis |
1.1 |
# clean out existing entries
|
| 146 |
agriffis |
1.2 |
verb " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}"
|
| 147 |
vapier |
1.15 |
clean_catalog "file://${CATALOG}" "${ROOTCATALOG}"
|
| 148 |
agriffis |
1.1 |
fi
|
| 149 |
|
|
|
| 150 |
|
|
if [[ ! -r ${CATALOG} ]] ; then
|
| 151 |
|
|
echo "Creating DocBook XML Catalog ${CATALOG}"
|
| 152 |
vapier |
1.15 |
xmlcatalog --noout --create "${CATALOG}"
|
| 153 |
agriffis |
1.1 |
if [[ ! -r ${CATALOG} ]] ; then
|
| 154 |
vapier |
1.8 |
error "failed creating ${CATALOG}"
|
| 155 |
agriffis |
1.1 |
fi
|
| 156 |
|
|
else
|
| 157 |
agriffis |
1.2 |
verb "Found DocBook XML Catalog ${CATALOG}"
|
| 158 |
agriffis |
1.1 |
fi
|
| 159 |
|
|
|
| 160 |
|
|
# dtd pointers
|
| 161 |
agriffis |
1.2 |
verb " Populating ${ROOTCATALOG} with DTD delegates to ${CATALOG}"
|
| 162 |
vapier |
1.14 |
adds=(
|
| 163 |
|
|
"delegatePublic" "-//OASIS//ENTITIES DocBook" "${CATALOG}"
|
| 164 |
|
|
"delegatePublic" "-//OASIS//ELEMENTS DocBook" "${CATALOG}"
|
| 165 |
|
|
"delegatePublic" "-//OASIS//DTD DocBook" "${CATALOG}"
|
| 166 |
|
|
"delegateSystem" "http://www.oasis-open.org/docbook/" "${CATALOG}"
|
| 167 |
|
|
"delegateURI" "http://www.oasis-open.org/docbook/" "${CATALOG}"
|
| 168 |
|
|
)
|
| 169 |
|
|
multi_xmlcatalog_add "${ROOTCATALOG}" "${adds[@]}"
|
| 170 |
agriffis |
1.1 |
|
| 171 |
|
|
# entities pointer
|
| 172 |
agriffis |
1.2 |
verb " Populating ${ROOTCATALOG} with ISO entities delegate to ${CATALOG}"
|
| 173 |
vapier |
1.14 |
adds=(
|
| 174 |
|
|
"delegatePublic" "ISO 8879:1986" "${CATALOG}"
|
| 175 |
|
|
)
|
| 176 |
|
|
multi_xmlcatalog_add "${ROOTCATALOG}" "${adds[@]}"
|
| 177 |
agriffis |
1.1 |
}
|
| 178 |
|
|
|
| 179 |
|
|
#
|
| 180 |
|
|
# clean_catalog
|
| 181 |
|
|
# $1 == regex to clean
|
| 182 |
|
|
# $2 == catalog
|
| 183 |
|
|
#
|
| 184 |
|
|
clean_catalog() {
|
| 185 |
vapier |
1.10 |
local list f regex=$1 catalog=$2
|
| 186 |
agriffis |
1.1 |
|
| 187 |
|
|
list=$(egrep --only-matching "${regex}" "${catalog}" | sort -u)
|
| 188 |
|
|
for f in ${list}; do
|
| 189 |
vapier |
1.15 |
xmlcatalog --noout --del "${f}" "${catalog}"
|
| 190 |
agriffis |
1.1 |
done
|
| 191 |
|
|
}
|
| 192 |
|
|
|
| 193 |
vapier |
1.7 |
#
|
| 194 |
agriffis |
1.1 |
# populate a specific dtd version into the docbook catalog
|
| 195 |
|
|
# $1 == /path/to/docbookx.dtd
|
| 196 |
|
|
#
|
| 197 |
|
|
populate_dtd() {
|
| 198 |
vapier |
1.10 |
local dtd=$1 docbookdir=${1%/*} dtd_date
|
| 199 |
vapier |
1.14 |
local v=${docbookdir##*-} adds
|
| 200 |
agriffis |
1.1 |
|
| 201 |
|
|
# sanity check
|
| 202 |
|
|
if [[ ${dtd} != */xml-dtd-*/* ]]; then
|
| 203 |
|
|
echo "Warning: I don't understand \"${dtd}\"" >&2
|
| 204 |
|
|
return
|
| 205 |
|
|
fi
|
| 206 |
|
|
echo "Found DocBook XML ${v} in ${docbookdir}"
|
| 207 |
|
|
|
| 208 |
|
|
# Populate the docbook catalog with this version
|
| 209 |
agriffis |
1.2 |
verb " Populating ${CATALOG} based on ${docbookdir}"
|
| 210 |
vapier |
1.14 |
adds=(
|
| 211 |
|
|
"public" "-//OASIS//ELEMENTS DocBook XML Information Pool V${v}//EN" "${docbookdir}/dbpoolx.mod"
|
| 212 |
|
|
"public" "-//OASIS//DTD DocBook XML V${v}//EN" "${docbookdir}/docbookx.dtd"
|
| 213 |
|
|
"public" "-//OASIS//ENTITIES DocBook XML Character Entities V${v}//EN" "${docbookdir}/dbcentx.mod"
|
| 214 |
|
|
"public" "-//OASIS//ENTITIES DocBook XML Notations V${v}//EN" "${docbookdir}/dbnotnx.mod"
|
| 215 |
|
|
"public" "-//OASIS//ENTITIES DocBook XML Additional General Entities V${v}//EN" "${docbookdir}/dbgenent.mod"
|
| 216 |
|
|
"public" "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V${v}//EN" "${docbookdir}/dbhierx.mod"
|
| 217 |
|
|
"public" "-//OASIS//DTD XML Exchange Table Model 19990315//EN" "${docbookdir}/soextblx.dtd"
|
| 218 |
|
|
"public" "-//OASIS//DTD DocBook XML CALS Table Model V${v}//EN" "${docbookdir}/calstblx.dtd"
|
| 219 |
|
|
"rewriteSystem" "http://www.oasis-open.org/docbook/xml/${v}" "${docbookdir}"
|
| 220 |
|
|
"rewriteURI" "http://www.oasis-open.org/docbook/xml/${v}" "${docbookdir}"
|
| 221 |
|
|
)
|
| 222 |
|
|
multi_xmlcatalog_add "${CATALOG}" "${adds[@]}"
|
| 223 |
agriffis |
1.1 |
|
| 224 |
|
|
# grab the RCS date from docbookx.dtd for comparison purposes
|
| 225 |
|
|
if [[ ! -f ${docbookdir}/ent/iso-lat1.ent ]]; then
|
| 226 |
agriffis |
1.2 |
verb " No entities available for ${dtd}"
|
| 227 |
agriffis |
1.1 |
return 0
|
| 228 |
|
|
fi
|
| 229 |
|
|
dtd_date=$(egrep --only-matching --max-count=1 \
|
| 230 |
|
|
'[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}' "${dtd}")
|
| 231 |
|
|
if [[ -z ${dtd_date} ]]; then
|
| 232 |
agriffis |
1.2 |
verb " Couldn't find RCS date in ${dtd}, ignoring entities"
|
| 233 |
agriffis |
1.1 |
return 0
|
| 234 |
|
|
fi
|
| 235 |
agriffis |
1.2 |
verb " RCS datestamp in ${dtd} is ${dtd_date}"
|
| 236 |
vapier |
1.16 |
dtd_date=$(date -d "${dtd_date}" +%s)
|
| 237 |
|
|
if [[ ${dtd_date} -gt ${LATEST_DATE:-0} ]] ; then
|
| 238 |
agriffis |
1.1 |
LATEST_DATE=${dtd_date}
|
| 239 |
|
|
LATEST_DTD=${dtd}
|
| 240 |
|
|
fi
|
| 241 |
|
|
}
|
| 242 |
|
|
|
| 243 |
vapier |
1.7 |
#
|
| 244 |
flameeyes |
1.6 |
# populate a specific simple dtd version into the docbook catalog
|
| 245 |
|
|
# $1 == /path/to/sdocbook.dtd
|
| 246 |
|
|
#
|
| 247 |
|
|
populate_simple_dtd() {
|
| 248 |
vapier |
1.10 |
local dtd=$1 docbookdir=${1%/*}
|
| 249 |
vapier |
1.14 |
local v=${docbookdir##*-} adds
|
| 250 |
flameeyes |
1.6 |
|
| 251 |
|
|
# sanity check
|
| 252 |
|
|
if [[ ${dtd} != */xml-simple-dtd-*/* ]]; then
|
| 253 |
|
|
echo "Warning: I don't understand \"${dtd}\"" >&2
|
| 254 |
|
|
return
|
| 255 |
|
|
fi
|
| 256 |
|
|
echo "Found Simplified DocBook XML ${v} in ${docbookdir}"
|
| 257 |
|
|
|
| 258 |
|
|
# Populate the docbook catalog with this version
|
| 259 |
|
|
verb " Populating ${CATALOG} based on ${docbookdir}"
|
| 260 |
vapier |
1.14 |
adds=(
|
| 261 |
|
|
"public" "-//OASIS//DTD Simplified DocBook XML V${v}//EN" "${docbookdir}/sdocbook.dtd"
|
| 262 |
|
|
"rewriteSystem" "http://www.oasis-open.org/docbook/xml/simple/${v}" "${docbookdir}"
|
| 263 |
|
|
"rewriteURI" "http://www.oasis-open.org/docbook/xml/simple/${v}" "${docbookdir}"
|
| 264 |
|
|
)
|
| 265 |
|
|
multi_xmlcatalog_add "${CATALOG}" "${adds[@]}"
|
| 266 |
flameeyes |
1.6 |
}
|
| 267 |
|
|
|
| 268 |
agriffis |
1.1 |
#
|
| 269 |
|
|
# populate ISO DocBook entities from the most recent DTD
|
| 270 |
|
|
#
|
| 271 |
|
|
populate_entities() {
|
| 272 |
vapier |
1.10 |
local isodir=${LATEST_DTD%/*}/ent i j
|
| 273 |
|
|
local entities=() avail=()
|
| 274 |
agriffis |
1.1 |
|
| 275 |
|
|
# sanity check
|
| 276 |
|
|
if [[ -z ${LATEST_DTD} || ! -d ${isodir} ]]; then
|
| 277 |
|
|
echo "No ISO DocBook entities available for catalog"
|
| 278 |
|
|
return 0
|
| 279 |
|
|
fi
|
| 280 |
|
|
echo "Using ISO DocBook entities from ${isodir}"
|
| 281 |
|
|
|
| 282 |
|
|
# here are the entities we know about;
|
| 283 |
|
|
# note these must remain sorted!
|
| 284 |
|
|
entities=(
|
| 285 |
|
|
"iso-amsa.ent" "ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN"
|
| 286 |
|
|
"iso-amsb.ent" "ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN"
|
| 287 |
|
|
"iso-amsc.ent" "ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN"
|
| 288 |
|
|
"iso-amsn.ent" "ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN"
|
| 289 |
|
|
"iso-amso.ent" "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN"
|
| 290 |
|
|
"iso-amsr.ent" "ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN"
|
| 291 |
|
|
"iso-box.ent" "ISO 8879:1986//ENTITIES Box and Line Drawing//EN"
|
| 292 |
|
|
"iso-cyr1.ent" "ISO 8879:1986//ENTITIES Russian Cyrillic//EN"
|
| 293 |
|
|
"iso-cyr2.ent" "ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN"
|
| 294 |
|
|
"iso-dia.ent" "ISO 8879:1986//ENTITIES Diacritical Marks//EN"
|
| 295 |
|
|
"iso-grk1.ent" "ISO 8879:1986//ENTITIES Greek Letters//EN"
|
| 296 |
|
|
"iso-grk2.ent" "ISO 8879:1986//ENTITIES Monotoniko Greek//EN"
|
| 297 |
|
|
"iso-grk3.ent" "ISO 8879:1986//ENTITIES Greek Symbols//EN"
|
| 298 |
|
|
"iso-grk4.ent" "ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN"
|
| 299 |
|
|
"iso-lat1.ent" "ISO 8879:1986//ENTITIES Added Latin 1//EN"
|
| 300 |
|
|
"iso-lat2.ent" "ISO 8879:1986//ENTITIES Added Latin 2//EN"
|
| 301 |
|
|
"iso-num.ent" "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN"
|
| 302 |
|
|
"iso-pub.ent" "ISO 8879:1986//ENTITIES Publishing//EN"
|
| 303 |
|
|
"iso-tech.ent" "ISO 8879:1986//ENTITIES General Technical//EN"
|
| 304 |
|
|
)
|
| 305 |
|
|
|
| 306 |
|
|
# here are the entities available; assume no spaces in filenames...
|
| 307 |
vapier |
1.15 |
avail=($(ls "${isodir}" | sort))
|
| 308 |
agriffis |
1.1 |
|
| 309 |
|
|
# double-check the lists
|
| 310 |
agriffis |
1.2 |
verb " Populating ${CATALOG} with ISO DocBook entities"
|
| 311 |
agriffis |
1.1 |
i=0 ; j=0
|
| 312 |
|
|
while [[ ${i} -lt ${#entities[@]} || ${j} -lt ${#avail[@]} ]]; do
|
| 313 |
|
|
if [[ ${i} -ge ${#entities[@]} ]]; then
|
| 314 |
|
|
echo "Warning: Extra ISO entities file: ${avail[j]}"
|
| 315 |
|
|
let j=j+1
|
| 316 |
|
|
elif [[ ${j} -ge ${#avail[@]} ]]; then
|
| 317 |
|
|
echo "Warning: Entities file not found: ${entities[i]}"
|
| 318 |
|
|
let i=i+2
|
| 319 |
|
|
elif [[ ${avail[j]} < ${entities[i]} ]]; then
|
| 320 |
|
|
echo "Warning: Extra ISO entities file: ${avail[j]}"
|
| 321 |
|
|
let j=j+1
|
| 322 |
|
|
elif [[ ${entities[i]} < ${avail[j]} ]]; then
|
| 323 |
|
|
echo "Warning: Entities file not found: ${entities[i]}"
|
| 324 |
|
|
let i=i+2
|
| 325 |
|
|
elif [[ ${entities[i]} == ${avail[j]} ]]; then
|
| 326 |
|
|
xmlcatalog --noout --add "public" "${entities[i+1]}" \
|
| 327 |
vapier |
1.15 |
"file://${isodir}/${entities[i]}" "${CATALOG}"
|
| 328 |
agriffis |
1.1 |
let j=j+1
|
| 329 |
|
|
let i=i+2
|
| 330 |
|
|
else
|
| 331 |
vapier |
1.8 |
error "${0}: whoah, shouldn't be here"
|
| 332 |
agriffis |
1.1 |
fi
|
| 333 |
|
|
done
|
| 334 |
|
|
}
|
| 335 |
|
|
|
| 336 |
|
|
#
|
| 337 |
|
|
# populate XSL stylesheets
|
| 338 |
|
|
#
|
| 339 |
|
|
populate_xsl() {
|
| 340 |
vapier |
1.14 |
local f adds
|
| 341 |
agriffis |
1.1 |
|
| 342 |
flameeyes |
1.3 |
# This is either xsl, xsl-ns, xsl-saxon or xsl-xalan
|
| 343 |
|
|
local type=$1
|
| 344 |
|
|
|
| 345 |
|
|
# Delete current entries from the catalog (delete legacy versioned entries too)
|
| 346 |
vapier |
1.15 |
clean_catalog "${DOCBOOKDIR}/${type}-stylesheets(-[0-9\.]+)?" "${CATALOG}"
|
| 347 |
|
|
clean_catalog "${DOCBOOKDIR}/${type}-stylesheets(-[0-9\.]+)?" "${ROOTCATALOG}"
|
| 348 |
flameeyes |
1.3 |
|
| 349 |
vapier |
1.17 |
local xsldir=${DOCBOOKDIR}/${type}-stylesheets
|
| 350 |
flameeyes |
1.3 |
|
| 351 |
|
|
if [[ ! -d ${xsldir} ]]; then
|
| 352 |
|
|
echo "DocBook XSL stylesheets (${type}) not found" >&2
|
| 353 |
agriffis |
1.1 |
return 1
|
| 354 |
|
|
fi
|
| 355 |
flameeyes |
1.3 |
|
| 356 |
agriffis |
1.1 |
if [[ ! -e ${xsldir}/html/docbook.xsl || ! -e ${xsldir}/common/l10n.xml ]]; then
|
| 357 |
flameeyes |
1.3 |
echo "DocBook XSL stylesheets are missing files from ${xsldir}" >&2
|
| 358 |
agriffis |
1.1 |
return 1
|
| 359 |
|
|
fi
|
| 360 |
|
|
|
| 361 |
|
|
# Populate catalog with XSL entries
|
| 362 |
flameeyes |
1.3 |
echo "Found DocBook XSL stylesheets (${type}) in ${xsldir}"
|
| 363 |
flameeyes |
1.4 |
|
| 364 |
|
|
verb " Populating ${ROOTCATALOG} with XSL delegations"
|
| 365 |
vapier |
1.14 |
adds=(
|
| 366 |
|
|
"delegateSystem" "http://docbook.sourceforge.net/release/${type}/" "${CATALOG}"
|
| 367 |
|
|
"delegateURI" "http://docbook.sourceforge.net/release/${type}/" "${CATALOG}"
|
| 368 |
|
|
)
|
| 369 |
|
|
multi_xmlcatalog_add "${ROOTCATALOG}" "${adds[@]}"
|
| 370 |
flameeyes |
1.4 |
|
| 371 |
agriffis |
1.2 |
verb " Populating ${CATALOG} with XSL stylesheets"
|
| 372 |
vapier |
1.14 |
adds=(
|
| 373 |
|
|
"rewriteSystem" "http://docbook.sourceforge.net/release/${type}/current" "${xsldir}"
|
| 374 |
|
|
"rewriteURI" "http://docbook.sourceforge.net/release/${type}/current" "${xsldir}"
|
| 375 |
|
|
)
|
| 376 |
|
|
multi_xmlcatalog_add "${CATALOG}" "${adds[@]}"
|
| 377 |
agriffis |
1.1 |
}
|
| 378 |
|
|
|
| 379 |
|
|
# Call the main routine
|
| 380 |
agriffis |
1.2 |
main "$@"
|