/[gentoo-src]/build-docbook-catalog/build-docbook-catalog
Gentoo

Diff of /build-docbook-catalog/build-docbook-catalog

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.13 Revision 1.14
1#!/bin/bash 1#!/bin/bash
2# $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.13 2012/03/27 22:46:32 vapier Exp $ 2# $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.14 2012/03/27 22:50:44 vapier Exp $
3# 3#
4# build-docbook-catalog: populate /etc/xml/docbook based in 4# build-docbook-catalog: populate /etc/xml/docbook based in
5# installed docbook-xml-dtd versions. 5# installed docbook-xml-dtd versions.
6# 6#
7# Copyright 2004-2012 Gentoo Foundation 7# Copyright 2004-2012 Gentoo Foundation
108 return 0 108 return 0
109 fi 109 fi
110} 110}
111 111
112# 112#
113# multi_xmlcatalog_add <file> <opts array>
114#
115# the opts array is a set of three: what gets passed to --add
116#
117multi_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#
113# create the catalogs root and docbook specific 128# create the catalogs root and docbook specific
114# 129#
115create_catalogs() { 130create_catalogs() {
131 local adds
132
116 if [[ ! -d ${ROOTCONFDIR} ]] ; then 133 if [[ ! -d ${ROOTCONFDIR} ]] ; then
117 mkdir -p "${ROOTCONFDIR}" || error "could not create ${ROOTCONFDIR}" 134 mkdir -p "${ROOTCONFDIR}" || error "could not create ${ROOTCONFDIR}"
118 fi 135 fi
119 136
120 if [[ ! -r ${ROOTCATALOG} ]] ; then 137 if [[ ! -r ${ROOTCATALOG} ]] ; then
140 verb "Found DocBook XML Catalog ${CATALOG}" 157 verb "Found DocBook XML Catalog ${CATALOG}"
141 fi 158 fi
142 159
143 # dtd pointers 160 # dtd pointers
144 verb " Populating ${ROOTCATALOG} with DTD delegates to ${CATALOG}" 161 verb " Populating ${ROOTCATALOG} with DTD delegates to ${CATALOG}"
145 xmlcatalog --noout --add "delegatePublic" "-//OASIS//ENTITIES DocBook" "file://${CATALOG}" ${ROOTCATALOG} 162 adds=(
146 xmlcatalog --noout --add "delegatePublic" "-//OASIS//ELEMENTS DocBook" "file://${CATALOG}" ${ROOTCATALOG} 163 "delegatePublic" "-//OASIS//ENTITIES DocBook" "${CATALOG}"
147 xmlcatalog --noout --add "delegatePublic" "-//OASIS//DTD DocBook" "file://${CATALOG}" ${ROOTCATALOG} 164 "delegatePublic" "-//OASIS//ELEMENTS DocBook" "${CATALOG}"
148 xmlcatalog --noout --add "delegateSystem" "http://www.oasis-open.org/docbook/" "file://${CATALOG}" ${ROOTCATALOG} 165 "delegatePublic" "-//OASIS//DTD DocBook" "${CATALOG}"
149 xmlcatalog --noout --add "delegateURI" "http://www.oasis-open.org/docbook/" "file://${CATALOG}" ${ROOTCATALOG} 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[@]}"
150 170
151 # entities pointer 171 # entities pointer
152 verb " Populating ${ROOTCATALOG} with ISO entities delegate to ${CATALOG}" 172 verb " Populating ${ROOTCATALOG} with ISO entities delegate to ${CATALOG}"
153 xmlcatalog --noout --add "delegatePublic" "ISO 8879:1986" "file://${CATALOG}" ${ROOTCATALOG} 173 adds=(
174 "delegatePublic" "ISO 8879:1986" "${CATALOG}"
175 )
176 multi_xmlcatalog_add "${ROOTCATALOG}" "${adds[@]}"
154} 177}
155 178
156# 179#
157# clean_catalog 180# clean_catalog
158# $1 == regex to clean 181# $1 == regex to clean
171# populate a specific dtd version into the docbook catalog 194# populate a specific dtd version into the docbook catalog
172# $1 == /path/to/docbookx.dtd 195# $1 == /path/to/docbookx.dtd
173# 196#
174populate_dtd() { 197populate_dtd() {
175 local dtd=$1 docbookdir=${1%/*} dtd_date 198 local dtd=$1 docbookdir=${1%/*} dtd_date
176 local v=${docbookdir##*-} 199 local v=${docbookdir##*-} adds
177 200
178 # sanity check 201 # sanity check
179 if [[ ${dtd} != */xml-dtd-*/* ]]; then 202 if [[ ${dtd} != */xml-dtd-*/* ]]; then
180 echo "Warning: I don't understand \"${dtd}\"" >&2 203 echo "Warning: I don't understand \"${dtd}\"" >&2
181 return 204 return
182 fi 205 fi
183 echo "Found DocBook XML ${v} in ${docbookdir}" 206 echo "Found DocBook XML ${v} in ${docbookdir}"
184 207
185 # Populate the docbook catalog with this version 208 # Populate the docbook catalog with this version
186 verb " Populating ${CATALOG} based on ${docbookdir}" 209 verb " Populating ${CATALOG} based on ${docbookdir}"
210 adds=(
187 xmlcatalog --noout --add "public" "-//OASIS//ELEMENTS DocBook XML Information Pool V${v}//EN" "file://${docbookdir}/dbpoolx.mod" ${CATALOG} 211 "public" "-//OASIS//ELEMENTS DocBook XML Information Pool V${v}//EN" "${docbookdir}/dbpoolx.mod"
188 xmlcatalog --noout --add "public" "-//OASIS//DTD DocBook XML V${v}//EN" "file://${docbookdir}/docbookx.dtd" ${CATALOG} 212 "public" "-//OASIS//DTD DocBook XML V${v}//EN" "${docbookdir}/docbookx.dtd"
189 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Character Entities V${v}//EN" "file://${docbookdir}/dbcentx.mod" ${CATALOG} 213 "public" "-//OASIS//ENTITIES DocBook XML Character Entities V${v}//EN" "${docbookdir}/dbcentx.mod"
190 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Notations V${v}//EN" "file://${docbookdir}/dbnotnx.mod" ${CATALOG} 214 "public" "-//OASIS//ENTITIES DocBook XML Notations V${v}//EN" "${docbookdir}/dbnotnx.mod"
191 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Additional General Entities V${v}//EN" "file://${docbookdir}/dbgenent.mod" ${CATALOG} 215 "public" "-//OASIS//ENTITIES DocBook XML Additional General Entities V${v}//EN" "${docbookdir}/dbgenent.mod"
192 xmlcatalog --noout --add "public" "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V${v}//EN" "file://${docbookdir}/dbhierx.mod" ${CATALOG} 216 "public" "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V${v}//EN" "${docbookdir}/dbhierx.mod"
193 xmlcatalog --noout --add "public" "-//OASIS//DTD XML Exchange Table Model 19990315//EN" "file://${docbookdir}/soextblx.dtd" ${CATALOG} 217 "public" "-//OASIS//DTD XML Exchange Table Model 19990315//EN" "${docbookdir}/soextblx.dtd"
194 xmlcatalog --noout --add "public" "-//OASIS//DTD DocBook XML CALS Table Model V${v}//EN" "file://${docbookdir}/calstblx.dtd" ${CATALOG} 218 "public" "-//OASIS//DTD DocBook XML CALS Table Model V${v}//EN" "${docbookdir}/calstblx.dtd"
195 xmlcatalog --noout --add "rewriteSystem" "http://www.oasis-open.org/docbook/xml/${v}" "file://${docbookdir}" ${CATALOG} 219 "rewriteSystem" "http://www.oasis-open.org/docbook/xml/${v}" "${docbookdir}"
196 xmlcatalog --noout --add "rewriteURI" "http://www.oasis-open.org/docbook/xml/${v}" "file://${docbookdir}" ${CATALOG} 220 "rewriteURI" "http://www.oasis-open.org/docbook/xml/${v}" "${docbookdir}"
221 )
222 multi_xmlcatalog_add "${CATALOG}" "${adds[@]}"
197 223
198 # grab the RCS date from docbookx.dtd for comparison purposes 224 # grab the RCS date from docbookx.dtd for comparison purposes
199 if [[ ! -f ${docbookdir}/ent/iso-lat1.ent ]]; then 225 if [[ ! -f ${docbookdir}/ent/iso-lat1.ent ]]; then
200 verb " No entities available for ${dtd}" 226 verb " No entities available for ${dtd}"
201 return 0 227 return 0
218# populate a specific simple dtd version into the docbook catalog 244# populate a specific simple dtd version into the docbook catalog
219# $1 == /path/to/sdocbook.dtd 245# $1 == /path/to/sdocbook.dtd
220# 246#
221populate_simple_dtd() { 247populate_simple_dtd() {
222 local dtd=$1 docbookdir=${1%/*} 248 local dtd=$1 docbookdir=${1%/*}
223 local v=${docbookdir##*-} 249 local v=${docbookdir##*-} adds
224 250
225 # sanity check 251 # sanity check
226 if [[ ${dtd} != */xml-simple-dtd-*/* ]]; then 252 if [[ ${dtd} != */xml-simple-dtd-*/* ]]; then
227 echo "Warning: I don't understand \"${dtd}\"" >&2 253 echo "Warning: I don't understand \"${dtd}\"" >&2
228 return 254 return
229 fi 255 fi
230 echo "Found Simplified DocBook XML ${v} in ${docbookdir}" 256 echo "Found Simplified DocBook XML ${v} in ${docbookdir}"
231 257
232 # Populate the docbook catalog with this version 258 # Populate the docbook catalog with this version
233 verb " Populating ${CATALOG} based on ${docbookdir}" 259 verb " Populating ${CATALOG} based on ${docbookdir}"
260 adds=(
234 xmlcatalog --noout --add "public" "-//OASIS//DTD Simplified DocBook XML V${v}//EN" "file://${docbookdir}/sdocbook.dtd" ${CATALOG} 261 "public" "-//OASIS//DTD Simplified DocBook XML V${v}//EN" "${docbookdir}/sdocbook.dtd"
235 xmlcatalog --noout --add "rewriteSystem" "http://www.oasis-open.org/docbook/xml/simple/${v}" "file://${docbookdir}" ${CATALOG} 262 "rewriteSystem" "http://www.oasis-open.org/docbook/xml/simple/${v}" "${docbookdir}"
236 xmlcatalog --noout --add "rewriteURI" "http://www.oasis-open.org/docbook/xml/simple/${v}" "file://${docbookdir}" ${CATALOG} 263 "rewriteURI" "http://www.oasis-open.org/docbook/xml/simple/${v}" "${docbookdir}"
264 )
265 multi_xmlcatalog_add "${CATALOG}" "${adds[@]}"
237} 266}
238 267
239# 268#
240# populate ISO DocBook entities from the most recent DTD 269# populate ISO DocBook entities from the most recent DTD
241# 270#
306 335
307# 336#
308# populate XSL stylesheets 337# populate XSL stylesheets
309# 338#
310populate_xsl() { 339populate_xsl() {
311 local f 340 local f adds
312 341
313 # This is either xsl, xsl-ns, xsl-saxon or xsl-xalan 342 # This is either xsl, xsl-ns, xsl-saxon or xsl-xalan
314 local type=$1 343 local type=$1
315 344
316 # Delete current entries from the catalog (delete legacy versioned entries too) 345 # Delete current entries from the catalog (delete legacy versioned entries too)
331 360
332 # Populate catalog with XSL entries 361 # Populate catalog with XSL entries
333 echo "Found DocBook XSL stylesheets (${type}) in ${xsldir}" 362 echo "Found DocBook XSL stylesheets (${type}) in ${xsldir}"
334 363
335 verb " Populating ${ROOTCATALOG} with XSL delegations" 364 verb " Populating ${ROOTCATALOG} with XSL delegations"
365 adds=(
336 xmlcatalog --noout --add "delegateSystem" "http://docbook.sourceforge.net/release/${type}/" "file://${CATALOG}" ${ROOTCATALOG} 366 "delegateSystem" "http://docbook.sourceforge.net/release/${type}/" "${CATALOG}"
337 xmlcatalog --noout --add "delegateURI" "http://docbook.sourceforge.net/release/${type}/" "file://${CATALOG}" ${ROOTCATALOG} 367 "delegateURI" "http://docbook.sourceforge.net/release/${type}/" "${CATALOG}"
368 )
369 multi_xmlcatalog_add "${ROOTCATALOG}" "${adds[@]}"
338 370
339 verb " Populating ${CATALOG} with XSL stylesheets" 371 verb " Populating ${CATALOG} with XSL stylesheets"
372 adds=(
340 xmlcatalog --noout --add "rewriteSystem" "http://docbook.sourceforge.net/release/${type}/current" "file://${xsldir}" ${CATALOG} 373 "rewriteSystem" "http://docbook.sourceforge.net/release/${type}/current" "${xsldir}"
341 xmlcatalog --noout --add "rewriteURI" "http://docbook.sourceforge.net/release/${type}/current" "file://${xsldir}" ${CATALOG} 374 "rewriteURI" "http://docbook.sourceforge.net/release/${type}/current" "${xsldir}"
375 )
376 multi_xmlcatalog_add "${CATALOG}" "${adds[@]}"
342} 377}
343 378
344# Call the main routine 379# Call the main routine
345main "$@" 380main "$@"

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20