2003-06-18 17:37:36 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Script to check for catalogs, stylesheets, XSL processors and all
|
|
|
|
# the other stuff necessary to convert the XML documentation.
|
|
|
|
|
|
|
|
_xsltwrapper="xsltproc.sh"
|
|
|
|
_xmllintwrapper="xmllint.sh"
|
|
|
|
|
2004-01-20 23:27:25 +00:00
|
|
|
echo "Searching for XML catalogs..."
|
2005-04-11 22:59:33 +00:00
|
|
|
for _try_catalog in \
|
|
|
|
/etc/sgml/catalog \
|
2005-12-25 17:38:19 +00:00
|
|
|
/usr/share/xml/docbook/*/catalog.xml \
|
2005-04-11 22:59:33 +00:00
|
|
|
/usr/share/sgml/docbook/xml-dtd-4.1.2/xmlcatalog \
|
|
|
|
/usr/share/apps/ksgmltools2/customization/en/catalog \
|
|
|
|
/usr/share/sgml/catalog \
|
|
|
|
/usr/local/share/sgml/catalog \
|
|
|
|
/usr/lib/sgml/catalog \
|
|
|
|
/usr/local/lib/sgml/catalog \
|
|
|
|
/usr/share/docbook-xml42/catalog.xml \
|
|
|
|
/usr/share/sgml/docbook/xmlcatalog
|
2003-06-18 17:37:36 +00:00
|
|
|
do
|
|
|
|
if test -f "$_try_catalog"
|
|
|
|
then
|
|
|
|
_catalog=$_try_catalog
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -n "$_catalog"
|
|
|
|
then
|
|
|
|
echo "Found SGML catalog at $_catalog"
|
|
|
|
_sgmlcatalog="export SGML_CATALOG_FILES=$_catalog"
|
|
|
|
else
|
|
|
|
echo "No SGML catalog found."
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-10-21 11:07:02 +00:00
|
|
|
echo "Searching for stylesheets..."
|
|
|
|
echo "Searching for html/chunk.xsl..."
|
2005-04-11 22:59:33 +00:00
|
|
|
for _try_chunk_xsl in \
|
|
|
|
/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl \
|
|
|
|
/usr/share/sgml/docbook/yelp/docbook/html/chunk.xsl \
|
|
|
|
/usr/local/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl \
|
|
|
|
/usr/local/share/sgml/docbook/yelp/docbook/html/chunk.xsl \
|
|
|
|
/usr/share/docbook-xsl/html/chunk.xsl \
|
2006-02-24 17:38:23 +00:00
|
|
|
/usr/share/sgml/docbook/xsl-stylesheets*/html/chunk.xsl \
|
|
|
|
/usr/share/xml/docbook/stylesheet/nwalsh/current/html/chunk.xsl \
|
|
|
|
|
2003-06-18 17:37:36 +00:00
|
|
|
do
|
|
|
|
if test -f "$_try_chunk_xsl"
|
|
|
|
then
|
|
|
|
_chunk_xsl=$_try_chunk_xsl
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -z "$_chunk_xsl"
|
|
|
|
then
|
|
|
|
_chunk_xsl=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl
|
2003-09-21 13:02:27 +00:00
|
|
|
echo "Not found. Using default ($_chunk_xsl)"
|
|
|
|
_fake_chunk_xsl=yes
|
2003-06-18 17:37:36 +00:00
|
|
|
else
|
|
|
|
echo "Found chunk.xsl at $_chunk_xsl"
|
|
|
|
fi
|
|
|
|
|
2003-10-20 09:56:48 +00:00
|
|
|
echo "Searching for html/docbook.xsl..."
|
2005-04-11 22:59:33 +00:00
|
|
|
for _try_docbook_xsl in \
|
|
|
|
/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl \
|
|
|
|
/usr/share/sgml/docbook/yelp/docbook/html/docbook.xsl \
|
|
|
|
/usr/local/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl \
|
|
|
|
/usr/local/share/sgml/docbook/yelp/docbook/html/docbook.xsl \
|
|
|
|
/usr/share/docbook-xsl/html/docbook.xsl \
|
2006-02-24 17:38:23 +00:00
|
|
|
/usr/share/sgml/docbook/xsl-stylesheets*/html/docbook.xsl \
|
|
|
|
/usr/share/xml/docbook/stylesheet/nwalsh/current/html/docbook.xsl \
|
|
|
|
|
2003-10-20 09:56:48 +00:00
|
|
|
do
|
|
|
|
if test -f "$_try_docbook_xsl"
|
|
|
|
then
|
|
|
|
_docbook_xsl=$_try_docbook_xsl
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -z "$_docbook_xsl"
|
|
|
|
then
|
|
|
|
_docbook_xsl=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl
|
|
|
|
echo "Not found. Using default ($_docbook_xsl)"
|
|
|
|
_fake_docbook_xsl=yes
|
|
|
|
else
|
|
|
|
echo "Found docbook.xsl at $_docbook_xsl"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat > html-chunk.xsl << EOF
|
2006-11-08 12:39:16 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2003-06-18 17:37:36 +00:00
|
|
|
<!-- **************************************************
|
|
|
|
This file is generated automatically. DO NOT EDIT.
|
|
|
|
************************************************** -->
|
|
|
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
|
|
version="1.0">
|
|
|
|
|
|
|
|
<xsl:import href="$_chunk_xsl"/>
|
|
|
|
<xsl:include href="html-common.xsl"/>
|
|
|
|
|
|
|
|
</xsl:stylesheet>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
2003-10-21 11:07:02 +00:00
|
|
|
cat > html-single.xsl << EOF
|
2006-11-08 12:39:16 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2003-10-20 09:56:48 +00:00
|
|
|
<!-- **************************************************
|
|
|
|
This file is generated automatically. DO NOT EDIT.
|
|
|
|
************************************************** -->
|
|
|
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
|
|
version="1.0">
|
|
|
|
|
|
|
|
<xsl:import href="$_docbook_xsl"/>
|
|
|
|
<xsl:include href="html-common.xsl"/>
|
|
|
|
|
|
|
|
</xsl:stylesheet>
|
|
|
|
EOF
|
|
|
|
|
2004-01-20 23:27:25 +00:00
|
|
|
echo "Searching for DTD..."
|
2005-04-11 22:59:33 +00:00
|
|
|
for _try_dtd in \
|
2005-12-25 17:38:19 +00:00
|
|
|
/usr/share/xml/docbook/*/docbookx.dtd \
|
2005-04-11 22:59:33 +00:00
|
|
|
/usr/share/sgml/docbook/dtd/xml/4.1.2/docbookx.dtd \
|
|
|
|
/usr/share/docbook-xml42/docbookx.dtd \
|
|
|
|
/usr/share/sgml/docbook/xml-dtd-4.1.2*/docbookx.dtd \
|
|
|
|
/usr/share/sgml/docbook/xml-dtd-4.2/docbookx.dtd \
|
2006-01-22 15:50:49 +00:00
|
|
|
/usr/share/sgml/docbook/xml-dtd-4.4/docbookx.dtd \
|
2005-04-11 22:59:33 +00:00
|
|
|
/usr/share/xml/docbook/schema/dtd/4.2/docbookx.dtd \
|
|
|
|
/usr/share/sgml/docbook/dtd/4.2/docbookx.dtd
|
2004-01-20 23:27:25 +00:00
|
|
|
do
|
|
|
|
if test -f "$_try_dtd"
|
|
|
|
then
|
|
|
|
_dtd=$_try_dtd
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -z "$_dtd"
|
|
|
|
then
|
|
|
|
_dtd=/usr/share/sgml/docbook/dtd/xml/4.1.2/docbookx.dtd
|
|
|
|
echo "Not found. Using default ($_dtd)."
|
|
|
|
else
|
|
|
|
echo "Found docbookx.dtd at $_dtd"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for lang in `grep 'SUBDIRS =' Makefile|cut -d= -f2`; do
|
|
|
|
cat > $lang/main.xml << EOF
|
2006-11-08 12:39:16 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
2006-10-26 09:10:32 +00:00
|
|
|
<!-- **************************************************
|
|
|
|
This file is generated automatically. DO NOT EDIT.
|
|
|
|
************************************************** -->
|
2004-01-20 23:27:25 +00:00
|
|
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
|
|
|
|
"$_dtd"
|
|
|
|
[
|
|
|
|
EOF
|
|
|
|
|
2004-01-21 21:38:27 +00:00
|
|
|
for file in `find $lang en -name \*.xml -exec basename \{\} \; | sort -u`; do
|
2004-01-20 23:27:25 +00:00
|
|
|
echo '<!ENTITY '$file' SYSTEM "'$file'">' >> $lang/main.xml
|
|
|
|
done
|
|
|
|
|
|
|
|
cat >> $lang/main.xml << EOF
|
|
|
|
]>
|
|
|
|
<book id="index" lang="$lang">
|
|
|
|
&documentation.xml;
|
|
|
|
</book>
|
|
|
|
EOF
|
2003-10-20 09:56:48 +00:00
|
|
|
|
2004-01-20 23:27:25 +00:00
|
|
|
done
|
2003-06-18 17:37:36 +00:00
|
|
|
|
|
|
|
echo "Looking for a valid XSLT processor..."
|
|
|
|
# Checks for xsltproc, then checks for the Saxon processor (it needs Java).
|
|
|
|
# Also checks for Jade/OpenJade.
|
|
|
|
#FIXME: Add support for the xalan/xalan2 XSLT processors.
|
|
|
|
|
|
|
|
if xsltproc --version &> /dev/null
|
|
|
|
then
|
2003-09-21 13:02:27 +00:00
|
|
|
if test -z "$_fake_chunk_xsl"
|
2003-06-18 17:37:36 +00:00
|
|
|
then
|
|
|
|
echo "Found xsltproc. If it works, it's probably the best choice."
|
|
|
|
if test -n "$_catalog"
|
|
|
|
then
|
|
|
|
_xsltcommand="xsltproc --catalogs -o \$1 \$2 \$3"
|
|
|
|
else
|
|
|
|
_xsltcommand="xsltproc -o \$1 \$2 \$3"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Found xsltproc but no stylesheets on your system."
|
|
|
|
echo "xsltproc is unusable without stylesheets."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# xsltproc not found.
|
|
|
|
# Now try to find a good Java virtual machine.
|
|
|
|
# FIXME: We need more checks for Java virtual machines.
|
|
|
|
if test -z "$_xsltcommand"
|
|
|
|
then
|
2003-09-21 13:02:27 +00:00
|
|
|
#FIXME: Add more suitable machines!!!
|
2003-06-18 17:37:36 +00:00
|
|
|
for _try_java in java gij-3.3 gij-3.2 gij-3.1 gij-3.0 gij
|
|
|
|
do
|
|
|
|
if $_try_java --version > /dev/null 2>&1 || $_try_java -version > /dev/null 2>&1
|
|
|
|
then
|
|
|
|
_java=$_try_java
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if test -z "$_java"
|
|
|
|
then
|
|
|
|
echo "Java VM not found."
|
|
|
|
else
|
|
|
|
# Try to find the right jar files for classpath.
|
|
|
|
# This must not trigger on something like saxon-fop-6.4.4.jar.
|
2005-04-11 22:59:33 +00:00
|
|
|
for _try_saxon_jar in \
|
|
|
|
/usr/share/java/saxon-[0-9]*.jar \
|
|
|
|
/usr/local/share/java/saxon-[0-9]*.jar \
|
|
|
|
/usr/share/java/saxon.jar \
|
|
|
|
/usr/local/share/java/saxon.jar
|
2003-06-18 17:37:36 +00:00
|
|
|
do
|
|
|
|
if test -f "$_try_saxon_jar"
|
|
|
|
then
|
|
|
|
_saxon_jar=$_try_saxon_jar
|
|
|
|
#Don't break to find the _latest_ saxon.jar.
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if test -n "$_saxon_jar"
|
|
|
|
then
|
2003-09-21 13:02:27 +00:00
|
|
|
if test -z "$_fake_chunk_xsl"
|
2003-06-18 17:37:36 +00:00
|
|
|
then
|
2003-10-20 09:56:48 +00:00
|
|
|
# _xsltcommand="cd \$1 && if test \"\`dirname \$2 | head -c 1\`\" = \".\" ; then $_java -classpath $_saxon_jar com.icl.saxon.StyleSheet \$_IN_DIR/\$3 \$_IN_DIR/\$2 ; else $_java -classpath $_saxon_jar com.icl.saxon.StyleSheet \$_IN_DIR/\$3 \$2 ;fi"
|
|
|
|
_xsltcommand="
|
|
|
|
if test \"\`dirname \$2 | head -c 1\`\" = \".\"
|
|
|
|
then
|
|
|
|
_STYLESHEET=\$_IN_DIR/\$2
|
|
|
|
else
|
|
|
|
_STYLESHEET=\$2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -d \$1
|
|
|
|
then
|
|
|
|
_DIRNAME=\"\$1\"
|
|
|
|
_OUTPUT=\"\"
|
|
|
|
else
|
|
|
|
_DIRNAME=\"\`dirname \$1\`\"
|
|
|
|
_OUTPUT=\"-o \`basename \$1\`\"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd \$_DIRNAME &&
|
|
|
|
java -classpath /usr/share/java/saxon.jar com.icl.saxon.StyleSheet \$_OUTPUT \$_IN_DIR/\$3 \$_STYLESHEET
|
|
|
|
"
|
|
|
|
|
2003-06-18 17:37:36 +00:00
|
|
|
echo "Found the Saxon XSLT Processor ($_saxon_jar), using Java VM '$_java'."
|
|
|
|
else
|
|
|
|
echo "Found the Saxon XSLT processor but no stylesheets on your system."
|
|
|
|
echo "Saxon is unusable without stylesheets."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -z "$_xsltcommand"
|
|
|
|
then
|
|
|
|
# Java not found.
|
|
|
|
# now try openjade/jade.
|
|
|
|
for _try_jade in jade openjade
|
|
|
|
do
|
|
|
|
if command -v $_try_jade > /dev/null
|
|
|
|
then
|
|
|
|
_jade=$_try_jade
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if test -n "$_jade"
|
|
|
|
then
|
|
|
|
echo "xsltproc and Saxon XSLT processors not found."
|
|
|
|
echo "I will try to use OpenJade or Jade (using '$_jade')."
|
|
|
|
echo "They aren't (currently) fully supported, however."
|
2005-04-11 22:59:33 +00:00
|
|
|
for _try_docbook_dsl in \
|
|
|
|
/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl \
|
|
|
|
/usr/local/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl
|
2003-06-18 17:37:36 +00:00
|
|
|
do
|
|
|
|
if test -f "$_try_docbook_dsl"
|
|
|
|
then
|
|
|
|
_docbook_dsl=$_try_docbook_dsl
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2005-04-11 22:59:33 +00:00
|
|
|
for _try_xml_dcl in \
|
|
|
|
/usr/share/sgml/declaration/xml.dcl \
|
|
|
|
/usr/local/share/sgml/declaration/xml.dcl
|
2003-06-18 17:37:36 +00:00
|
|
|
do
|
|
|
|
if test -f "$_try_xml_dcl"
|
|
|
|
then
|
|
|
|
_xml_dcl=$_try_xml_dcl
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if test "x$_docbook_dsl" = "x" -o "x$_xml_dcl" = "x"
|
|
|
|
then
|
|
|
|
echo "One of the files docbook.dsl and xml.dcl or both of them weren't found."
|
|
|
|
echo "Bailing out."
|
|
|
|
exit 1
|
|
|
|
fi
|
2003-06-30 19:30:36 +00:00
|
|
|
_xsltcommand="cd \$1 && $_jade -t xml -d $_docbook_dsl $_xml_dcl \$_IN_DIR/\$3"
|
2003-06-18 17:37:36 +00:00
|
|
|
else
|
|
|
|
echo "No valid XSLT processor found."
|
|
|
|
echo "Bailing out."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat > $_xsltwrapper << EOF
|
|
|
|
#!/bin/sh
|
|
|
|
# **************************************************
|
|
|
|
# This file is generated automatically. DO NOT EDIT.
|
|
|
|
# **************************************************
|
|
|
|
# This is a small wrapper script around many ways to call the XSLT processor.
|
|
|
|
# It accepts 3 arguments: <output_dir> <stylesheet_name> <main XML file name>
|
|
|
|
_IN_DIR=\`pwd\`
|
|
|
|
|
|
|
|
$_sgmlcatalog
|
|
|
|
$_xsltcommand
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x $_xsltwrapper
|
|
|
|
|
|
|
|
|
2003-10-21 11:07:02 +00:00
|
|
|
echo "Searching for XML checker..."
|
2003-06-18 17:37:36 +00:00
|
|
|
for _try_xmllint in xmllint
|
|
|
|
do
|
2003-11-16 00:57:47 +00:00
|
|
|
if command -v $_try_xmllint > /dev/null 2>&1
|
2003-06-18 17:37:36 +00:00
|
|
|
then
|
2004-01-20 23:27:25 +00:00
|
|
|
echo "Found $_try_xmllint"
|
2003-06-18 17:37:36 +00:00
|
|
|
if test -n "$_catalog"
|
|
|
|
then
|
|
|
|
_xmllint_command="$_try_xmllint --noout --noent --postvalid --catalogs \$*"
|
|
|
|
else
|
|
|
|
_xmllint_command="$_try_xmllint --noout --noent --postvalid \$*"
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -z "$_xmllint_command"
|
|
|
|
then
|
2003-10-20 09:56:48 +00:00
|
|
|
echo "Not found"
|
2003-06-18 17:37:36 +00:00
|
|
|
_xmllint_command=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat > $_xmllintwrapper << EOF
|
|
|
|
#!/bin/sh
|
|
|
|
# **************************************************
|
|
|
|
# This file is generated automatically. DO NOT EDIT.
|
|
|
|
# **************************************************
|
|
|
|
# This is a small wrapper for XML lintian programs.
|
|
|
|
$_sgmlcatalog
|
|
|
|
$_xmllint_command
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x $_xmllintwrapper
|