3
# Uncomment to debugging
9
sed 's/\ \ /\ /g' <<END
11
Generate the Debian Installer Manual in several different formats
15
[params] can be any combination of the following:
17
- 'debug' to make debug output appear and skip removing old files
18
- '--help' or 'help' to print this usage help
19
- a language name (see below)
20
- an architecture name (see below)
21
- a file format (see below)
22
- '-d <dir>' to produce output in the <dir>-directory
23
- 'official' to build the official version of the manual
25
Example: $0 ru en i386 sparc pdf
27
Defaults: $default_language $default_format $default_arch
29
Available languages: $LANGUAGES
30
Available architectures: $ARCHS
31
Available formats: $FORMATS
40
create_ProfiledXML () {
42
[ -x /usr/bin/xsltproc ] || return 9
44
[ -f $tempdir/install.$cur_lang.profiled.xml ] && return
46
entities_path="$build_path/entities"
47
source_path="$manual_path/$cur_lang"
49
if [ ! "$official_build" ]; then
50
unofficial_build="FIXME;unofficial-build"
55
. arch-options/$cur_arch
57
# Join all architecture options into one big variable
58
condition="$fdisk;$network;$boot;$smp;$other;$goodies;$unofficial_build;$status"
60
# Write dynamic non-profilable entities into the file
61
echo "<!-- arch- and lang-specific non-profilable entities -->" > $dynamic
62
echo "<!ENTITY langext \".$cur_lang\">" >> $dynamic
63
echo "<!ENTITY architecture \"$cur_arch\">" >> $dynamic
64
echo "<!ENTITY kernelversion \"${kernelversion}\">" >> $dynamic
65
echo "<!ENTITY altkernelversion \"${altkernelversion}\">" >> $dynamic
66
sed "s:##SRCPATH##:$source_path:" templates/docstruct.ent >> $dynamic
68
sed "s:##LANG##:$cur_lang:g" templates/install.xml.template | \
69
sed "s:##TEMPDIR##:$tempdir:g" | \
70
sed "s:##ENTPATH##:$entities_path:g" | \
71
sed "s:##SRCPATH##:$source_path:" > $tempdir/install.$cur_lang.xml
73
# Create the profiled xml file
76
--stringparam profile.arch "$archspec" \
77
--stringparam profile.condition "$condition" \
78
--output $tempdir/install.$cur_lang.profiled.xml \
80
$tempdir/install.$cur_lang.xml > /dev/null 2>&1
81
RET=$?; [ $RET -ne 0 ] && return $RET
88
/usr/bin/xsltproc --xinclude \
89
--stringparam base.dir "$tempdir/$cur_lang.$cur_arch.html/" \
91
"$tempdir/install.$cur_lang.profiled.xml" > /dev/null 2>&1
93
RET=$?; [ $RET -ne 0 ] && return $RET
95
output_files="$output_files $tempdir/$cur_lang.$cur_arch.html/"
100
create_SingleHTML () {
102
if [ ! -f $tempdir/install.$cur_lang.html ]; then
106
--output $tempdir/install.$cur_lang.html \
107
$stylesheet_html_single \
108
$tempdir/install.${cur_lang}.profiled.xml
110
RET=$?; [ $RET -ne 0 ] && return $RET
112
mv $tempdir/install.$cur_lang.html $tempdir/install.$cur_lang.uncorr.html
114
# Replace some unprintable characters
116
sed "s:–:-:g # n-dash
118
s:“:\":g # different types of quotes
122
s:™: (tm):g # trademark" \
123
$tempdir/install.$cur_lang.uncorr.html >$tempdir/install.$cur_lang.html
125
rm $tempdir/install.$cur_lang.uncorr.html
129
output_files="$output_files $tempdir/install.$cur_lang.html"
135
[ -x /usr/bin/w3m ] || return 9
137
# Set encoding for output file
153
echo /usr/bin/w3m -dump $tempdir/install.$cur_lang.html \
154
-o display_charset=$CHARSET \
155
>$tempdir/install.$cur_lang.txt
157
/usr/bin/w3m -dump $tempdir/install.$cur_lang.html \
158
-o display_charset=$CHARSET \
159
>$tempdir/install.$cur_lang.txt
161
RET=$?; [ $RET -ne 0 ] && return $RET
163
output_files="$output_files $tempdir/install.${cur_lang}.txt"
170
[ -f $tempdir/install.$cur_lang.tex ] && return
173
[ -x /usr/bin/openjade ] || return 9
175
# And use openjade to generate a .tex file
176
export SP_ENCODING="utf-8"
177
/usr/bin/openjade -t tex \
179
-o $tempdir/install.${cur_lang}.tex \
180
-d $stylesheet_dsssl \
182
$tempdir/install.${cur_lang}.profiled.xml > /dev/null 2>&1
190
[ -x /usr/bin/jadetex ] || return 9
192
# Next we use jadetext to generate a .dvi file
193
# This needs three passes to properly generate the index (page numbering)
196
for PASS in 1 2 3 ; do
198
/usr/bin/jadetex -interaction=batchmode install.${cur_lang}.tex >/dev/null
199
# RET=$?; [ $RET -ne 0 ] && break
200
[ "$PASS" -lt 3 ] && echo -n "-"
209
[ -f $tempdir/install.$cur_lang.new.tex ] && return
211
sed "s:##LANG##:$cur_lang:g" templates/driver.xsl.template > $tempdir/driver.xsl
214
-o $tempdir/install.${cur_lang}.new.tex \
215
$tempdir/driver.xsl \
216
$tempdir/install.${cur_lang}.profiled.xml &> xsltproc.log
220
# Japanese is different :(
222
if [ "$cur_lang" == "ja" ]; then
223
cat $tempdir/install.${cur_lang}.new.tex | \
224
sed 's/\\begin{document}/\\begin{document}\\begin{CJK*}\[dnp\]{JIS}{min}/g' | \
225
sed 's/\\end{document}/\\end{CJK*}\\end{document}/g' \
226
> $tempdir/install.${cur_lang}.new.tex.tmp
227
mv $tempdir/install.${cur_lang}.new.tex.tmp $tempdir/install.${cur_lang}.new.tex
228
recode -f UTF-8..EUC-JP $tempdir/install.${cur_lang}.new.tex
231
output_files="$output_files $tempdir/install.${cur_lang}.new.tex"
242
for PASS in 1 2 3 ; do
244
/usr/bin/latex -interaction=batchmode install.${cur_lang}.new.tex > /dev/null
245
# RET=$?; [ $RET -ne 0 ] && break
246
[ "$PASS" -lt 3 ] && echo -n "-"
257
for PASS in 1 2 3 ; do
259
/usr/bin/pdflatex -interaction=batchmode install.${cur_lang}.new.tex > /dev/null
260
# RET=$?; [ $RET -ne 0 ] && break
261
[ "$PASS" -lt 3 ] && echo -n "-"
265
output_files="$output_files $tempdir/install.$cur_lang.new.pdf"
273
/usr/bin/dvips -q $tempdir/install.${cur_lang}.new.dvi -o $tempdir/install.${cur_lang}.new.ps
275
RET=$?; [ $RET -ne 0 ] && return $RET
277
output_files="$output_files $tempdir/install.${cur_lang}.new.ps"
285
for PASS in 1 2 3 ; do
287
/usr/bin/pdfjadetex -interaction=batchmode install.${cur_lang}.tex > /dev/null
288
RET=$?; [ $RET -ne 0 ] && break
289
[ "$PASS" -lt 3 ] && echo -n "-"
293
output_files="$output_files $tempdir/install.${cur_lang}.pdf"
299
[ -x /usr/bin/dvips ] || return 9
301
/usr/bin/dvips -q $tempdir/install.${cur_lang}.dvi -o $tempdir/install.${cur_lang}.ps
302
RET=$?; [ $RET -ne 0 ] && return $RET
304
output_files="$output_files $tempdir/install.${cur_lang}.ps"
310
if [ ! -z "$debug" ]; then
315
create_toolchain () {
317
echo -n "$((($BUILD_NO-1)*100/$TOTAL_BUILDS)) $cur_lang $cur_arch $cur_format Docbook "
321
RET=$?; [ $RET -ne 0 ] && break
329
htmlone) create_toolchain "ProfiledXML SingleHTML" ;;
330
html) create_toolchain "ProfiledXML HTML" ;;
331
ps) create_toolchain "ProfiledXML JadeTeX JadeDVI PS" ;;
332
pdf) create_toolchain "ProfiledXML JadeTeX PDF" ;;
333
# dvi) create_toolchain "ProfiledXML JadeTeX JadeDVI" ;;
334
text) create_toolchain "ProfiledXML SingleHTML Text" ;;
335
newps) create_toolchain "ProfiledXML LaTeX DVI newPS" ;;
336
newpdf) create_toolchain "ProfiledXML LaTeX newPDF" ;;
337
latex) create_toolchain "ProfiledXML LaTeX" ;;
338
# dvinew) create_toolchain "ProfiledXML LaTeX DVI" ;;
349
BUILD_OK="$BUILD_OK $cur_lang/$cur_arch/$cur_format"
352
BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
353
ERROR="execution error"
356
BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
357
ERROR="missing build dependencies"
360
BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
361
ERROR="unknown, code $RET"
364
if [ $RET -ne 0 ]; then
365
echo "-- failed ($ERROR)!"
375
if [ -z "$debug" ]; then
385
basedir="$(cd "$(dirname $0)"; pwd)"
386
manual_path="$(echo $basedir | sed "s:/build$::")"
387
build_path="$manual_path/build"
389
# Define all possible languages, formats and archs.
391
# Warning: it is necessary to keep spaces around each arch, language and
392
# format to make sure we don't get an arch 'ps' just because it's a
393
# substring of 'mipsel'
395
LANGUAGES=`find $basedir/.. -type d -maxdepth 1 -printf " %f \n" | grep -v "^\ \." | grep -v "build" | grep -v "scripts" | grep -v "po" | sort | tr -d "\n"`
396
ARCHS=`find arch-options -type f -maxdepth 1 -printf " %f "`
397
FORMATS=" html text pdf ps newpdf newps htmlone latex "
404
default_language="en"
405
default_format="html"
412
dynamic="${tempdir}/dynamic.ent"
414
stylesheet_dir="$build_path/stylesheets"
415
stylesheet_profile="$stylesheet_dir/style-profile.xsl"
416
stylesheet_html="$stylesheet_dir/style-html.xsl"
417
stylesheet_html_single="$stylesheet_dir/style-html-single.xsl"
418
stylesheet_fo="$stylesheet_dir/style-fo.xsl"
419
stylesheet_dsssl="$stylesheet_dir/style-print.dsl"
422
######################
423
# Parse command line #
424
######################
426
while [ "$1" != "" ]; do
430
*$comp*) language="$1 $language"
437
*$comp*) arch="$1 $arch"
444
*$comp*) format="$1 $format"
450
if [ "$comp" == " --help " -o "$comp" == " help " ]; then
455
if [ "$comp" == " debug " ]; then
460
if [ "$comp" == " -d " ]; then
466
if [ "$comp" == " official " ]; then
471
if [ -z "$found" ]; then
472
echo "Option '$1' unknown or unsupported. Ignoring."
479
if [ -z "$language" ]; then
480
language="$default_language"
483
if [ -z "$format" ]; then
484
format="$default_format"
487
if [ -z "$arch" ]; then
491
debug_echo "Languages '$language'"
492
debug_echo "Formats '$format'"
493
debug_echo "Archs '$arch'"
499
if [ -z "$destdir" ]; then
504
debug_echo "Output directory '$destdir'"
518
if [ ! -d "$destdir" ]; then
528
TOTAL_BUILDS="$((`echo $language | wc -w`*`echo $arch | wc -w`*`echo $format | wc -w`))"
530
debug_echo "$TOTAL_BUILDS builds"
532
echo "------ ---- ---- ------ ------"
533
echo "% Done Lang Arch Format Status"
534
echo "------ ---- ---- ------ ------"
536
for cur_lang in $language; do
537
for cur_arch in $arch; do
538
cleanup && mkdir -p $tempdir
539
for cur_format in $format ; do
540
BUILD_NO=$(($BUILD_NO+1))
543
debug_echo "Output files '$output_files'"
544
for i in $output_files; do
547
mv "$output" "$destdir"
557
# Evaluate the overall results
558
[ -z "$BUILD_FAIL" ] && exit 0 # Build successful for all formats
559
echo "Warning: The following formats failed to build:$BUILD_FAIL"
560
[ -n "$BUILD_OK" ] && exit 2 # Build failed for some formats
561
exit 1 # Build failed for all formats