source: CLFS/clfs.xsl@ c3b96a9

2.4 ablfs-more legacy new_features trunk
Last change on this file since c3b96a9 was c3b96a9, checked in by Pierre Labastie <pierre@…>, 11 years ago

Update clfs script generation to new book layout (remap="test" attribute).
Thanks to William Harrington for the patch

  • Property mode set to 100644
File size: 16.9 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 <xsl:template match="/">
50 <xsl:apply-templates select="//sect1"/>
51 </xsl:template>
52
53 <xsl:template match="sect1">
54 <xsl:choose>
55 <xsl:when test="../@id='chapter-partitioning' or
56 ../@id='chapter-getting-materials' or
57 ../@id='chapter-final-preps'"/>
58 <xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
59 <xsl:when test="../@id='chapter-boot' and $method='chroot'"/>
60 <xsl:when test="../@id='chapter-chroot' and $method='boot'"/>
61 <xsl:otherwise>
62 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
63 count(descendant::screen/userinput) &gt;
64 count(descendant::screen[@role='nodump'])">
65 <!-- The dirs names -->
66 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
67 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
68 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
69 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
70 <!-- The file names -->
71 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
72 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
73 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
74 <!-- The build order -->
75 <xsl:variable name="position" select="position()"/>
76 <xsl:variable name="order">
77 <xsl:choose>
78 <xsl:when test="string-length($position) = 1">
79 <xsl:text>00</xsl:text>
80 <xsl:value-of select="$position"/>
81 </xsl:when>
82 <xsl:when test="string-length($position) = 2">
83 <xsl:text>0</xsl:text>
84 <xsl:value-of select="$position"/>
85 </xsl:when>
86 <xsl:otherwise>
87 <xsl:value-of select="$position"/>
88 </xsl:otherwise>
89 </xsl:choose>
90 </xsl:variable>
91 <!-- Creating dirs and files -->
92 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
93 <xsl:choose>
94 <xsl:when test="@id='ch-chroot-changingowner' or
95 @id='ch-chroot-creatingdirs' or
96 @id='ch-chroot-createfiles' or
97 @id='ch-system-stripping'">
98 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
99 </xsl:when>
100 <xsl:otherwise>
101 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
102 </xsl:otherwise>
103 </xsl:choose>
104 <xsl:if test="not(@id='ch-system-stripping')">
105 <xsl:text>set -e</xsl:text>
106 </xsl:if>
107 <xsl:text>&#xA;</xsl:text>
108 <xsl:if test="sect2[@role='installation'] and
109 not(@id='ch-system-multiarch-wrapper')">
110 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
111 <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
112 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
113 </xsl:if>
114 </xsl:if>
115 <xsl:apply-templates select=".//para/userinput | .//screen"/>
116 <xsl:if test="not(@id='ch-chroot-chroot')">
117 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
118 </xsl:if>
119 <xsl:text>exit</xsl:text>
120 </exsl:document>
121 </xsl:if>
122 </xsl:otherwise>
123 </xsl:choose>
124 </xsl:template>
125
126 <xsl:template match="screen">
127 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
128 <xsl:apply-templates select="userinput" mode="screen"/>
129 </xsl:if>
130 </xsl:template>
131
132 <xsl:template match="para/userinput">
133 <xsl:if test="(contains(string(),'test') or
134 contains(string(),'check')) and
135 ($testsuite = '2' or $testsuite = '3')">
136 <xsl:choose>
137 <xsl:when test="$bomb-testsuite = 'n'">
138 <xsl:value-of select="substring-before(string(),'make')"/>
139 <xsl:text>make -k</xsl:text>
140 <xsl:value-of select="substring-after(string(),'make')"/>
141 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
142 </xsl:when>
143 <xsl:otherwise>
144 <xsl:apply-templates/>
145 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
146 <xsl:if test="contains(string(),' -k ')">
147 <xsl:text> || true</xsl:text>
148 </xsl:if>
149 <xsl:text>&#xA;</xsl:text>
150 </xsl:otherwise>
151 </xsl:choose>
152 </xsl:if>
153 </xsl:template>
154
155 <xsl:template match="userinput" mode="screen">
156 <xsl:choose>
157 <!-- Estandarized package formats -->
158 <xsl:when test="contains(string(),'tar.gz')">
159 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
160 <xsl:text>tar.*</xsl:text>
161 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
162 <xsl:text>&#xA;</xsl:text>
163 </xsl:when>
164 <!-- Setting $LANG for /etc/profile -->
165 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
166 contains(string(),'export LANG=')">
167 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
168 <xsl:text>export LANG=</xsl:text>
169 <xsl:value-of select="$lang"/>
170 <xsl:value-of select="substring-after(string(),'charmap]')"/>
171 <xsl:text>&#xA;</xsl:text>
172 </xsl:when>
173 <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
174 <xsl:when test="contains(string(),'defkeymap')"/>
175 <!-- Copying the kernel config file -->
176 <xsl:when test="string() = 'make mrproper'">
177 <xsl:text>make mrproper&#xA;</xsl:text>
178 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
179 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
180 </xsl:if>
181 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
182 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
183 </xsl:if>
184 </xsl:when>
185 <!-- No interactive commands are needed if the .config file is the proper one -->
186 <xsl:when test="contains(string(),'menuconfig')"/>
187<!-- test instructions -->
188 <xsl:when test="@remap = 'test'">
189 <xsl:choose>
190 <xsl:when test="$testsuite = '0'"/>
191 <xsl:when test="$testsuite = '1' and
192 not(ancestor::sect1[@id='ch-system-gcc']) and
193 not(ancestor::sect1[@id='ch-system-eglibc']) and
194 not(ancestor::sect1[@id='ch-system-gmp']) and
195 not(ancestor::sect1[@id='ch-system-mpfr']) and
196 not(ancestor::sect1[@id='ch-system-mpc']) and
197 not(ancestor::sect1[@id='ch-system-ppl']) and
198 not(ancestor::sect1[@id='ch-system-isl']) and
199 not(ancestor::sect1[@id='ch-system-cloog']) and
200 not(ancestor::sect1[@id='ch-system-cloog-ppl']) and
201 not(ancestor::sect1[@id='ch-system-binutils'])"/>
202 <xsl:when test="$testsuite = '2' and
203 ancestor::chapter[@id='ch-temp-system']"/>
204 <xsl:otherwise>
205 <xsl:choose>
206 <xsl:when test="$bomb-testsuite = 'n'">
207 <xsl:choose>
208 <!-- special case for eglibc -->
209 <xsl:when test="contains(string(), 'eglibc-check-log')">
210 <xsl:value-of
211 select="substring-before(string(),'2&gt;&amp;1')"/>
212 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
213 </xsl:when>
214 <!-- special case for procps-ng -->
215 <xsl:when test="contains(string(), 'pushd')">
216 <xsl:text>{ </xsl:text>
217 <xsl:apply-templates/>
218 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
219 </xsl:when>
220 <xsl:when test="contains(string(), 'make -k')">
221 <xsl:apply-templates/>
222 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
223 </xsl:when>
224 <xsl:when test="contains(string(), 'make')">
225 <xsl:value-of select="substring-before(string(),'make')"/>
226 <xsl:text>make -k</xsl:text>
227 <xsl:value-of select="substring-after(string(),'make')"/>
228 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
229 </xsl:when>
230 <xsl:otherwise>
231 <xsl:apply-templates/>
232 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
233 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
234 </xsl:if>
235 <xsl:text>&#xA;</xsl:text>
236 </xsl:otherwise>
237 </xsl:choose>
238 </xsl:when>
239 <xsl:otherwise>
240 <!-- bomb-testsuite != 'n'-->
241 <xsl:choose>
242 <!-- special case for eglibc -->
243 <xsl:when test="contains(string(), 'eglibc-check-log')">
244 <xsl:value-of
245 select="substring-before(string(),'2&gt;&amp;1')"/>
246 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
247 </xsl:when>
248 <!-- special case for gmp -->
249 <xsl:when test="contains(string(), 'tee gmp-check-log')">
250 <xsl:text>(</xsl:text>
251 <xsl:apply-templates/>
252 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 &amp;&amp; exit $PIPESTATUS)&#xA;</xsl:text>
253 </xsl:when>
254 <!-- special case for procps-ng -->
255 <xsl:when test="contains(string(), 'pushd')">
256 <xsl:text>{ </xsl:text>
257 <xsl:apply-templates/>
258 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
259 </xsl:when>
260 <xsl:when test="contains(string(), 'make -k')">
261 <xsl:apply-templates/>
262 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
263 </xsl:when>
264 <xsl:otherwise>
265 <xsl:apply-templates/>
266 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
267 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
268 </xsl:if>
269 <xsl:text>&#xA;</xsl:text>
270 </xsl:otherwise>
271 </xsl:choose>
272 </xsl:otherwise>
273 </xsl:choose>
274 </xsl:otherwise>
275 </xsl:choose>
276 </xsl:when>
277<!-- End of test instructions -->
278
279 <!-- Fixing toolchain test suites run XXX more to fix -->
280 <xsl:when test="contains(string(),'eglibc-check-log')">
281 <xsl:choose>
282 <xsl:when test="$testsuite != '0'">
283 <xsl:value-of select="substring-before(string(),'2&gt;')"/>
284 <xsl:choose>
285 <xsl:when test="$bomb-testsuite = 'n'">
286 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
287 </xsl:when>
288 <xsl:otherwise>
289 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
290 <xsl:if test="contains(string(),' -k ')">
291 <xsl:text> || true</xsl:text>
292 </xsl:if>
293 <xsl:text>&#xA;</xsl:text>
294 </xsl:otherwise>
295 </xsl:choose>
296 </xsl:when>
297 </xsl:choose>
298 </xsl:when>
299 <xsl:when test="string() = 'make check' or
300 contains(string(), 'make -k check')">
301 <xsl:choose>
302 <xsl:when test="$testsuite != '0'">
303 <xsl:choose>
304 <xsl:when test="$bomb-testsuite = 'n'">
305 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
306 </xsl:when>
307 <xsl:otherwise>
308 <xsl:apply-templates/>
309 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
310 <xsl:if test="contains(string(),' -k ')">
311 <xsl:text> || true</xsl:text>
312 </xsl:if>
313 <xsl:text>&#xA;</xsl:text>
314 </xsl:otherwise>
315 </xsl:choose>
316 </xsl:when>
317 </xsl:choose>
318 </xsl:when>
319 <xsl:when test="contains(string(),'test_summary') or
320 contains(string(),'expect -c')">
321 <xsl:choose>
322 <xsl:when test="$testsuite != '0'">
323 <xsl:apply-templates/>
324 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
325 </xsl:when>
326 </xsl:choose>
327 </xsl:when>
328 <!-- Don't stop on strip run -->
329 <xsl:when test="contains(string(),'strip ')">
330 <xsl:apply-templates/>
331 <xsl:text> || true&#xA;</xsl:text>
332 </xsl:when>
333 <!-- Add -j1 to make install commands -->
334 <xsl:when test="contains(string(),'make ') and
335 contains(string(),'install')">
336 <xsl:value-of select="substring-before(string(),'make ')"/>
337 <xsl:text>make -j1 </xsl:text>
338 <xsl:value-of select="substring-after(string(),'make ')"/>
339 <xsl:text>&#xA;</xsl:text>
340 </xsl:when>
341 <!-- Avoid calling hostname in chroot -->
342 <xsl:when test="ancestor::note[@os='a00']">
343 <xsl:if test="$method='boot'">
344 <xsl:apply-templates/>
345 <xsl:text>&#xA;</xsl:text>
346 </xsl:if>
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:otherwise>
402 <xsl:text>**EDITME</xsl:text>
403 <xsl:apply-templates/>
404 <xsl:text>EDITME**</xsl:text>
405 </xsl:otherwise>
406 </xsl:choose>
407 </xsl:template>
408
409</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.