diff options
author | 2004-07-22 22:35:18 +0000 | |
---|---|---|
committer | 2004-07-22 22:35:18 +0000 | |
commit | a89de4d51cff9c9d5acc111839d94a3f11da8b53 (patch) | |
tree | ce7af049f1bebc128632f88b96f7e8947cca2f1c | |
parent | see bug 52725 (diff) | |
download | build-docbook-catalog-a89de4d51cff9c9d5acc111839d94a3f11da8b53.tar.gz build-docbook-catalog-a89de4d51cff9c9d5acc111839d94a3f11da8b53.tar.bz2 build-docbook-catalog-a89de4d51cff9c9d5acc111839d94a3f11da8b53.zip |
quiet down the script unless --verbose is specifiedv1.2
Signed-off-by: Aron Griffis <agriffis@gentoo.org>
-rwxr-xr-x | build-docbook-catalog | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/build-docbook-catalog b/build-docbook-catalog index cf5f5e2..6b7645b 100755 --- a/build-docbook-catalog +++ b/build-docbook-catalog @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /usr/local/src/gentoo/gentoo-src/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.1 2004/06/30 02:40:33 agriffis Exp $ +# $Header: /usr/local/src/gentoo/gentoo-src/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.2 2004/07/22 22:35:18 agriffis Exp $ # # build-docbook-catalog: populate /etc/xml/docbook based in # installed docbook-xml-dtd versions. @@ -15,18 +15,30 @@ DOCBOOKDIR=/usr/share/sgml/docbook DTDS= LATEST_DTD= LATEST_DATE= +VERBOSE=false +ZERO=${0##*/} # # main (called from bottom) # main() { - typeset d v + typeset d v opts + + opts=$(getopt -o v --long verbose -n "$ZERO" -- "$@") || exit 1 + eval set -- "$opts" + while true; do + case "$1" in + -v|--verbose) VERBOSE=true ; shift ;; + --) shift ; break ;; + *) echo "Options parsing failed on $1!" >&2 ; exit 1 ;; + esac + done create_catalogs # will exit on error populate_xsl # Clean out old dtds from catalog - echo "Cleaning out old DocBook XML versions from ${CATALOG} and ${ROOTCATALOG}" + verb "Cleaning out old DocBook XML versions from ${CATALOG} and ${ROOTCATALOG}" clean_catalog "${DOCBOOKDIR}/xml-dtd-[^/\"']*/[^/\"']*" ${CATALOG} clean_catalog "${DOCBOOKDIR}/xml-dtd-[^/\"']*/[^/\"']*" ${ROOTCATALOG} @@ -40,6 +52,13 @@ main() { exit 0 } +# +# verbose echo -- only echo if called with --verbose +# +verb() { + $VERBOSE && echo "$*" +} + # # fill in the DTDS variable based on installed versions # @@ -65,9 +84,9 @@ create_catalogs() { exit 1 fi else - echo "Found XML Catalog root ${ROOTCATALOG}" + verb "Found XML Catalog root ${ROOTCATALOG}" # clean out existing entries - echo " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}" + verb " Cleaning existing ${CATALOG} delegates from ${ROOTCATALOG}" clean_catalog "file://${CATALOG}" ${ROOTCATALOG} fi @@ -79,11 +98,11 @@ create_catalogs() { exit 1 fi else - echo "Found DocBook XML Catalog ${CATALOG}" + verb "Found DocBook XML Catalog ${CATALOG}" fi # dtd pointers - echo " Populating ${ROOTCATALOG} with DTD delegates to ${CATALOG}" + verb " Populating ${ROOTCATALOG} with DTD delegates to ${CATALOG}" xmlcatalog --noout --add "delegatePublic" "-//OASIS//ENTITIES DocBook XML" "file://${CATALOG}" ${ROOTCATALOG} xmlcatalog --noout --add "delegatePublic" "-//OASIS//DTD DocBook XML" "file://${CATALOG}" ${ROOTCATALOG} xmlcatalog --noout --add "delegateSystem" "http://www.oasis-open.org/docbook/" "file://${CATALOG}" ${ROOTCATALOG} @@ -92,7 +111,7 @@ create_catalogs() { xmlcatalog --noout --add "delegateURI" "http://docbook.sourceforge.net/release/xsl/" "file://${CATALOG}" ${ROOTCATALOG} # entities pointer - echo " Populating ${ROOTCATALOG} with ISO entities delegate to ${CATALOG}" + verb " Populating ${ROOTCATALOG} with ISO entities delegate to ${CATALOG}" xmlcatalog --noout --add "delegatePublic" "ISO 8879:1986" "file://${CATALOG}" ${ROOTCATALOG} } @@ -126,7 +145,7 @@ populate_dtd() { echo "Found DocBook XML ${v} in ${docbookdir}" # Populate the docbook catalog with this version - echo " Populating ${CATALOG} based on ${docbookdir}" + verb " Populating ${CATALOG} based on ${docbookdir}" xmlcatalog --noout --add "public" "-//OASIS//ELEMENTS DocBook XML Information Pool V${v}//EN" "file://${docbookdir}/dbpoolx.mod" ${CATALOG} xmlcatalog --noout --add "public" "-//OASIS//DTD DocBook XML V${v}//EN" "file://${docbookdir}/docbookx.dtd" ${CATALOG} xmlcatalog --noout --add "public" "-//OASIS//ENTITIES DocBook XML Character Entities V${v}//EN" "file://${docbookdir}/dbcentx.mod" ${CATALOG} @@ -140,16 +159,16 @@ populate_dtd() { # grab the RCS date from docbookx.dtd for comparison purposes if [[ ! -f ${docbookdir}/ent/iso-lat1.ent ]]; then - echo " No entities available for ${dtd}" + verb " No entities available for ${dtd}" return 0 fi dtd_date=$(egrep --only-matching --max-count=1 \ '[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}' "${dtd}") if [[ -z ${dtd_date} ]]; then - echo " Couldn't find RCS date in ${dtd}, ignoring entities" + verb " Couldn't find RCS date in ${dtd}, ignoring entities" return 0 fi - echo " RCS datestamp in ${dtd} is ${dtd_date}" + verb " RCS datestamp in ${dtd} is ${dtd_date}" dtd_date=$(date -d "$dtd_date" +%s) if [[ -z $LATEST_DTD || $dtd_date -gt $LATEST_DATE ]]; then LATEST_DATE=${dtd_date} @@ -199,7 +218,7 @@ populate_entities() { avail=($(ls ${isodir} | sort)) # double-check the lists - echo " Populating ${CATALOG} with ISO DocBook entities" + verb " Populating ${CATALOG} with ISO DocBook entities" i=0 ; j=0 while [[ ${i} -lt ${#entities[@]} || ${j} -lt ${#avail[@]} ]]; do if [[ ${i} -ge ${#entities[@]} ]]; then @@ -252,7 +271,7 @@ populate_xsl() { # Populate catalog with XSL entries echo "Found DocBook XSL stylesheets in ${xsldir}" - echo " Populating ${CATALOG} with XSL stylesheets" + verb " Populating ${CATALOG} with XSL stylesheets" for version in current 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47 \ 1.48 1.49 1.50 ${xsldir##*-} do @@ -262,4 +281,4 @@ populate_xsl() { } # Call the main routine -main +main "$@" |