/[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.14 Revision 1.15
1#!/bin/bash 1#!/bin/bash
2# $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.14 2012/03/27 22:50:44 vapier Exp $ 2# $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.15 2012/03/27 22:54:41 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
57 populate_xsl $type 57 populate_xsl $type
58 done 58 done
59 59
60 # Clean out old dtds from catalog 60 # Clean out old dtds from catalog
61 verb "Cleaning out old DocBook XML versions from ${CATALOG} and ${ROOTCATALOG}" 61 verb "Cleaning out old DocBook XML versions from ${CATALOG} and ${ROOTCATALOG}"
62 clean_catalog "${DOCBOOKDIR}/xml\(-simple\)*-dtd-[^/\"']*/[^/\"']*" ${CATALOG} 62 clean_catalog "${DOCBOOKDIR}/xml\(-simple\)*-dtd-[^/\"']*/[^/\"']*" "${CATALOG}"
63 clean_catalog "${DOCBOOKDIR}/xml\(-simple\)*-dtd-[^/\"']*/[^/\"']*" ${ROOTCATALOG} 63 clean_catalog "${DOCBOOKDIR}/xml\(-simple\)*-dtd-[^/\"']*/[^/\"']*" "${ROOTCATALOG}"
64 64
65 if set_dtds; then 65 if set_dtds; then
66 for d in ${DTDS}; do 66 for d in ${DTDS}; do
67 populate_dtd ${d} 67 populate_dtd ${d}
68 done 68 done
95# 95#
96set_dtds() { 96set_dtds() {
97 DTDS= SIMPLE_DTS= 97 DTDS= SIMPLE_DTS=
98 98
99 if [[ -d ${DOCBOOKDIR} ]] ; then 99 if [[ -d ${DOCBOOKDIR} ]] ; then
100 DTDS=$(find ${DOCBOOKDIR} -path '*/xml-dtd-*/docbookx.dtd') 100 DTDS=$(find "${DOCBOOKDIR}" -path '*/xml-dtd-*/docbookx.dtd')
101 SIMPLE_DTDS=$(find ${DOCBOOKDIR} -path '*/xml-simple-dtd-*/sdocbook.dtd') 101 SIMPLE_DTDS=$(find "${DOCBOOKDIR}" -path '*/xml-simple-dtd-*/sdocbook.dtd')
102 fi 102 fi
103 103
104 if [[ -z ${DTDS} ]]; then 104 if [[ -z ${DTDS} ]]; then
105 echo "No installed DocBook XML DTDs found" 105 echo "No installed DocBook XML DTDs found"
106 return 1 106 return 1
134 mkdir -p "${ROOTCONFDIR}" || error "could not create ${ROOTCONFDIR}" 134 mkdir -p "${ROOTCONFDIR}" || error "could not create ${ROOTCONFDIR}"
135 fi 135 fi
136 136
137 if [[ ! -r ${ROOTCATALOG} ]] ; then 137 if [[ ! -r ${ROOTCATALOG} ]] ; then
138 echo "Creating XML Catalog root ${ROOTCATALOG}" 138 echo "Creating XML Catalog root ${ROOTCATALOG}"
139 xmlcatalog --noout --create ${ROOTCATALOG} 139 xmlcatalog --noout --create "${ROOTCATALOG}"
140 if [[ ! -r ${ROOTCATALOG} ]] ; then 140 if [[ ! -r ${ROOTCATALOG} ]] ; then
141 error "failed creating ${ROOTCATALOG}" 141 error "failed creating ${ROOTCATALOG}"
142 fi 142 fi
143 else 143 else
144 verb "Found XML Catalog root ${ROOTCATALOG}" 144 verb "Found XML Catalog root ${ROOTCATALOG}"
145 # clean out existing entries 145 # clean out existing entries
146 verb " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}" 146 verb " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}"
147 clean_catalog "file://${CATALOG}" ${ROOTCATALOG} 147 clean_catalog "file://${CATALOG}" "${ROOTCATALOG}"
148 fi 148 fi
149 149
150 if [[ ! -r ${CATALOG} ]] ; then 150 if [[ ! -r ${CATALOG} ]] ; then
151 echo "Creating DocBook XML Catalog ${CATALOG}" 151 echo "Creating DocBook XML Catalog ${CATALOG}"
152 xmlcatalog --noout --create ${CATALOG} 152 xmlcatalog --noout --create "${CATALOG}"
153 if [[ ! -r ${CATALOG} ]] ; then 153 if [[ ! -r ${CATALOG} ]] ; then
154 error "failed creating ${CATALOG}" 154 error "failed creating ${CATALOG}"
155 fi 155 fi
156 else 156 else
157 verb "Found DocBook XML Catalog ${CATALOG}" 157 verb "Found DocBook XML Catalog ${CATALOG}"
184clean_catalog() { 184clean_catalog() {
185 local list f regex=$1 catalog=$2 185 local list f regex=$1 catalog=$2
186 186
187 list=$(egrep --only-matching "${regex}" "${catalog}" | sort -u) 187 list=$(egrep --only-matching "${regex}" "${catalog}" | sort -u)
188 for f in ${list}; do 188 for f in ${list}; do
189 xmlcatalog --noout --del "${f}" ${catalog} 189 xmlcatalog --noout --del "${f}" "${catalog}"
190 done 190 done
191} 191}
192 192
193# 193#
194# populate a specific dtd version into the docbook catalog 194# populate a specific dtd version into the docbook catalog
302 "iso-pub.ent" "ISO 8879:1986//ENTITIES Publishing//EN" 302 "iso-pub.ent" "ISO 8879:1986//ENTITIES Publishing//EN"
303 "iso-tech.ent" "ISO 8879:1986//ENTITIES General Technical//EN" 303 "iso-tech.ent" "ISO 8879:1986//ENTITIES General Technical//EN"
304 ) 304 )
305 305
306 # here are the entities available; assume no spaces in filenames... 306 # here are the entities available; assume no spaces in filenames...
307 avail=($(ls ${isodir} | sort)) 307 avail=($(ls "${isodir}" | sort))
308 308
309 # double-check the lists 309 # double-check the lists
310 verb " Populating ${CATALOG} with ISO DocBook entities" 310 verb " Populating ${CATALOG} with ISO DocBook entities"
311 i=0 ; j=0 311 i=0 ; j=0
312 while [[ ${i} -lt ${#entities[@]} || ${j} -lt ${#avail[@]} ]]; do 312 while [[ ${i} -lt ${#entities[@]} || ${j} -lt ${#avail[@]} ]]; do
322 elif [[ ${entities[i]} < ${avail[j]} ]]; then 322 elif [[ ${entities[i]} < ${avail[j]} ]]; then
323 echo "Warning: Entities file not found: ${entities[i]}" 323 echo "Warning: Entities file not found: ${entities[i]}"
324 let i=i+2 324 let i=i+2
325 elif [[ ${entities[i]} == ${avail[j]} ]]; then 325 elif [[ ${entities[i]} == ${avail[j]} ]]; then
326 xmlcatalog --noout --add "public" "${entities[i+1]}" \ 326 xmlcatalog --noout --add "public" "${entities[i+1]}" \
327 "file://${isodir}/${entities[i]}" ${CATALOG} 327 "file://${isodir}/${entities[i]}" "${CATALOG}"
328 let j=j+1 328 let j=j+1
329 let i=i+2 329 let i=i+2
330 else 330 else
331 error "${0}: whoah, shouldn't be here" 331 error "${0}: whoah, shouldn't be here"
332 fi 332 fi
341 341
342 # This is either xsl, xsl-ns, xsl-saxon or xsl-xalan 342 # This is either xsl, xsl-ns, xsl-saxon or xsl-xalan
343 local type=$1 343 local type=$1
344 344
345 # Delete current entries from the catalog (delete legacy versioned entries too) 345 # Delete current entries from the catalog (delete legacy versioned entries too)
346 clean_catalog "${DOCBOOKDIR}/${type}-stylesheets(-[0-9\.]+)?" $CATALOG 346 clean_catalog "${DOCBOOKDIR}/${type}-stylesheets(-[0-9\.]+)?" "${CATALOG}"
347 clean_catalog "${DOCBOOKDIR}/${type}-stylesheets(-[0-9\.]+)?" $ROOTCATALOG 347 clean_catalog "${DOCBOOKDIR}/${type}-stylesheets(-[0-9\.]+)?" "${ROOTCATALOG}"
348 348
349 local xsldir=/usr/share/sgml/docbook/${type}-stylesheets 349 local xsldir=/usr/share/sgml/docbook/${type}-stylesheets
350 350
351 if [[ ! -d ${xsldir} ]]; then 351 if [[ ! -d ${xsldir} ]]; then
352 echo "DocBook XSL stylesheets (${type}) not found" >&2 352 echo "DocBook XSL stylesheets (${type}) not found" >&2

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

  ViewVC Help
Powered by ViewVC 1.1.20