Newer version of the script upstream

This commit is contained in:
Pierre Pronchery 2014-10-31 18:14:36 +01:00
parent 4ee39f3ea0
commit 664e04a60f

View File

@ -27,6 +27,7 @@
#variables #variables
PREFIX="/usr/local" PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh" [ -f "../config.sh" ] && . "../config.sh"
PROGNAME="docbook.sh"
#executables #executables
DEBUG="_debug" DEBUG="_debug"
FOP="fop" FOP="fop"
@ -51,19 +52,25 @@ _docbook()
{ {
target="$1" target="$1"
source="${target#$OBJDIR}" source="${target%.*}.xml"
source="${source%.*}.xml" [ -f "$source" ] || source="${source#$OBJDIR}"
ext="${target##*.}" ext="${target##*.}"
ext="${ext##.}" ext="${ext##.}"
case "$ext" in case "$ext" in
html) html)
XSL="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl" XSL="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl" [ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
[ -f "${target%.*}.css.xml" ] && XSLTPROC="$XSLTPROC --param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1" if [ -f "${target%.*}.css.xml" ]; then
XSLTPROC="$XSLTPROC --param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1"
elif [ -f "${source%.*}.css.xml" ]; then
XSLTPROC="$XSLTPROC --param custom.css.source \"${source%.*}.css.xml\" --param generate.css.header 1"
fi
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source" $DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
;; ;;
pdf) pdf)
XSL="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl" XSL="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl" [ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
$DEBUG $XSLTPROC -o "${target%.*}.fo" "$XSL" "$source" && $DEBUG $XSLTPROC -o "${target%.*}.fo" "$XSL" "$source" &&
$DEBUG $FOP -fo "${target%.*}.fo" -pdf "$target" $DEBUG $FOP -fo "${target%.*}.fo" -pdf "$target"
@ -74,13 +81,13 @@ _docbook()
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source" $DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
;; ;;
*) *)
echo "$0: $target: Unknown type" 1>&2 _error "$target: Unknown type"
return 2 return 2
;; ;;
esac esac
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$0: $target: Could not create page" 1>&2 _error "$target: Could not create page"
$RM -- "$target" $RM -- "$target"
return 2 return 2
fi fi
@ -90,7 +97,7 @@ _docbook()
#error #error
_error() _error()
{ {
echo "docbook.sh: $@" 1>&2 echo "$PROGNAME: $@" 1>&2
return 2 return 2
} }
@ -98,7 +105,7 @@ _error()
#usage #usage
_usage() _usage()
{ {
echo "Usage: docbook.sh [-c|-i|-u][-P prefix] target..." 1>&2 echo "Usage: $PROGNAME [-c|-i|-u][-P prefix] target..." 1>&2
return 1 return 1
} }
@ -169,7 +176,7 @@ while [ $# -gt 0 ]; do
instdir="$MANDIR/man$ext" instdir="$MANDIR/man$ext"
;; ;;
*) *)
echo "$0: $target: Unknown type" 1>&2 _error "$target: Unknown type"
exit 2 exit 2
;; ;;
esac esac