blob: 520afd3b11b7462c50b96adee215b32444f9b9db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
#!/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"
echo "Searching for XML catalogs..."
for _try_catalog in \
/etc/sgml/catalog \
/usr/share/xml/docbook/*/catalog.xml \
/opt/local/share/xml/docbook-xml/*/catalog.xml \
/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
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
echo "Searching for stylesheets..."
echo "Searching for html/chunk.xsl..."
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 \
/usr/share/sgml/docbook/xsl-stylesheets*/html/chunk.xsl \
/usr/share/xml/docbook/stylesheet/nwalsh/current/html/chunk.xsl \
/opt/local/share/xsl/docbook-xsl/html/chunk.xsl \
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
echo "Not found. Using default ($_chunk_xsl)"
_fake_chunk_xsl=yes
else
echo "Found chunk.xsl at $_chunk_xsl"
fi
echo "Searching for html/docbook.xsl..."
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 \
/usr/share/sgml/docbook/xsl-stylesheets*/html/docbook.xsl \
/usr/share/xml/docbook/stylesheet/nwalsh/current/html/docbook.xsl \
/opt/local/share/xsl/docbook-xsl/html/docbook.xsl \
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
<?xml version="1.0" encoding="utf-8"?>
<!-- **************************************************
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
cat > html-single.xsl << EOF
<?xml version="1.0" encoding="utf-8"?>
<!-- **************************************************
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
echo "Searching for DTD..."
for _try_dtd in \
/usr/share/xml/docbook/*/docbookx.dtd \
/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 \
/usr/share/sgml/docbook/xml-dtd-4.4/docbookx.dtd \
/usr/share/xml/docbook/schema/dtd/4.2/docbookx.dtd \
/opt/local/share/xml/docbook-xml/4.2/docbookx.dtd \
/usr/share/sgml/docbook/dtd/4.2/docbookx.dtd
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
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!-- **************************************************
This file is generated automatically. DO NOT EDIT.
************************************************** -->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"$_dtd"
[
EOF
for file in `find $lang en -name \*.xml -exec basename \{\} \; | sort -u`; do
echo '<!ENTITY '$file' SYSTEM "'$file'">' >> $lang/main.xml
done
cat >> $lang/main.xml << EOF
]>
<book id="index" lang="$lang">
&documentation.xml;
</book>
EOF
done
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
if test -z "$_fake_chunk_xsl"
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
#FIXME: Add more suitable machines!!!
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.
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
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
if test -z "$_fake_chunk_xsl"
then
# _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
"
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."
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
do
if test -f "$_try_docbook_dsl"
then
_docbook_dsl=$_try_docbook_dsl
break
fi
done
for _try_xml_dcl in \
/usr/share/sgml/declaration/xml.dcl \
/usr/local/share/sgml/declaration/xml.dcl
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
_xsltcommand="cd \$1 && $_jade -t xml -d $_docbook_dsl $_xml_dcl \$_IN_DIR/\$3"
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
echo "Searching for XML checker..."
for _try_xmllint in xmllint
do
if command -v $_try_xmllint > /dev/null 2>&1
then
echo "Found $_try_xmllint"
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
echo "Not found"
_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
|