/[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.1 Revision 1.2
1#!/bin/bash 1#!/bin/bash
2# $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.1 2004/06/30 02:40:33 agriffis Exp $ 2# $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.2 2004/07/22 22:35:18 agriffis 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 Gentoo Foundation 7# Copyright 2004 Gentoo Foundation
13CATALOG=/etc/xml/docbook 13CATALOG=/etc/xml/docbook
14DOCBOOKDIR=/usr/share/sgml/docbook 14DOCBOOKDIR=/usr/share/sgml/docbook
15DTDS= 15DTDS=
16LATEST_DTD= 16LATEST_DTD=
17LATEST_DATE= 17LATEST_DATE=
18VERBOSE=false
19ZERO=${0##*/}
18 20
19# 21#
20# main (called from bottom) 22# main (called from bottom)
21# 23#
22main() { 24main() {
23 typeset d v 25 typeset d v opts
26
27 opts=$(getopt -o v --long verbose -n "$ZERO" -- "$@") || exit 1
28 eval set -- "$opts"
29 while true; do
30 case "$1" in
31 -v|--verbose) VERBOSE=true ; shift ;;
32 --) shift ; break ;;
33 *) echo "Options parsing failed on $1!" >&2 ; exit 1 ;;
34 esac
35 done
24 36
25 create_catalogs # will exit on error 37 create_catalogs # will exit on error
26 populate_xsl 38 populate_xsl
27 39
28 # Clean out old dtds from catalog 40 # Clean out old dtds from catalog
29 echo "Cleaning out old DocBook XML versions from ${CATALOG} and ${ROOTCATALOG}" 41 verb "Cleaning out old DocBook XML versions from ${CATALOG} and ${ROOTCATALOG}"
30 clean_catalog "${DOCBOOKDIR}/xml-dtd-[^/\"']*/[^/\"']*" ${CATALOG} 42 clean_catalog "${DOCBOOKDIR}/xml-dtd-[^/\"']*/[^/\"']*" ${CATALOG}
31 clean_catalog "${DOCBOOKDIR}/xml-dtd-[^/\"']*/[^/\"']*" ${ROOTCATALOG} 43 clean_catalog "${DOCBOOKDIR}/xml-dtd-[^/\"']*/[^/\"']*" ${ROOTCATALOG}
32 44
33 if set_dtds; then 45 if set_dtds; then
34 for d in ${DTDS}; do 46 for d in ${DTDS}; do
36 done 48 done
37 populate_entities 49 populate_entities
38 fi 50 fi
39 51
40 exit 0 52 exit 0
53}
54
55#
56# verbose echo -- only echo if called with --verbose
57#
58verb() {
59 $VERBOSE && echo "$*"
41} 60}
42 61
43# 62#
44# fill in the DTDS variable based on installed versions 63# fill in the DTDS variable based on installed versions
45# 64#
63 if [[ ! -r ${ROOTCATALOG} ]] ; then 82 if [[ ! -r ${ROOTCATALOG} ]] ; then
64 echo "Failed creating ${ROOTCATALOG}, aborting" >&2 83 echo "Failed creating ${ROOTCATALOG}, aborting" >&2
65 exit 1 84 exit 1
66 fi 85 fi
67 else 86 else
68 echo "Found XML Catalog root ${ROOTCATALOG}" 87 verb "Found XML Catalog root ${ROOTCATALOG}"
69 # clean out existing entries 88 # clean out existing entries
70 echo " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}" 89 verb " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}"
71 clean_catalog "file://${CATALOG}" ${ROOTCATALOG} 90 clean_catalog "file://${CATALOG}" ${ROOTCATALOG}
72 fi 91 fi
73 92
74 if [[ ! -r ${CATALOG} ]] ; then 93 if [[ ! -r ${CATALOG} ]] ; then
75 echo "Creating DocBook XML Catalog ${CATALOG}" 94 echo "Creating DocBook XML Catalog ${CATALOG}"
77 if [[ ! -r ${CATALOG} ]] ; then 96 if [[ ! -r ${CATALOG} ]] ; then
78 echo "Failed creating ${CATALOG}, aborting" >&2 97 echo "Failed creating ${CATALOG}, aborting" >&2
79 exit 1 98 exit 1
80 fi 99 fi
81 else 100 else
82 echo "Found DocBook XML Catalog ${CATALOG}" 101 verb "Found DocBook XML Catalog ${CATALOG}"
83 fi 102 fi
84 103
85 # dtd pointers 104 # dtd pointers
86 echo " Populating ${ROOTCATALOG} with DTD delegates to ${CATALOG}" 105 verb " Populating ${ROOTCATALOG} with DTD delegates to ${CATALOG}"
87 xmlcatalog --noout --add "delegatePublic" "-//OASIS//ENTITIES DocBook XML" "file://${CATALOG}" ${ROOTCATALOG} 106 xmlcatalog --noout --add "delegatePublic" "-//OASIS//ENTITIES DocBook XML" "file://${CATALOG}" ${ROOTCATALOG}
88 xmlcatalog --noout --add "delegatePublic" "-//OASIS//DTD DocBook XML" "file://${CATALOG}" ${ROOTCATALOG} 107 xmlcatalog --noout --add "delegatePublic" "-//OASIS//DTD DocBook XML" "file://${CATALOG}" ${ROOTCATALOG}
89 xmlcatalog --noout --add "delegateSystem" "http://www.oasis-open.org/docbook/" "file://${CATALOG}" ${ROOTCATALOG} 108 xmlcatalog --noout --add "delegateSystem" "http://www.oasis-open.org/docbook/" "file://${CATALOG}" ${ROOTCATALOG}
90 xmlcatalog --noout --add "delegateURI" "http://www.oasis-open.org/docbook/" "file://${CATALOG}" ${ROOTCATALOG} 109 xmlcatalog --noout --add "delegateURI" "http://www.oasis-open.org/docbook/" "file://${CATALOG}" ${ROOTCATALOG}
91 xmlcatalog --noout --add "delegateSystem" "http://docbook.sourceforge.net/release/xsl/" "file://${CATALOG}" ${ROOTCATALOG} 110 xmlcatalog --noout --add "delegateSystem" "http://docbook.sourceforge.net/release/xsl/" "file://${CATALOG}" ${ROOTCATALOG}
92 xmlcatalog --noout --add "delegateURI" "http://docbook.sourceforge.net/release/xsl/" "file://${CATALOG}" ${ROOTCATALOG} 111 xmlcatalog --noout --add "delegateURI" "http://docbook.sourceforge.net/release/xsl/" "file://${CATALOG}" ${ROOTCATALOG}
93 112
94 # entities pointer 113 # entities pointer
95 echo " Populating ${ROOTCATALOG} with ISO entities delegate to ${CATALOG}" 114 verb " Populating ${ROOTCATALOG} with ISO entities delegate to ${CATALOG}"
96 xmlcatalog --noout --add "delegatePublic" "ISO 8879:1986" "file://${CATALOG}" ${ROOTCATALOG} 115 xmlcatalog --noout --add "delegatePublic" "ISO 8879:1986" "file://${CATALOG}" ${ROOTCATALOG}
97} 116}
98 117
99# 118#
100# clean_catalog 119# clean_catalog
124 return 143 return
125 fi 144 fi
126 echo "Found DocBook XML ${v} in ${docbookdir}" 145 echo "Found DocBook XML ${v} in ${docbookdir}"
127 146
128 # Populate the docbook catalog with this version 147 # Populate the docbook catalog with this version
129 echo " Populating ${CATALOG} based on ${docbookdir}" 148 verb " Populating ${CATALOG} based on ${docbookdir}"
130 xmlcatalog --noout --add "public" "-//OASIS//ELEMENTS DocBook XML Information Pool V${v}//EN" "file://${docbookdir}/dbpoolx.mod" ${CATALOG} 149 xmlcatalog --noout --add "public" "-//OASIS//ELEMENTS DocBook XML Information Pool V${v}//EN" "file://${docbookdir}/dbpoolx.mod" ${CATALOG}
131 xmlcatalog --noout --add "public" "-//OASIS//DTD DocBook XML V${v}//EN" "file://${docbookdir}/docbookx.dtd" ${CATALOG} 150 xmlcatalog --noout --add "public" "-//OASIS//DTD DocBook XML V${v}//EN" "file://${docbookdir}/docbookx.dtd" ${CATALOG}
132 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Character Entities V${v}//EN" "file://${docbookdir}/dbcentx.mod" ${CATALOG} 151 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Character Entities V${v}//EN" "file://${docbookdir}/dbcentx.mod" ${CATALOG}
133 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Notations V${v}//EN" "file://${docbookdir}/dbnotnx.mod" ${CATALOG} 152 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Notations V${v}//EN" "file://${docbookdir}/dbnotnx.mod" ${CATALOG}
134 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Additional General Entities V${v}//EN" "file://${docbookdir}/dbgenent.mod" ${CATALOG} 153 xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Additional General Entities V${v}//EN" "file://${docbookdir}/dbgenent.mod" ${CATALOG}
138 xmlcatalog --noout --add "rewriteSystem" "http://www.oasis-open.org/docbook/xml/${v}" "file://${docbookdir}" ${CATALOG} 157 xmlcatalog --noout --add "rewriteSystem" "http://www.oasis-open.org/docbook/xml/${v}" "file://${docbookdir}" ${CATALOG}
139 xmlcatalog --noout --add "rewriteURI" "http://www.oasis-open.org/docbook/xml/${v}" "file://${docbookdir}" ${CATALOG} 158 xmlcatalog --noout --add "rewriteURI" "http://www.oasis-open.org/docbook/xml/${v}" "file://${docbookdir}" ${CATALOG}
140 159
141 # grab the RCS date from docbookx.dtd for comparison purposes 160 # grab the RCS date from docbookx.dtd for comparison purposes
142 if [[ ! -f ${docbookdir}/ent/iso-lat1.ent ]]; then 161 if [[ ! -f ${docbookdir}/ent/iso-lat1.ent ]]; then
143 echo " No entities available for ${dtd}" 162 verb " No entities available for ${dtd}"
144 return 0 163 return 0
145 fi 164 fi
146 dtd_date=$(egrep --only-matching --max-count=1 \ 165 dtd_date=$(egrep --only-matching --max-count=1 \
147 '[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}' "${dtd}") 166 '[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}' "${dtd}")
148 if [[ -z ${dtd_date} ]]; then 167 if [[ -z ${dtd_date} ]]; then
149 echo " Couldn't find RCS date in ${dtd}, ignoring entities" 168 verb " Couldn't find RCS date in ${dtd}, ignoring entities"
150 return 0 169 return 0
151 fi 170 fi
152 echo " RCS datestamp in ${dtd} is ${dtd_date}" 171 verb " RCS datestamp in ${dtd} is ${dtd_date}"
153 dtd_date=$(date -d "$dtd_date" +%s) 172 dtd_date=$(date -d "$dtd_date" +%s)
154 if [[ -z $LATEST_DTD || $dtd_date -gt $LATEST_DATE ]]; then 173 if [[ -z $LATEST_DTD || $dtd_date -gt $LATEST_DATE ]]; then
155 LATEST_DATE=${dtd_date} 174 LATEST_DATE=${dtd_date}
156 LATEST_DTD=${dtd} 175 LATEST_DTD=${dtd}
157 fi 176 fi
197 216
198 # here are the entities available; assume no spaces in filenames... 217 # here are the entities available; assume no spaces in filenames...
199 avail=($(ls ${isodir} | sort)) 218 avail=($(ls ${isodir} | sort))
200 219
201 # double-check the lists 220 # double-check the lists
202 echo " Populating ${CATALOG} with ISO DocBook entities" 221 verb " Populating ${CATALOG} with ISO DocBook entities"
203 i=0 ; j=0 222 i=0 ; j=0
204 while [[ ${i} -lt ${#entities[@]} || ${j} -lt ${#avail[@]} ]]; do 223 while [[ ${i} -lt ${#entities[@]} || ${j} -lt ${#avail[@]} ]]; do
205 if [[ ${i} -ge ${#entities[@]} ]]; then 224 if [[ ${i} -ge ${#entities[@]} ]]; then
206 echo "Warning: Extra ISO entities file: ${avail[j]}" 225 echo "Warning: Extra ISO entities file: ${avail[j]}"
207 let j=j+1 226 let j=j+1
250 return 1 269 return 1
251 fi 270 fi
252 271
253 # Populate catalog with XSL entries 272 # Populate catalog with XSL entries
254 echo "Found DocBook XSL stylesheets in ${xsldir}" 273 echo "Found DocBook XSL stylesheets in ${xsldir}"
255 echo " Populating ${CATALOG} with XSL stylesheets" 274 verb " Populating ${CATALOG} with XSL stylesheets"
256 for version in current 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47 \ 275 for version in current 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47 \
257 1.48 1.49 1.50 ${xsldir##*-} 276 1.48 1.49 1.50 ${xsldir##*-}
258 do 277 do
259 xmlcatalog --noout --add "rewriteSystem" "http://docbook.sourceforge.net/release/xsl/${version}" "file://${xsldir}" ${CATALOG} 278 xmlcatalog --noout --add "rewriteSystem" "http://docbook.sourceforge.net/release/xsl/${version}" "file://${xsldir}" ${CATALOG}
260 xmlcatalog --noout --add "rewriteURI" "http://docbook.sourceforge.net/release/xsl/${version}" "file://${xsldir}" ${CATALOG} 279 xmlcatalog --noout --add "rewriteURI" "http://docbook.sourceforge.net/release/xsl/${version}" "file://${xsldir}" ${CATALOG}
261 done 280 done
262} 281}
263 282
264# Call the main routine 283# Call the main routine
265main 284main "$@"

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20