source: CLFS/clfs.xsl@ c8d5f11

ablfs-more legacy trunk
Last change on this file since c8d5f11 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
RevLine 
[877cc6a]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
[269d81c]9<xsl:stylesheet
10 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
[877cc6a]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
[28f4756]24 3 = alias to 2
25 -->
[877cc6a]26 <xsl:param name="testsuite" select="1"/>
27
[28f4756]28 <!-- Bomb on test suites failures?
[401f81e]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
[28f4756]31 -->
[401f81e]32 <xsl:param name="bomb-testsuite" select="n"/>
[28f4756]33
[269d81c]34 <!-- Install vim-lang package? OBSOLETE should always be 'n'-->
35 <xsl:param name="vim-lang" select="n"/>
[877cc6a]36
37 <!-- Time zone -->
[a229600]38 <xsl:param name="timezone" select="GMT"/>
[877cc6a]39
40 <!-- Page size -->
41 <xsl:param name="page" select="letter"/>
42
43 <!-- Locale settings -->
[a229600]44 <xsl:param name="lang" select="C"/>
[877cc6a]45
[650acce]46 <!-- Sparc64 processor type -->
[c93f2b0]47 <xsl:param name="sparc" select="none"/>
[650acce]48
[3f83cb0]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
[877cc6a]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
[3f83cb0]62 ../@id='chapter-getting-materials'"/>
[877cc6a]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">
[1330ebc]98 <xsl:choose>
99 <xsl:when test="@id='ch-chroot-changingowner' or
100 @id='ch-chroot-creatingdirs' or
[7d6fe10]101 @id='ch-chroot-createfiles' or
102 @id='ch-system-stripping'">
[1330ebc]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>
[5f4982d]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>
[58b186c]113 <xsl:if test="sect2[@role='installation'] and
114 not(@id='ch-system-multiarch-wrapper')">
[877cc6a]115 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
[401f81e]116 <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
[877cc6a]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"/>
[68713c9]121 <xsl:if test="not(@id='ch-chroot-chroot')">
122 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
123 </xsl:if>
[877cc6a]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
[489bdc2]140 not($testsuite = '2' or $testsuite = '3')">
141 <xsl:text># </xsl:text>
[877cc6a]142 </xsl:if>
[489bdc2]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>
[877cc6a]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>
[f4caf9c]179 <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
180 <xsl:when test="contains(string(),'defkeymap')"/>
[877cc6a]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')"/>
[c3b96a9]193<!-- test instructions -->
[489bdc2]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 -->
[a229600]283 </xsl:when>
[c3b96a9]284<!-- End of test instructions -->
285
[608fbe1]286 <!-- Fixing toolchain test suites run XXX more to fix -->
[ee2c45c]287 <xsl:when test="contains(string(),'glibc-check-log')">
[877cc6a]288 <xsl:choose>
289 <xsl:when test="$testsuite != '0'">
[269d81c]290 <xsl:value-of select="substring-before(string(),'2&gt;')"/>
[28f4756]291 <xsl:choose>
[401f81e]292 <xsl:when test="$bomb-testsuite = 'n'">
[269d81c]293 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[28f4756]294 </xsl:when>
295 <xsl:otherwise>
[269d81c]296 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
[a1f1969]297 <xsl:if test="contains(string(),' -k ')">
298 <xsl:text> || true</xsl:text>
299 </xsl:if>
300 <xsl:text>&#xA;</xsl:text>
[28f4756]301 </xsl:otherwise>
302 </xsl:choose>
[877cc6a]303 </xsl:when>
304 </xsl:choose>
305 </xsl:when>
[269d81c]306 <xsl:when test="string() = 'make check' or
307 contains(string(), 'make -k check')">
[877cc6a]308 <xsl:choose>
309 <xsl:when test="$testsuite != '0'">
[28f4756]310 <xsl:choose>
[401f81e]311 <xsl:when test="$bomb-testsuite = 'n'">
[269d81c]312 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[28f4756]313 </xsl:when>
314 <xsl:otherwise>
[269d81c]315 <xsl:apply-templates/>
316 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
[a1f1969]317 <xsl:if test="contains(string(),' -k ')">
318 <xsl:text> || true</xsl:text>
319 </xsl:if>
320 <xsl:text>&#xA;</xsl:text>
[28f4756]321 </xsl:otherwise>
322 </xsl:choose>
[877cc6a]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/>
[28f4756]331 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
[877cc6a]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>
[433a5d4]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>
[877cc6a]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>
[608fbe1]361 <xsl:when test="ancestor::sect1[@id='ch-system-eglibc']">
362 <xsl:value-of select="$timezone"/>
363 </xsl:when>
[877cc6a]364 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
365 <xsl:value-of select="$page"/>
366 </xsl:when>
[650acce]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'">
[3f83cb0]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'">
[650acce]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>
[877cc6a]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.