| 1 | #!/bin/bash |
1 | #!/bin/bash |
| 2 | # $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.7 2011/11/01 21:04:00 vapier Exp $ |
2 | # $Header: /var/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.8 2012/03/27 21:23:00 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 Gentoo Foundation |
7 | # Copyright 2004-2012 Gentoo Foundation |
| 8 | # Distributed under the terms of the GNU General Public License v2 |
8 | # Distributed under the terms of the GNU General Public License v2 |
| 9 | # written by Aron Griffis |
9 | # written by Aron Griffis |
| 10 | # |
10 | # |
| 11 | |
11 | |
| 12 | ROOTCATALOG=/etc/xml/catalog |
12 | ROOTCATALOG=/etc/xml/catalog |
| … | |
… | |
| 28 | eval set -- "$opts" |
28 | eval set -- "$opts" |
| 29 | while true; do |
29 | while true; do |
| 30 | case "$1" in |
30 | case "$1" in |
| 31 | -v|--verbose) VERBOSE=true ; shift ;; |
31 | -v|--verbose) VERBOSE=true ; shift ;; |
| 32 | --) shift ; break ;; |
32 | --) shift ; break ;; |
| 33 | *) echo "Options parsing failed on $1!" >&2 ; exit 1 ;; |
33 | *) error "options parsing failed on $1!" ;; |
| 34 | esac |
34 | esac |
| 35 | done |
35 | done |
| 36 | |
36 | |
| 37 | create_catalogs # will exit on error |
37 | create_catalogs # will exit on error |
| 38 | for type in xsl xsl-ns xsl-saxon xsl-xalan; do |
38 | for type in xsl xsl-ns xsl-saxon xsl-xalan; do |
| … | |
… | |
| 63 | verb() { |
63 | verb() { |
| 64 | $VERBOSE && echo "$*" |
64 | $VERBOSE && echo "$*" |
| 65 | } |
65 | } |
| 66 | |
66 | |
| 67 | # |
67 | # |
|
|
68 | # show an error and abort |
|
|
69 | # |
|
|
70 | error() { |
|
|
71 | printf '%s: %b, aborting\n' "${ZERO}" "$*" 1>&2 |
|
|
72 | exit 1 |
|
|
73 | } |
|
|
74 | |
|
|
75 | # |
| 68 | # fill in the DTDS variable based on installed versions |
76 | # fill in the DTDS variable based on installed versions |
| 69 | # |
77 | # |
| 70 | set_dtds() { |
78 | set_dtds() { |
| 71 | DTDS=$(find ${DOCBOOKDIR} -path '*/xml-dtd-*/docbookx.dtd') |
79 | DTDS=$(find ${DOCBOOKDIR} -path '*/xml-dtd-*/docbookx.dtd') |
| 72 | SIMPLE_DTDS=$(find ${DOCBOOKDIR} -path '*/xml-simple-dtd-*/sdocbook.dtd') |
80 | SIMPLE_DTDS=$(find ${DOCBOOKDIR} -path '*/xml-simple-dtd-*/sdocbook.dtd') |
| … | |
… | |
| 84 | create_catalogs() { |
92 | create_catalogs() { |
| 85 | if [[ ! -r ${ROOTCATALOG} ]] ; then |
93 | if [[ ! -r ${ROOTCATALOG} ]] ; then |
| 86 | echo "Creating XML Catalog root ${ROOTCATALOG}" |
94 | echo "Creating XML Catalog root ${ROOTCATALOG}" |
| 87 | /usr/bin/xmlcatalog --noout --create ${ROOTCATALOG} |
95 | /usr/bin/xmlcatalog --noout --create ${ROOTCATALOG} |
| 88 | if [[ ! -r ${ROOTCATALOG} ]] ; then |
96 | if [[ ! -r ${ROOTCATALOG} ]] ; then |
| 89 | echo "Failed creating ${ROOTCATALOG}, aborting" >&2 |
97 | error "failed creating ${ROOTCATALOG}" |
| 90 | exit 1 |
|
|
| 91 | fi |
98 | fi |
| 92 | else |
99 | else |
| 93 | verb "Found XML Catalog root ${ROOTCATALOG}" |
100 | verb "Found XML Catalog root ${ROOTCATALOG}" |
| 94 | # clean out existing entries |
101 | # clean out existing entries |
| 95 | verb " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}" |
102 | verb " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}" |
| … | |
… | |
| 98 | |
105 | |
| 99 | if [[ ! -r ${CATALOG} ]] ; then |
106 | if [[ ! -r ${CATALOG} ]] ; then |
| 100 | echo "Creating DocBook XML Catalog ${CATALOG}" |
107 | echo "Creating DocBook XML Catalog ${CATALOG}" |
| 101 | /usr/bin/xmlcatalog --noout --create ${CATALOG} |
108 | /usr/bin/xmlcatalog --noout --create ${CATALOG} |
| 102 | if [[ ! -r ${CATALOG} ]] ; then |
109 | if [[ ! -r ${CATALOG} ]] ; then |
| 103 | echo "Failed creating ${CATALOG}, aborting" >&2 |
110 | error "failed creating ${CATALOG}" |
| 104 | exit 1 |
|
|
| 105 | fi |
111 | fi |
| 106 | else |
112 | else |
| 107 | verb "Found DocBook XML Catalog ${CATALOG}" |
113 | verb "Found DocBook XML Catalog ${CATALOG}" |
| 108 | fi |
114 | fi |
| 109 | |
115 | |
| … | |
… | |
| 264 | xmlcatalog --noout --add "public" "${entities[i+1]}" \ |
270 | xmlcatalog --noout --add "public" "${entities[i+1]}" \ |
| 265 | "file://${isodir}/${entities[i]}" ${CATALOG} |
271 | "file://${isodir}/${entities[i]}" ${CATALOG} |
| 266 | let j=j+1 |
272 | let j=j+1 |
| 267 | let i=i+2 |
273 | let i=i+2 |
| 268 | else |
274 | else |
| 269 | echo "${0}: Whoah, shouldn't be here, aborting" >&2 |
275 | error "${0}: whoah, shouldn't be here" |
| 270 | exit 1 |
|
|
| 271 | fi |
276 | fi |
| 272 | done |
277 | done |
| 273 | } |
278 | } |
| 274 | |
279 | |
| 275 | # |
280 | # |