/[d-i]/trunk/manual/build/buildone.sh
ViewVC logotype

Contents of /trunk/manual/build/buildone.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42357 - (show annotations) (download) (as text)
Mon Oct 30 17:18:55 2006 UTC (6 years, 7 months ago) by fjp
File MIME type: application/x-sh
File size: 9280 byte(s)
Add misplaced entry
1 #!/bin/sh
2
3 if [ "$1" = "--help" ]; then
4 echo "$0: Generate the Debian Installer Manual in several different formats"
5 echo "Usage: $0 [arch] [lang] [format]"
6 echo "[format] may consist of multiple formats provided they are quoted (e.g. \"html pdf\")"
7 echo "Supported formats: html, ps, pdf, txt"
8 exit 0
9 fi
10
11 arch=${1:-i386}
12 language=${2:-en}
13 formats=${3:-html}
14
15 ## Configuration
16 basedir="$(cd "$(dirname $0)"; pwd)"
17 manual_path="$(echo $basedir | sed "s:/build$::")"
18 build_path="$manual_path/build"
19 cd $build_path
20
21 stylesheet_dir="$build_path/stylesheets"
22 stylesheet_profile="$stylesheet_dir/style-profile.xsl"
23 if [ ! "$web_build" ]; then
24 stylesheet_html="$stylesheet_dir/style-html.xsl"
25 else
26 stylesheet_html="$stylesheet_dir/style-html-web.xsl"
27 fi
28 stylesheet_html_single="$stylesheet_dir/style-html-single.xsl"
29 stylesheet_fo="$stylesheet_dir/style-fo.xsl"
30 stylesheet_dsssl="$stylesheet_dir/style-print.dsl"
31 stylesheet_css="$stylesheet_dir/install.css"
32
33 entities_path="$build_path/entities"
34 source_path="$manual_path/$language"
35
36 if [ -z "$destdir" ]; then
37 destdir="build.out"
38 fi
39
40 tempdir="build.tmp"
41 dynamic="${tempdir}/dynamic.ent"
42
43 create_profiled () {
44
45 [ -x "`which xsltproc 2>/dev/null`" ] || return 9
46
47 echo "Info: creating temporary profiled .xml file..."
48
49 if [ ! "$official_build" ]; then
50 unofficial_build="FIXME;unofficial-build"
51 else
52 unofficial_build=""
53 fi
54
55 if [ -z "$manual_release" ]; then
56 manual_release="etch"
57 fi
58 if [ -z "$manual_target" ]; then
59 manual_target="for_cd"
60 fi
61
62 # Now we source the profiling information for the selected architecture
63 [ -f "arch-options/${arch}" ] || {
64 echo "Error: unknown architecture '$arch'"
65 return 1
66 }
67 . arch-options/$arch
68
69 # Now we source the profiling information for the current language
70 if [ -f "lang-options/${language}" ]; then
71 . lang-options/$language
72 fi
73
74 # Join all architecture options into one big variable
75 condition="$fdisk;$network;$boot;$smp;$other;$goodies;$unofficial_build;$status;$manual_release"
76 # Add language options
77 condition="$condition;$optional_paras"
78 # Add build options for the manual
79 condition="$condition;$unofficial_build;$status;$manual_release;$manual_target"
80 # TODO: Obsoleted, but keep until translations have been updated
81 condition="$condition;common-kpkg"
82
83 # Write dynamic non-profilable entities into the file
84 echo "<!-- arch- and lang-specific non-profilable entities -->" > $dynamic
85 echo "<!ENTITY langext \".${language}\">" >> $dynamic
86 echo "<!ENTITY architecture \"${arch}\">" >> $dynamic
87 echo "<!ENTITY kernelversion \"${kernelversion}\">" >> $dynamic
88 echo "<!ENTITY arch-listname \"${arch_listname}\">" >> $dynamic
89 echo "<!ENTITY altkernelversion \"${altkernelversion}\">" >> $dynamic
90 echo "<!ENTITY smp-config-section \"${smp_config_section}\">" >> $dynamic
91 echo "<!ENTITY smp-config-option \"${smp_config_option}\">" >> $dynamic
92 sed "s:##SRCPATH##:$source_path:" templates/docstruct.ent >> $dynamic
93
94 sed "s:##LANG##:$language:g" templates/install.xml.template | \
95 sed "s:##TEMPDIR##:$tempdir:g" | \
96 sed "s:##ENTPATH##:$entities_path:g" | \
97 sed "s:##SRCPATH##:$source_path:" > $tempdir/install.${language}.xml
98
99 # Create the profiled xml file
100 xsltproc \
101 --xinclude \
102 --stringparam profile.arch "$archspec" \
103 --stringparam profile.condition "$condition" \
104 --output $tempdir/install.${language}.profiled.xml \
105 $stylesheet_profile \
106 $tempdir/install.${language}.xml
107 RET=$?; [ $RET -ne 0 ] && return $RET
108
109 return 0
110 }
111
112 create_html () {
113
114 echo "Info: creating .html files..."
115
116 xsltproc \
117 --xinclude \
118 --stringparam base.dir $destdir/html/ \
119 $stylesheet_html \
120 $tempdir/install.${language}.profiled.xml
121 RET=$?; [ $RET -ne 0 ] && return $RET
122
123 # Copy the custom css stylesheet to the destination directory
124 cp $stylesheet_css $destdir/html/
125
126 return 0
127 }
128
129 create_text () {
130
131 [ -x "`which w3m 2>/dev/null`" ] || return 9
132
133 echo "Info: creating temporary .html file..."
134
135 xsltproc \
136 --xinclude \
137 --output $tempdir/install.${language}.html \
138 $stylesheet_html_single \
139 $tempdir/install.${language}.profiled.xml
140 RET=$?; [ $RET -ne 0 ] && return $RET
141
142 # Replace some unprintable characters
143 sed "s:–:-:g # n-dash
144 s:—:--:g # m-dash
145 s:“:\&quot;:g # different types of quotes
146 s:”:\&quot;:g
147 s:„:\&quot;:g
148 s:…:...:g # ellipsis
149 s:™: (tm):g # trademark" \
150 $tempdir/install.${language}.html >$tempdir/install.${language}.corr.html
151 RET=$?; [ $RET -ne 0 ] && return $RET
152
153 echo "Info: creating .txt file..."
154
155 # Set encoding for output file
156 case "$language" in
157 ja)
158 CHARSET=EUC-JP ;;
159 ko)
160 CHARSET=EUC-KR ;;
161 ru)
162 CHARSET=KOI8-R ;;
163 cs|el|hu|ro|zh_CN|zh_TW)
164 CHARSET=UTF-8 ;;
165 *)
166 CHARSET=ISO-8859-1 ;;
167 esac
168
169 HOME=$tempdir w3m -dump $tempdir/install.${language}.corr.html \
170 -o display_charset=$CHARSET \
171 >$destdir/install.${language}.txt
172 RET=$?; [ $RET -ne 0 ] && return $RET
173
174 return 0
175 }
176
177 create_dvi () {
178
179 [ -x "`which openjade 2>/dev/null`" ] || return 9
180 [ -x "`which jadetex 2>/dev/null`" ] || return 9
181
182 # Skip this step if the .dvi file already exists
183 [ -f "$tempdir/install.${language}.dvi" ] && return
184
185 echo "Info: creating temporary .tex file..."
186
187 # And use openjade to generate a .tex file
188 export SP_ENCODING="utf-8"
189 openjade -t tex \
190 -b utf-8 \
191 -o $tempdir/install.${language}.tex \
192 -d $stylesheet_dsssl \
193 -V tex-backend declaration/xml.dcl \
194 $tempdir/install.${language}.profiled.xml
195 RET=$?; [ $RET -ne 0 ] && return $RET
196
197 # some languages need additional macro
198 case "$language" in
199 ko)
200 mv $tempdir/install.${language}.tex \
201 $tempdir/install.${language}.orig.tex
202 cat templates/header.${language}.tex \
203 $tempdir/install.${language}.orig.tex \
204 > $tempdir/install.${language}.tex
205 rm $tempdir/install.${language}.orig.tex
206 ;;
207 esac
208
209 echo "Info: creating temporary .dvi file..."
210
211 # Next we use jadetex to generate a .dvi file
212 # This needs three passes to properly generate the index (page numbering)
213 cd $tempdir
214 for PASS in 1 2 3 ; do
215 jadetex install.${language}.tex >/dev/null
216 RET=$?; [ $RET -ne 0 ] && break
217 done
218 cd ..
219 [ $RET -ne 0 ] && return $RET
220
221 return 0
222 }
223
224 create_pdf() {
225
226 [ -x "`which dvipdf 2>/dev/null`" ] || return 9
227
228 create_dvi
229 RET=$?; [ $RET -ne 0 ] && return $RET
230
231 echo "Info: creating .pdf file..."
232
233 dvipdf $tempdir/install.${language}.dvi
234 RET=$?; [ $RET -ne 0 ] && return $RET
235 mv install.${language}.pdf $destdir/
236
237 return 0
238 }
239
240 create_ps() {
241
242 [ -x "`which dvips 2>/dev/null`" ] || return 9
243
244 create_dvi
245 RET=$?; [ $RET -ne 0 ] && return $RET
246
247 echo "Info: creating .ps file..."
248
249 dvips -q $tempdir/install.${language}.dvi
250 RET=$?; [ $RET -ne 0 ] && return $RET
251 mv install.${language}.ps $destdir/
252
253 return 0
254 }
255
256 ## MAINLINE
257
258 # Clean old builds
259 rm -rf $tempdir
260 rm -rf $destdir
261
262 [ -d "$manual_path/$language" ] || {
263 echo "Error: unknown language '$language'"
264 exit 1
265 }
266
267 mkdir -p $tempdir
268 mkdir -p $destdir
269
270 # Create profiled XML. This is needed for all output formats.
271 create_profiled
272 RET=$?; [ $RET -ne 0 ] && exit 1
273
274 BUILD_OK=""
275 BUILD_FAIL=""
276 for format in $formats ; do
277 case "$language" in
278 el|ja|vi|zh_CN|zh_TW)
279 if [ "$format" = "pdf" -o "$format" = "ps" ] ; then
280 echo "Warning: pdf and ps formats are currently not supported for Chinese, Greek, Japanese and Vietnamese"
281 BUILD_SKIP="$BUILD_SKIP $format"
282 continue
283 fi
284 ;;
285 esac
286
287 case $format in
288 html) create_html;;
289 ps) create_ps;;
290 pdf) create_pdf;;
291 txt) create_text;;
292 *)
293 echo "Error: format $format unknown or not yet supported!"
294 exit 1
295 ;;
296 esac
297
298 RET=$?
299 case $RET in
300 0)
301 BUILD_OK="$BUILD_OK $format"
302 ;;
303 9)
304 BUILD_FAIL="$BUILD_FAIL $format"
305 echo "Error: build of $format failed because of missing build dependencies"
306 ;;
307 *)
308 BUILD_FAIL="$BUILD_FAIL $format"
309 echo "Error: build of $format failed with error code $RET"
310 ;;
311 esac
312 done
313
314 # Clean up
315 #rm -r $tempdir
316
317 # Evaluate the overall results
318 [ -n "$BUILD_SKIP" ] && echo "Info: The following formats were skipped:$BUILD_SKIP"
319 [ -z "$BUILD_FAIL" ] && exit 0 # Build successful for all formats
320 echo "Warning: The following formats failed to build:$BUILD_FAIL"
321 [ -n "$BUILD_OK" ] && exit 2 # Build failed for some formats
322 exit 1 # Build failed for all formats

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5