source: CLFS/clfs.xsl@ bcbecc5

ablfs-more legacy trunk
Last change on this file since bcbecc5 was 489bdc2, checked in by Pierre Labastie <pierre@…>, 7 years ago

Always generate test instructions, and comment unwanted ones out.
Fixes ticket #1695, also for CLFS...

  • Property mode set to 100644
File size: 18.5 KB
Line 
1<?xml version="1.0"?>
2<!DOCTYPE xsl:stylesheet [
3 <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
4 %general-entities;
5]>
6
7<!-- $Id$ -->
8
9<xsl:stylesheet
10 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11 xmlns:exsl="http://exslt.org/common"
12 extension-element-prefixes="exsl"
13 version="1.0">
14
15<!-- XSLT stylesheet to create shell scripts from CLFS books. -->
16
17 <!-- Build method used -->
18 <xsl:param name="method" select="chroot"/>
19
20 <!-- Run test suites?
21 0 = none
22 1 = only Glibc, GCC and Binutils testsuites
23 2 = all testsuites
24 3 = alias to 2
25 -->
26 <xsl:param name="testsuite" select="1"/>
27
28 <!-- Bomb on test suites failures?
29 n = no, I want to build the full system and review the logs
30 y = yes, bomb at the first test suite failure to can review the build dir
31 -->
32 <xsl:param name="bomb-testsuite" select="n"/>
33
34 <!-- Install vim-lang package? OBSOLETE should always be 'n'-->
35 <xsl:param name="vim-lang" select="n"/>
36
37 <!-- Time zone -->
38 <xsl:param name="timezone" select="GMT"/>
39
40 <!-- Page size -->
41 <xsl:param name="page" select="letter"/>
42
43 <!-- Locale settings -->
44 <xsl:param name="lang" select="C"/>
45
46 <!-- Sparc64 processor type -->
47 <xsl:param name="sparc" select="none"/>
48
49 <!-- x86 32 bit target triplet -->
50 <xsl:param name="x86" select="i686-pc-linux-gnu"/>
51
52 <!-- mips target triplet -->
53 <xsl:param name="mips" select="mips-unknown-linux-gnu"/>
54
55 <xsl:template match="/">
56 <xsl:apply-templates select="//sect1"/>
57 </xsl:template>
58
59 <xsl:template match="sect1">
60 <xsl:choose>
61 <xsl:when test="../@id='chapter-partitioning' or
62 ../@id='chapter-getting-materials'"/>
63 <xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
64 <xsl:when test="../@id='chapter-boot' and $method='chroot'"/>
65 <xsl:when test="../@id='chapter-chroot' and $method='boot'"/>
66 <xsl:otherwise>
67 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
68 count(descendant::screen/userinput) &gt;
69 count(descendant::screen[@role='nodump'])">
70 <!-- The dirs names -->
71 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
72 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
73 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
74 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
75 <!-- The file names -->
76 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
77 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
78 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
79 <!-- The build order -->
80 <xsl:variable name="position" select="position()"/>
81 <xsl:variable name="order">
82 <xsl:choose>
83 <xsl:when test="string-length($position) = 1">
84 <xsl:text>00</xsl:text>
85 <xsl:value-of select="$position"/>
86 </xsl:when>
87 <xsl:when test="string-length($position) = 2">
88 <xsl:text>0</xsl:text>
89 <xsl:value-of select="$position"/>
90 </xsl:when>
91 <xsl:otherwise>
92 <xsl:value-of select="$position"/>
93 </xsl:otherwise>
94 </xsl:choose>
95 </xsl:variable>
96 <!-- Creating dirs and files -->
97 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
98 <xsl:choose>
99 <xsl:when test="@id='ch-chroot-changingowner' or
100 @id='ch-chroot-creatingdirs' or
101 @id='ch-chroot-createfiles' or
102 @id='ch-system-stripping'">
103 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
104 </xsl:when>
105 <xsl:otherwise>
106 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
107 </xsl:otherwise>
108 </xsl:choose>
109 <xsl:if test="not(@id='ch-system-stripping')">
110 <xsl:text>set -e</xsl:text>
111 </xsl:if>
112 <xsl:text>&#xA;</xsl:text>
113 <xsl:if test="sect2[@role='installation'] and
114 not(@id='ch-system-multiarch-wrapper')">
115 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
116 <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
117 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
118 </xsl:if>
119 </xsl:if>
120 <xsl:apply-templates select=".//para/userinput | .//screen"/>
121 <xsl:if test="not(@id='ch-chroot-chroot')">
122 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
123 </xsl:if>
124 <xsl:text>exit</xsl:text>
125 </exsl:document>
126 </xsl:if>
127 </xsl:otherwise>
128 </xsl:choose>
129 </xsl:template>
130
131 <xsl:template match="screen">
132 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
133 <xsl:apply-templates select="userinput" mode="screen"/>
134 </xsl:if>
135 </xsl:template>
136
137 <xsl:template match="para/userinput">
138 <xsl:if test="(contains(string(),'test') or
139 contains(string(),'check')) and
140 not($testsuite = '2' or $testsuite = '3')">
141 <xsl:text># </xsl:text>
142 </xsl:if>
143 <xsl:choose>
144 <xsl:when test="$bomb-testsuite = 'n'">
145 <xsl:value-of select="substring-before(string(),'make')"/>
146 <xsl:text>make -k</xsl:text>
147 <xsl:value-of select="substring-after(string(),'make')"/>
148 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
149 </xsl:when>
150 <xsl:otherwise>
151 <xsl:apply-templates/>
152 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
153 <xsl:if test="contains(string(),' -k ')">
154 <xsl:text> || true</xsl:text>
155 </xsl:if>
156 <xsl:text>&#xA;</xsl:text>
157 </xsl:otherwise>
158 </xsl:choose>
159 </xsl:template>
160
161 <xsl:template match="userinput" mode="screen">
162 <xsl:choose>
163 <!-- Estandarized package formats -->
164 <xsl:when test="contains(string(),'tar.gz')">
165 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
166 <xsl:text>tar.*</xsl:text>
167 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
168 <xsl:text>&#xA;</xsl:text>
169 </xsl:when>
170 <!-- Setting $LANG for /etc/profile -->
171 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
172 contains(string(),'export LANG=')">
173 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
174 <xsl:text>export LANG=</xsl:text>
175 <xsl:value-of select="$lang"/>
176 <xsl:value-of select="substring-after(string(),'charmap]')"/>
177 <xsl:text>&#xA;</xsl:text>
178 </xsl:when>
179 <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
180 <xsl:when test="contains(string(),'defkeymap')"/>
181 <!-- Copying the kernel config file -->
182 <xsl:when test="string() = 'make mrproper'">
183 <xsl:text>make mrproper&#xA;</xsl:text>
184 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
185 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
186 </xsl:if>
187 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
188 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
189 </xsl:if>
190 </xsl:when>
191 <!-- No interactive commands are needed if the .config file is the proper one -->
192 <xsl:when test="contains(string(),'menuconfig')"/>
193<!-- test instructions -->
194 <xsl:when test="@remap = 'test'">
195 <xsl:if test="not(ancestor::note[@os='a00'] and $method='chroot')">
196 <!-- Avoid executing the note before perl tests while in 'chroot' -->
197 <xsl:if test="
198 $testsuite = '0' or
199 $testsuite = '1' and
200 not(ancestor::sect1[@id='ch-system-gcc']) and
201 not(ancestor::sect1[contains(@id,'ch-system-eglibc')]) and
202 not(ancestor::sect1[contains(@id,'ch-system-glibc')]) and
203 not(ancestor::sect1[contains(@id,'ch-system-gmp')]) and
204 not(ancestor::sect1[contains(@id,'ch-system-mpfr')]) and
205 not(ancestor::sect1[contains(@id,'ch-system-mpc')]) and
206 not(ancestor::sect1[contains(@id,'ch-system-ppl')]) and
207 not(ancestor::sect1[contains(@id,'ch-system-isl')]) and
208 not(ancestor::sect1[contains(@id,'ch-system-cloog')]) and
209 not(ancestor::sect1[contains(@id,'ch-system-cloog-ppl')]) and
210 not(ancestor::sect1[@id='ch-system-binutils'])">
211 <xsl:text># </xsl:text>
212 </xsl:if>
213 <xsl:choose>
214 <xsl:when test="$bomb-testsuite = 'n'">
215 <xsl:choose>
216 <!-- special case for (e)glibc -->
217 <xsl:when test="contains(string(), 'glibc-check-log')">
218 <xsl:value-of
219 select="substring-before(string(),'2&gt;&amp;1')"/>
220 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
221 </xsl:when>
222 <!-- special case for procps-ng -->
223 <xsl:when test="contains(string(), 'pushd')">
224 <xsl:text>{ </xsl:text>
225 <xsl:apply-templates/>
226 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
227 </xsl:when>
228 <xsl:when test="contains(string(), 'make -k')">
229 <xsl:apply-templates/>
230 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
231 </xsl:when>
232 <xsl:when test="contains(string(), 'make')">
233 <xsl:value-of select="substring-before(string(),'make')"/>
234 <xsl:text>make -k</xsl:text>
235 <xsl:value-of select="substring-after(string(),'make')"/>
236 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
237 </xsl:when>
238 <xsl:otherwise>
239 <xsl:apply-templates/>
240 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
241 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
242 </xsl:if>
243 <xsl:text>&#xA;</xsl:text>
244 </xsl:otherwise>
245 </xsl:choose>
246 </xsl:when>
247 <xsl:otherwise>
248 <!-- bomb-testsuite != 'n'-->
249 <xsl:choose>
250 <!-- special case for (e)glibc -->
251 <xsl:when test="contains(string(), 'glibc-check-log')">
252 <xsl:value-of
253 select="substring-before(string(),'2&gt;&amp;1')"/>
254 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
255 </xsl:when>
256 <!-- special case for gmp -->
257 <xsl:when test="contains(string(), 'tee gmp-check-log')">
258 <xsl:text>(</xsl:text>
259 <xsl:apply-templates/>
260 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 &amp;&amp; exit $PIPESTATUS)&#xA;</xsl:text>
261 </xsl:when>
262 <!-- special case for procps-ng -->
263 <xsl:when test="contains(string(), 'pushd')">
264 <xsl:text>{ </xsl:text>
265 <xsl:apply-templates/>
266 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
267 </xsl:when>
268 <xsl:when test="contains(string(), 'make -k')">
269 <xsl:apply-templates/>
270 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
271 </xsl:when>
272 <xsl:otherwise>
273 <xsl:apply-templates/>
274 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
275 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
276 </xsl:if>
277 <xsl:text>&#xA;</xsl:text>
278 </xsl:otherwise>
279 </xsl:choose>
280 </xsl:otherwise>
281 </xsl:choose>
282 </xsl:if><!-- avoid executing note before perl tests -->
283 </xsl:when>
284<!-- End of test instructions -->
285
286 <!-- Fixing toolchain test suites run XXX more to fix -->
287 <xsl:when test="contains(string(),'glibc-check-log')">
288 <xsl:choose>
289 <xsl:when test="$testsuite != '0'">
290 <xsl:value-of select="substring-before(string(),'2&gt;')"/>
291 <xsl:choose>
292 <xsl:when test="$bomb-testsuite = 'n'">
293 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
294 </xsl:when>
295 <xsl:otherwise>
296 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
297 <xsl:if test="contains(string(),' -k ')">
298 <xsl:text> || true</xsl:text>
299 </xsl:if>
300 <xsl:text>&#xA;</xsl:text>
301 </xsl:otherwise>
302 </xsl:choose>
303 </xsl:when>
304 </xsl:choose>
305 </xsl:when>
306 <xsl:when test="string() = 'make check' or
307 contains(string(), 'make -k check')">
308 <xsl:choose>
309 <xsl:when test="$testsuite != '0'">
310 <xsl:choose>
311 <xsl:when test="$bomb-testsuite = 'n'">
312 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
313 </xsl:when>
314 <xsl:otherwise>
315 <xsl:apply-templates/>
316 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
317 <xsl:if test="contains(string(),' -k ')">
318 <xsl:text> || true</xsl:text>
319 </xsl:if>
320 <xsl:text>&#xA;</xsl:text>
321 </xsl:otherwise>
322 </xsl:choose>
323 </xsl:when>
324 </xsl:choose>
325 </xsl:when>
326 <xsl:when test="contains(string(),'test_summary') or
327 contains(string(),'expect -c')">
328 <xsl:choose>
329 <xsl:when test="$testsuite != '0'">
330 <xsl:apply-templates/>
331 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
332 </xsl:when>
333 </xsl:choose>
334 </xsl:when>
335 <!-- Don't stop on strip run -->
336 <xsl:when test="contains(string(),'strip ')">
337 <xsl:apply-templates/>
338 <xsl:text> || true&#xA;</xsl:text>
339 </xsl:when>
340 <!-- Add -j1 to make install commands -->
341 <xsl:when test="contains(string(),'make ') and
342 contains(string(),'install')">
343 <xsl:value-of select="substring-before(string(),'make ')"/>
344 <xsl:text>make -j1 </xsl:text>
345 <xsl:value-of select="substring-after(string(),'make ')"/>
346 <xsl:text>&#xA;</xsl:text>
347 </xsl:when>
348 <!-- The rest of commands -->
349 <xsl:otherwise>
350 <xsl:apply-templates/>
351 <xsl:text>&#xA;</xsl:text>
352 </xsl:otherwise>
353 </xsl:choose>
354 </xsl:template>
355
356 <xsl:template match="replaceable">
357 <xsl:choose>
358 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
359 <xsl:value-of select="$timezone"/>
360 </xsl:when>
361 <xsl:when test="ancestor::sect1[@id='ch-system-eglibc']">
362 <xsl:value-of select="$timezone"/>
363 </xsl:when>
364 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
365 <xsl:value-of select="$page"/>
366 </xsl:when>
367 <xsl:when test="ancestor::sect1[@id='ch-cross-tools-flags']">
368 <xsl:choose>
369 <xsl:when test="contains(string(),'BUILD32')">
370 <xsl:choose>
371 <xsl:when test="$sparc = '1' or $sparc = '2'">
372 <xsl:text>-m32 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
373 </xsl:when>
374 <xsl:when test="$sparc = '3'">
375 <xsl:text>-m32 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
376 </xsl:when>
377 </xsl:choose>
378 </xsl:when>
379 <xsl:when test="contains(string(),'BUILD64')">
380 <xsl:choose>
381 <xsl:when test="$sparc = '1' or $sparc = '2'">
382 <xsl:text>-m64 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
383 </xsl:when>
384 <xsl:when test="$sparc = '3'">
385 <xsl:text>-m64 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
386 </xsl:when>
387 </xsl:choose>
388 </xsl:when>
389 <xsl:when test="contains(string(),'GCCTARGET')">
390 <xsl:choose>
391 <xsl:when test="$sparc = '1' or $sparc = '2'">
392 <xsl:text>-mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
393 </xsl:when>
394 <xsl:when test="$sparc = '3'">
395 <xsl:text>-mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
396 </xsl:when>
397 </xsl:choose>
398 </xsl:when>
399 </xsl:choose>
400 </xsl:when>
401 <xsl:when test="ancestor::sect1[@id='ch-final-preps-variables']">
402 <xsl:choose>
403 <xsl:when test="contains(string(),'target triplet')">
404 <xsl:value-of select="$x86"/>
405 </xsl:when>
406 <xsl:when test="contains(string(),'mips')">
407 <xsl:value-of select="$mips"/>
408 </xsl:when>
409 <xsl:when test="contains(string(),'BUILD32')">
410 <xsl:choose>
411 <xsl:when test="$sparc = '1' or $sparc = '2'">
412 <xsl:text>-m32 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
413 </xsl:when>
414 <xsl:when test="$sparc = '3'">
415 <xsl:text>-m32 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
416 </xsl:when>
417 </xsl:choose>
418 </xsl:when>
419 <xsl:when test="contains(string(),'BUILD64')">
420 <xsl:choose>
421 <xsl:when test="$sparc = '1' or $sparc = '2'">
422 <xsl:text>-m64 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
423 </xsl:when>
424 <xsl:when test="$sparc = '3'">
425 <xsl:text>-m64 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
426 </xsl:when>
427 </xsl:choose>
428 </xsl:when>
429 <xsl:when test="contains(string(),'GCCTARGET')">
430 <xsl:choose>
431 <xsl:when test="$sparc = '1' or $sparc = '2'">
432 <xsl:text>-mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
433 </xsl:when>
434 <xsl:when test="$sparc = '3'">
435 <xsl:text>-mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
436 </xsl:when>
437 </xsl:choose>
438 </xsl:when>
439 </xsl:choose>
440 </xsl:when>
441 <xsl:otherwise>
442 <xsl:text>**EDITME</xsl:text>
443 <xsl:apply-templates/>
444 <xsl:text>EDITME**</xsl:text>
445 </xsl:otherwise>
446 </xsl:choose>
447 </xsl:template>
448
449</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.