~ubuntu-branches/ubuntu/vivid/installation-guide/vivid-proposed

« back to all changes in this revision

Viewing changes to build/buildone_ng.sh

  • Committer: Bazaar Package Importer
  • Author(s): Frans Pop
  • Date: 2005-10-25 17:37:25 UTC
  • Revision ID: james.westby@ubuntu.com-20051025173725-aq0bm11be7bfd7rw
Tags: 20051025
* Mention in copyright that full GPL is included in the manual.
  Closes: #334925
* Register installed documents with doc-base.
* Minor updates in English text and translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Uncomment to debugging
 
4
#set -x
 
5
 
 
6
usage() {
 
7
 
 
8
 
 
9
        sed 's/\ \ /\ /g' <<END
 
10
 
 
11
Generate the Debian Installer Manual in several different formats
 
12
 
 
13
Usage: $0 [params]
 
14
 
 
15
[params] can be any combination of the following:
 
16
 
 
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
 
24
 
 
25
Example: $0 ru en i386 sparc pdf
 
26
 
 
27
Defaults: $default_language $default_format $default_arch
 
28
 
 
29
Available languages:            $LANGUAGES
 
30
Available architectures:        $ARCHS
 
31
Available formats:              $FORMATS
 
32
 
 
33
END
 
34
 
 
35
exit 0
 
36
 
 
37
 
 
38
}
 
39
 
 
40
create_ProfiledXML () {
 
41
 
 
42
        [ -x /usr/bin/xsltproc ] || return 9
 
43
        
 
44
        [ -f $tempdir/install.$cur_lang.profiled.xml ] && return
 
45
        
 
46
        entities_path="$build_path/entities"
 
47
        source_path="$manual_path/$cur_lang"
 
48
 
 
49
        if [ ! "$official_build" ]; then
 
50
                unofficial_build="FIXME;unofficial-build"
 
51
        else
 
52
                unofficial_build=""
 
53
        fi
 
54
 
 
55
        . arch-options/$cur_arch
 
56
 
 
57
# Join all architecture options into one big variable
 
58
        condition="$fdisk;$network;$boot;$smp;$other;$goodies;$unofficial_build;$status"
 
59
 
 
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
 
67
 
 
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
 
72
 
 
73
# Create the profiled xml file
 
74
        /usr/bin/xsltproc \
 
75
                --xinclude \
 
76
                --stringparam profile.arch "$archspec" \
 
77
                --stringparam profile.condition "$condition" \
 
78
                --output $tempdir/install.$cur_lang.profiled.xml \
 
79
                $stylesheet_profile \
 
80
                $tempdir/install.$cur_lang.xml > /dev/null 2>&1
 
81
        RET=$?; [ $RET -ne 0 ] && return $RET
 
82
 
 
83
        return 0
 
84
}
 
85
 
 
86
create_HTML () {
 
87
 
 
88
        /usr/bin/xsltproc --xinclude \
 
89
                --stringparam base.dir  "$tempdir/$cur_lang.$cur_arch.html/" \
 
90
                $stylesheet_html \
 
91
                "$tempdir/install.$cur_lang.profiled.xml" > /dev/null 2>&1
 
92
 
 
93
        RET=$?; [ $RET -ne 0 ] && return $RET
 
94
 
 
95
        output_files="$output_files $tempdir/$cur_lang.$cur_arch.html/"
 
96
 
 
97
        return 0
 
98
}
 
99
 
 
100
create_SingleHTML () {
 
101
 
 
102
        if [ ! -f  $tempdir/install.$cur_lang.html ]; then
 
103
        
 
104
        /usr/bin/xsltproc \
 
105
                --xinclude \
 
106
                --output $tempdir/install.$cur_lang.html \
 
107
                $stylesheet_html_single \
 
108
                $tempdir/install.${cur_lang}.profiled.xml
 
109
 
 
110
        RET=$?; [ $RET -ne 0 ] && return $RET
 
111
 
 
112
        mv $tempdir/install.$cur_lang.html $tempdir/install.$cur_lang.uncorr.html
 
113
 
 
114
        # Replace some unprintable characters
 
115
        
 
116
        sed "s:–:-:g        # n-dash
 
117
                 s:—:--:g       # m-dash
 
118
                 s:“:\&quot;:g  # different types of quotes
 
119
                 s:”:\&quot;:g
 
120
                 s:„:\&quot;:g
 
121
                 s:…:...:g      # ellipsis
 
122
                 s:™: (tm):g    # trademark" \
 
123
                $tempdir/install.$cur_lang.uncorr.html >$tempdir/install.$cur_lang.html
 
124
 
 
125
        rm $tempdir/install.$cur_lang.uncorr.html
 
126
 
 
127
        fi
 
128
 
 
129
        output_files="$output_files $tempdir/install.$cur_lang.html"
 
130
 
 
131
}
 
132
 
 
133
create_Text () {
 
134
 
 
135
    [ -x /usr/bin/w3m ] || return 9
 
136
 
 
137
    # Set encoding for output file
 
138
    case "$cur_lang" in
 
139
        cs)
 
140
            CHARSET=ISO-8859-2
 
141
            ;;
 
142
        ja)
 
143
            CHARSET=EUC-JP
 
144
            ;;
 
145
        ru)
 
146
            CHARSET=KOI8-R
 
147
            ;;
 
148
        *)
 
149
            CHARSET=UTF-8
 
150
            ;;
 
151
    esac
 
152
    
 
153
    echo /usr/bin/w3m -dump $tempdir/install.$cur_lang.html \
 
154
        -o display_charset=$CHARSET \
 
155
        >$tempdir/install.$cur_lang.txt
 
156
 
 
157
    /usr/bin/w3m -dump $tempdir/install.$cur_lang.html \
 
158
        -o display_charset=$CHARSET \
 
159
        >$tempdir/install.$cur_lang.txt
 
160
 
 
161
    RET=$?; [ $RET -ne 0 ] && return $RET
 
162
 
 
163
    output_files="$output_files $tempdir/install.${cur_lang}.txt"
 
164
 
 
165
    return 0
 
166
}
 
167
 
 
168
create_JadeTeX () {
 
169
        
 
170
        [ -f  $tempdir/install.$cur_lang.tex ] && return
 
171
        
 
172
        
 
173
    [ -x /usr/bin/openjade ] || return 9
 
174
        
 
175
    # And use openjade to generate a .tex file
 
176
    export SP_ENCODING="utf-8"
 
177
    /usr/bin/openjade -t tex \
 
178
        -b utf-8 \
 
179
        -o $tempdir/install.${cur_lang}.tex \
 
180
        -d $stylesheet_dsssl \
 
181
        -V tex-backend \
 
182
        $tempdir/install.${cur_lang}.profiled.xml > /dev/null 2>&1
 
183
    RET=$?
 
184
    return $RET
 
185
 
 
186
}
 
187
 
 
188
create_JadeDVI () {
 
189
    
 
190
    [ -x /usr/bin/jadetex ] || return 9
 
191
 
 
192
    # Next we use jadetext to generate a .dvi file
 
193
    # This needs three passes to properly generate the index (page numbering)
 
194
    cd $tempdir
 
195
        echo -n "("
 
196
    for PASS in 1 2 3 ; do
 
197
                echo -n "$PASS"
 
198
        /usr/bin/jadetex -interaction=batchmode install.${cur_lang}.tex >/dev/null
 
199
#               RET=$?; [ $RET -ne 0 ] && break
 
200
                [ "$PASS" -lt 3 ] && echo -n "-"
 
201
    done
 
202
        echo -n ") "
 
203
    cd ..
 
204
    return $RET
 
205
}
 
206
 
 
207
create_LaTeX () {
 
208
 
 
209
        [ -f  $tempdir/install.$cur_lang.new.tex ] && return
 
210
        
 
211
    sed "s:##LANG##:$cur_lang:g" templates/driver.xsl.template > $tempdir/driver.xsl
 
212
 
 
213
        xsltproc \
 
214
                -o $tempdir/install.${cur_lang}.new.tex \
 
215
                $tempdir/driver.xsl \
 
216
                $tempdir/install.${cur_lang}.profiled.xml &> xsltproc.log
 
217
        
 
218
        RET=$?
 
219
 
 
220
#       Japanese is different :(
 
221
 
 
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
 
229
        fi
 
230
        
 
231
    output_files="$output_files $tempdir/install.${cur_lang}.new.tex"
 
232
 
 
233
        return $RET
 
234
        
 
235
 
 
236
}
 
237
 
 
238
create_DVI () {
 
239
 
 
240
        cd $tempdir
 
241
        echo -n "("
 
242
        for PASS in 1 2 3 ; do
 
243
                echo -n "$PASS"
 
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 "-"
 
247
        done
 
248
        echo -n ") "
 
249
        cd ..
 
250
 
 
251
}
 
252
 
 
253
create_newPDF () {
 
254
 
 
255
    cd $tempdir
 
256
        echo -n "("
 
257
    for PASS in 1 2 3 ; do
 
258
                echo -n "$PASS"
 
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 "-"
 
262
    done
 
263
        echo -n ") "
 
264
    cd ..
 
265
        output_files="$output_files $tempdir/install.$cur_lang.new.pdf"
 
266
    return $RET
 
267
 
 
268
}
 
269
 
 
270
create_newPS () {
 
271
 
 
272
 
 
273
    /usr/bin/dvips -q $tempdir/install.${cur_lang}.new.dvi -o $tempdir/install.${cur_lang}.new.ps
 
274
 
 
275
    RET=$?; [ $RET -ne 0 ] && return $RET
 
276
    
 
277
        output_files="$output_files $tempdir/install.${cur_lang}.new.ps"
 
278
 
 
279
}
 
280
 
 
281
create_PDF() {
 
282
        
 
283
    cd $tempdir
 
284
        echo -n "("
 
285
    for PASS in 1 2 3 ; do
 
286
                echo -n "$PASS"
 
287
                /usr/bin/pdfjadetex -interaction=batchmode install.${cur_lang}.tex > /dev/null
 
288
        RET=$?; [ $RET -ne 0 ] && break
 
289
                [ "$PASS" -lt 3 ] && echo -n "-"
 
290
    done
 
291
        echo -n ") "
 
292
    cd ..
 
293
        output_files="$output_files $tempdir/install.${cur_lang}.pdf"
 
294
    return $RET
 
295
}
 
296
 
 
297
create_PS () {
 
298
    
 
299
    [ -x /usr/bin/dvips ] || return 9
 
300
 
 
301
    /usr/bin/dvips -q $tempdir/install.${cur_lang}.dvi -o $tempdir/install.${cur_lang}.ps
 
302
    RET=$?; [ $RET -ne 0 ] && return $RET
 
303
        
 
304
        output_files="$output_files $tempdir/install.${cur_lang}.ps"
 
305
 
 
306
    return 0
 
307
}
 
308
 
 
309
debug_echo () {
 
310
        if [ ! -z "$debug" ]; then
 
311
                echo "DEBUG: $1"
 
312
        fi
 
313
}
 
314
 
 
315
create_toolchain () {
 
316
 
 
317
        echo -n "$((($BUILD_NO-1)*100/$TOTAL_BUILDS))   $cur_lang       $cur_arch       $cur_format     Docbook "
 
318
        for i in $1; do
 
319
                echo -n "-> $i "
 
320
                create_$i;
 
321
        RET=$?; [ $RET -ne 0 ] && break
 
322
        done
 
323
        
 
324
}
 
325
 
 
326
create_file () {
 
327
 
 
328
        case $cur_format in
 
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"  ;;
 
339
        esac
 
340
 
 
341
        return $RET
 
342
}
 
343
 
 
344
handle_errors () {
 
345
 
 
346
        RET=$?
 
347
        case $RET in
 
348
                0)
 
349
                        BUILD_OK="$BUILD_OK $cur_lang/$cur_arch/$cur_format"
 
350
                        ;;
 
351
                1)
 
352
                        BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
 
353
                        ERROR="execution error"
 
354
                        ;;
 
355
                9)
 
356
                        BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
 
357
                        ERROR="missing build dependencies"
 
358
                        ;;
 
359
                *)
 
360
                        BUILD_FAIL="$BUILD_FAIL $cur_lang/$cur_arch/$cur_format"
 
361
                        ERROR="unknown, code $RET"
 
362
                        ;;
 
363
        esac
 
364
        if [ $RET -ne 0 ]; then
 
365
                echo "-- failed ($ERROR)!"
 
366
                return 1
 
367
        else
 
368
                echo "-- OK!"
 
369
                return 0
 
370
        fi
 
371
}
 
372
 
 
373
cleanup() {
 
374
        
 
375
if [ -z "$debug" ]; then
 
376
        rm -rf $tempdir
 
377
fi
 
378
        
 
379
}
 
380
 
 
381
#################
 
382
# CONFIGURATION #
 
383
#################
 
384
 
 
385
basedir="$(cd "$(dirname $0)"; pwd)"
 
386
manual_path="$(echo $basedir | sed "s:/build$::")"
 
387
build_path="$manual_path/build"
 
388
 
 
389
# Define all possible languages, formats and archs.
 
390
 
 
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'
 
394
 
 
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 "
 
398
 
 
399
# Defaults 
 
400
 
 
401
language=""
 
402
arch=""
 
403
format=""
 
404
default_language="en"
 
405
default_format="html"
 
406
default_arch="i386"
 
407
debug=""
 
408
 
 
409
# Paths
 
410
 
 
411
tempdir="build.tmp"
 
412
dynamic="${tempdir}/dynamic.ent"
 
413
 
 
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"
 
420
 
 
421
 
 
422
######################
 
423
# Parse command line #
 
424
######################
 
425
 
 
426
while [ "$1" != "" ]; do
 
427
        found=""
 
428
        comp=" $1 "
 
429
        case $LANGUAGES in
 
430
        *$comp*) language="$1 $language"
 
431
                found="y"
 
432
                ;;
 
433
        *);;
 
434
        esac
 
435
        
 
436
        case $ARCHS in
 
437
        *$comp*) arch="$1 $arch"
 
438
                found="y"
 
439
                ;;
 
440
        *);;
 
441
        esac
 
442
        
 
443
        case $FORMATS in
 
444
        *$comp*) format="$1 $format"
 
445
                found="y"
 
446
                ;;
 
447
        *);;
 
448
        esac
 
449
        
 
450
        if [ "$comp" == " --help " -o "$comp" == " help " ]; then
 
451
                usage
 
452
                found="y"
 
453
        fi
 
454
 
 
455
        if [ "$comp" == " debug " ]; then
 
456
                debug="yes"
 
457
                found="y"
 
458
        fi
 
459
        
 
460
        if [ "$comp" == " -d " ]; then
 
461
                shift
 
462
                destdir="$1"
 
463
                found="y"
 
464
        fi
 
465
        
 
466
        if [ "$comp" == " official " ]; then
 
467
                official_build="yes"    
 
468
                found="y"
 
469
        fi
 
470
        
 
471
        if [ -z "$found" ]; then
 
472
                echo "Option '$1' unknown or unsupported. Ignoring."
 
473
        fi
 
474
        
 
475
        shift
 
476
        
 
477
done
 
478
 
 
479
if [ -z "$language" ]; then
 
480
        language="$default_language"
 
481
fi
 
482
 
 
483
if [ -z "$format" ]; then
 
484
        format="$default_format"
 
485
fi
 
486
 
 
487
if [ -z "$arch" ]; then
 
488
        arch="$default_arch"
 
489
fi
 
490
 
 
491
debug_echo "Languages '$language'"
 
492
debug_echo "Formats '$format'"
 
493
debug_echo "Archs '$arch'"
 
494
        
 
495
# End parsing
 
496
 
 
497
cd $build_path
 
498
 
 
499
if [ -z "$destdir" ]; then
 
500
    destdir="build.out"
 
501
fi
 
502
 
 
503
 
 
504
debug_echo "Output directory '$destdir'"
 
505
 
 
506
 
 
507
 
 
508
############
 
509
# MAINLINE #
 
510
############
 
511
 
 
512
# Clean old builds
 
513
 
 
514
#cleanup
 
515
 
 
516
#mkdir -p $tempdir
 
517
 
 
518
if [ ! -d "$destdir" ]; then 
 
519
        mkdir -p $destdir
 
520
fi
 
521
 
 
522
BUILD_OK=""
 
523
BUILD_FAIL=""
 
524
BUILD_NO="0"
 
525
 
 
526
output_files=""
 
527
 
 
528
TOTAL_BUILDS="$((`echo $language | wc -w`*`echo $arch | wc -w`*`echo $format | wc -w`))"
 
529
 
 
530
debug_echo "$TOTAL_BUILDS builds"
 
531
 
 
532
echo "------    ----    ----    ------  ------"
 
533
echo "% Done    Lang    Arch    Format  Status"
 
534
echo "------    ----    ----    ------  ------"
 
535
 
 
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))
 
541
                        create_file
 
542
                        handle_errors 
 
543
                        debug_echo "Output files '$output_files'"
 
544
                        for i in $output_files; do
 
545
                                output="$i"
 
546
                        done
 
547
                        mv "$output" "$destdir"
 
548
                        output_files=""
 
549
                done
 
550
        done
 
551
done
 
552
 
 
553
echo "100% done."
 
554
 
 
555
cleanup
 
556
 
 
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
 
562
 
 
563
#######
 
564
# END #
 
565
#######