blob: 5d9428d977efb6a672d639ebc6849fc03b9ecf8c (
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
|
#!/bin/sh
# Uncomment to debugging
#set -x
usage() {
sed 's/\ \ /\ /g' <<END
Generate the Debian Installer Manual in several different formats
Usage: $0 [params]
[params] can be any combination of the following:
- 'debug' to make debug output appear and skip removing old files
- '--help' or 'help' to print this usage help
- a language name (see below)
- an architecture name (see below)
- a file format (see below)
- '-d <dir>' to produce output in the <dir>-directory
- 'official' to build the official version of the manual
Example: $0 ru en i386 sparc pdf
Defaults: $default_language $default_format $default_arch
Available languages: $LANGUAGES
Available architectures: $ARCHS
Available formats: $FORMATS
END
exit 0
}
create_ProfiledXML () {
[ -x /usr/bin/xsltproc ] || return 9
[ -f $tempdir/install.$cur_lang.profiled.xml ] && return
entities_path="$build_path/entities"
source_path="$manual_path/$cur_lang"
if [ ! "$official_build" ]; then
unofficial_build="FIXME;unofficial-build"
else
unofficial_build=""
fi
. arch-options/$cur_arch
# Join all architecture options into one big variable
condition="$fdisk;$network;$boot;$smp;$other;$goodies;$unofficial_build;$status"
# Write dynamic non-profilable entities into the file
echo "<!-- arch- and lang-specific non-profilable entities -->" > $dynamic
echo "<!ENTITY langext \".$cur_lang\">" >> $dynamic
echo "<!ENTITY architecture \"$cur_arch\">" >> $dynamic
echo "<!ENTITY kernelversion \"${kernelversion}\">" >> $dynamic
echo "<!ENTITY altkernelversion \"${altkernelversion}\">" >> $dynamic
sed "s:##SRCPATH##:$source_path:" templates/docstruct.ent >> $dynamic
sed "s:##LANG##:$cur_lang:g" templates/install.xml.template | \
sed "s:##TEMPDIR##:$tempdir:g" | \
sed "s:##ENTPATH##:$entities_path:g" | \
sed "s:##SRCPATH##:$source_path:" > $tempdir/install.$cur_lang.xml
# Create the profiled xml file
/usr/bin/xsltproc \
--xinclude \
--stringparam profile.arch "$archspec" \
--stringparam profile.condition "$condition" \
--output $tempdir/install.$cur_lang.profiled.xml \
$stylesheet_profile \
$tempdir/install.$cur_lang.xml > /dev/null 2>&1
RET=$?; [ $RET -ne 0 ] && return $RET
return 0
}
create_HTML () {
/usr/bin/xsltproc --xinclude \
--stringparam base.dir "$tempdir/$cur_lang.$cur_arch.html/" \
$stylesheet_html \
"$tempdir/install.$cur_lang.profiled.xml" > /dev/null 2>&1
RET=$?; [ $RET -ne 0 ] && return $RET
output_files="$output_files $tempdir/$cur_lang.$cur_arch.html/"
return 0
}
create_SingleHTML () {
if [ ! -f $tempdir/install.$cur_lang.html ]; then
/usr/bin/xsltproc \
--xinclude \
--output $tempdir/install.$cur_lang.html \
$stylesheet_html_single \
$tempdir/install.${cur_lang}.profiled.xml
RET=$?; [ $RET -ne 0 ] && return $RET
mv $tempdir/install.$cur_lang.html $tempdir/install.$cur_lang.uncorr.html
# Replace some unprintable characters
sed "s:–:-:g # n-dash
s:—:--:g # m-dash
s:“:\":g # different types of quotes
s:”:\":g
s:„:\":g
s:…:...:g # ellipsis
s:™: (tm):g # trademark" \
$tempdir/install.$cur_lang.uncorr.html >$tempdir/install.$cur_lang.html
rm $tempdir/install.$cur_lang.uncorr.html
fi
output_files="$output_files $tempdir/install.$cur_lang.html"
}
create_Text () {
[ -x /usr/bin/w3m ] || return 9
# Set encoding for output file
case "$cur_lang" in
cs)
CHARSET=ISO-8859-2
;;
ja)
CHARSET=EUC-JP
;;
ru)
CHARSET=KOI8-R
;;
*)
CHARSET=UTF-8
;;
esac
echo /usr/bin/w3m -dump $tempdir/install.$cur_lang.html \
-o display_charset=$CHARSET \
>$tempdir/install.$cur_lang.txt
/usr/bin/w3m -dump $tempdir/install.$cur_lang.html \
-o display_charset=$CHARSET \
>$tempdir/install.$cur_lang.txt
RET=$?; [ $RET -ne 0 ] && return $RET
output_files="$output_files $tempdir/install.${cur_lang}.txt"
return 0
}
create_JadeTeX () {
[ -f $tempdir/install.$cur_lang.tex ] && return
[ -x /usr/bin/openjade ] || return 9
# And use openjade to generate a .tex file
export SP_ENCODING="utf-8"
/usr/bin/openjade -t tex \
-b utf-8 \
-o $tempdir/install.${cur_lang}.tex \
-d $stylesheet_dsssl \
-V tex-backend \
$tempdir/install.${cur_lang}.profiled.xml > /dev/null 2>&1
RET=$?
return $RET
}
create_JadeDVI () {
[ -x /usr/bin/jadetex ] || return 9
# Next we use jadetext to generate a .dvi file
# This needs three passes to properly generate the index (page numbering)
cd $tempdir
echo -n "("
for PASS in 1 2 3 ; do
echo -n "$PASS"
/usr/bin/jadetex -interaction=batchmode install.${cur_lang}.tex >/dev/null
# RET=$?; [ $RET -ne 0 ] && break
[ "$PASS" -lt 3 ] && echo -n "-"
done
echo -n ") "
cd ..
return $RET
}
create_LaTeX () {
[ -f $tempdir/install.$cur_lang.new.tex ] && return
sed "s:##LANG##:$cur_lang:g" templates/driver.xsl.template > $tempdir/driver.xsl
xsltproc \
-o $tempdir/install.${cur_lang}.new.tex \
$tempdir/driver.xsl \
$tempdir/install.${cur_lang}.profiled.xml &> xsltproc.log
RET=$?
# Japanese is different :(
if [ "$cur_lang" == "ja" ]; then
cat $tempdir/install.${cur_lang}.new.tex | \
sed 's/\\begin{document}/\\begin{document}\\begin{CJK*}\[dnp\]{JIS}{min}/g' | \
sed 's/\\end{document}/\\end{CJK*}\\end{document}/g' \
> $tempdir/install.${cur_lang}.new.tex.tmp
mv $tempdir/install.${cur_lang}.new.tex.tmp $tempdir/install.${cur_lang}.new.tex
recode -f UTF-8..EUC-JP $tempdir/install.${cur_lang}.new.tex
fi
output_files="$output_files $tempdir/install.${cur_lang}.new.tex"
return $RET
}
create_DVI () {
cd $tempdir
echo -n "("
for PASS in 1 2 3 ; do
echo -n "$PASS"
/usr/bin/latex -interaction=batchmode install.${cur_lang}.new.tex > /dev/null
# RET=$?; [ $RET -ne 0 ] && break
[ "$PASS" -lt 3 ] && echo -n "-"
done
echo -n ") "
cd ..
}
create_newPDF () {
cd $tempdir
echo -n "("
for PASS in 1 2 3 ; do
echo -n "$PASS"
/usr/bin/pdflatex -interaction=batchmode install.${cur_lang}.new.tex > /dev/null
# RET=$?; [ $RET -ne 0 ] && break
[ "$PASS" -lt 3 ] && echo -n "-"
done
echo -n ") "
cd ..
output_files="$output_files $tempdir/install.$cur_lang.new.pdf"
return $RET
}
create_newPS () {
/usr/bin/dvips -q $tempdir/install.${cur_lang}.new.dvi -o $tempdir/install.${cur_lang}.new.ps
RET=$?; [ $RET -ne 0 ] && return $RET
output_files="$output_files $tempdir/install.${cur_lang}.new.ps"
}
create_PDF() {
cd $tempdir
echo -n "("
for PASS in 1 2 3 ; do
echo -n "$PASS"
/usr/bin/pdfjadetex -interaction=batchmode install.${cur_lang}.tex > /dev/null
RET=$?; [ $RET -ne 0 ] && break
[ "$PASS" -lt 3 ] && echo -n "-"
done
echo -n ") "
cd ..
output_files="$output_files $tempdir/install.${cur_lang}.pdf"
return $RET
}
create_PS () {
[ -x /usr/bin/dvips ] || return 9
/usr/bin/dvips -q $tempdir/install.${cur_lang}.dvi -o $tempdir/install.${cur_lang}.ps
RET=$?; [ $RET -ne 0 ] && return $RET
output_files="$output_files $tempdir/install.${cur_lang}.ps"
return 0
}
debug_echo () {
if [ ! -z "$debug" ]; then
echo "DEBUG: $1"
fi
}
create_toolchain () {
echo -n "$((($BUILD_NO-1)*100/$TOTAL_BUILDS)) $cur_lang $cur_arch $cur_format Docbook "
for i in $1; do
echo -n "-> $i "
create_$i;
RET=$?; [ $RET -ne 0 ] && break
done
}
create_file () {
case $cur_format in
htmlone) create_toolchain "ProfiledXML SingleHTML" ;;
html) create_toolchain "ProfiledXML HTML" ;;
ps) create_toolchain "ProfiledXML JadeTeX JadeDVI PS" ;;
pdf) create_toolchain "ProfiledXML JadeTeX PDF" ;;
# dvi) create_toolchain "ProfiledXML JadeTeX JadeDVI" ;;
text) create_toolchain "ProfiledXML SingleHTML Text" ;;
newps) create_toolchain "ProfiledXML LaTeX DVI newPS" ;;
newpdf) create_toolchain "ProfiledXML LaTeX newPDF" ;;
latex) create_toolchain "ProfiledXML LaTeX" ;;
# dvinew) create_toolchain "ProfiledXML LaTeX DVI" ;;
esac
return $RET
}
handle_errors () {
RET=$?
case $RET in
0)
BUILD_OK="$BUILD_OK $cur_lang/$cur_arch/$cur_format"
;;
1)
BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
ERROR="execution error"
;;
9)
BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
ERROR="missing build dependencies"
;;
*)
BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
ERROR="unknown, code $RET"
;;
esac
if [ $RET -ne 0 ]; then
echo "-- failed ($ERROR)!"
return 1
else
echo "-- OK!"
return 0
fi
}
cleanup() {
if [ -z "$debug" ]; then
rm -rf $tempdir
fi
}
#################
# CONFIGURATION #
#################
basedir="$(cd "$(dirname $0)"; pwd)"
manual_path="$(echo $basedir | sed "s:/build$::")"
build_path="$manual_path/build"
# Define all possible languages, formats and archs.
# Warning: it is necessary to keep spaces around each arch, language and
# format to make sure we don't get an arch 'ps' just because it's a
# substring of 'mipsel'
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"`
ARCHS=`find arch-options -type f -maxdepth 1 -printf " %f "`
FORMATS=" html text pdf ps newpdf newps htmlone latex "
# Defaults
language=""
arch=""
format=""
default_language="en"
default_format="html"
default_arch="i386"
debug=""
# Paths
tempdir="build.tmp"
dynamic="${tempdir}/dynamic.ent"
stylesheet_dir="$build_path/stylesheets"
stylesheet_profile="$stylesheet_dir/style-profile.xsl"
stylesheet_html="$stylesheet_dir/style-html.xsl"
stylesheet_html_single="$stylesheet_dir/style-html-single.xsl"
stylesheet_fo="$stylesheet_dir/style-fo.xsl"
stylesheet_dsssl="$stylesheet_dir/style-print.dsl"
######################
# Parse command line #
######################
while [ "$1" != "" ]; do
found=""
comp=" $1 "
case $LANGUAGES in
*$comp*) language="$1 $language"
found="y"
;;
*);;
esac
case $ARCHS in
*$comp*) arch="$1 $arch"
found="y"
;;
*);;
esac
case $FORMATS in
*$comp*) format="$1 $format"
found="y"
;;
*);;
esac
if [ "$comp" == " --help " -o "$comp" == " help " ]; then
usage
found="y"
fi
if [ "$comp" == " debug " ]; then
debug="yes"
found="y"
fi
if [ "$comp" == " -d " ]; then
shift
destdir="$1"
found="y"
fi
if [ "$comp" == " official " ]; then
official_build="yes"
found="y"
fi
if [ -z "$found" ]; then
echo "Option '$1' unknown or unsupported. Ignoring."
fi
shift
done
if [ -z "$language" ]; then
language="$default_language"
fi
if [ -z "$format" ]; then
format="$default_format"
fi
if [ -z "$arch" ]; then
arch="$default_arch"
fi
debug_echo "Languages '$language'"
debug_echo "Formats '$format'"
debug_echo "Archs '$arch'"
# End parsing
cd $build_path
if [ -z "$destdir" ]; then
destdir="build.out"
fi
debug_echo "Output directory '$destdir'"
############
# MAINLINE #
############
# Clean old builds
#cleanup
#mkdir -p $tempdir
if [ ! -d "$destdir" ]; then
mkdir -p $destdir
fi
BUILD_OK=""
BUILD_FAIL=""
BUILD_NO="0"
output_files=""
TOTAL_BUILDS="$((`echo $language | wc -w`*`echo $arch | wc -w`*`echo $format | wc -w`))"
debug_echo "$TOTAL_BUILDS builds"
echo "------ ---- ---- ------ ------"
echo "% Done Lang Arch Format Status"
echo "------ ---- ---- ------ ------"
for cur_lang in $language; do
for cur_arch in $arch; do
cleanup && mkdir -p $tempdir
for cur_format in $format ; do
BUILD_NO=$(($BUILD_NO+1))
create_file
handle_errors
debug_echo "Output files '$output_files'"
for i in $output_files; do
output="$i"
done
mv "$output" "$destdir"
output_files=""
done
done
done
echo "100% done."
cleanup
# Evaluate the overall results
[ -z "$BUILD_FAIL" ] && exit 0 # Build successful for all formats
echo "Warning: The following formats failed to build:$BUILD_FAIL"
[ -n "$BUILD_OK" ] && exit 2 # Build failed for some formats
exit 1 # Build failed for all formats
#######
# END #
#######
|