source: CLFS/clfs.xsl@ a690d42

ablfs-more legacy trunk
Last change on this file since a690d42 was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

  • Property mode set to 100644
File size: 18.2 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<xsl:stylesheet
8 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9 xmlns:exsl="http://exslt.org/common"
10 extension-element-prefixes="exsl"
11 version="1.0">
12
13<!-- XSLT stylesheet to create shell scripts from CLFS books. -->
14
15 <!-- Build method used -->
16 <xsl:param name="method" select="chroot"/>
17
18 <!-- Run test suites?
19 0 = none
20 1 = only Glibc, GCC and Binutils testsuites
21 2 = all testsuites
22 3 = alias to 2
23 -->
24 <xsl:param name="testsuite" select="1"/>
25
26 <!-- Bomb on test suites failures?
27 n = no, I want to build the full system and review the logs
28 y = yes, bomb at the first test suite failure to can review the build dir
29 -->
30 <xsl:param name="bomb-testsuite" select="n"/>
31
32 <!-- Time zone -->
33 <xsl:param name="timezone" select="GMT"/>
34
35 <!-- Page size -->
36 <xsl:param name="page" select="letter"/>
37
38 <!-- Locale settings -->
39 <xsl:param name="lang" select="C"/>
40
41 <!-- Sparc64 processor type -->
42 <xsl:param name="sparc" select="none"/>
43
44 <!-- x86 32 bit target triplet -->
45 <xsl:param name="x86" select="i686-pc-linux-gnu"/>
46
47 <!-- mips target triplet -->
48 <xsl:param name="mips" select="mips-unknown-linux-gnu"/>
49
50 <xsl:template match="/">
51 <xsl:apply-templates select="//sect1"/>
52 </xsl:template>
53
54 <xsl:template match="sect1">
55 <xsl:choose>
56 <xsl:when test="../@id='chapter-partitioning' or
57 ../@id='chapter-getting-materials'"/>
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>
112 <xsl:apply-templates select=".//para/userinput | .//screen"/>
113 <xsl:if test="not(@id='ch-chroot-chroot')">
114 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
115 </xsl:if>
116 <xsl:text>exit</xsl:text>
117 </exsl:document>
118 </xsl:if>
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:template>
122
123 <xsl:template match="screen">
124 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
125 <xsl:apply-templates select="userinput" mode="screen"/>
126 </xsl:if>
127 </xsl:template>
128
129 <xsl:template match="para/userinput">
130 <xsl:if test="(contains(string(),'test') or
131 contains(string(),'check')) and
132 not($testsuite = '2' or $testsuite = '3')">
133 <xsl:text># </xsl:text>
134 </xsl:if>
135 <xsl:choose>
136 <xsl:when test="$bomb-testsuite = 'n'">
137 <xsl:value-of select="substring-before(string(),'make')"/>
138 <xsl:text>make -k</xsl:text>
139 <xsl:value-of select="substring-after(string(),'make')"/>
140 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
141 </xsl:when>
142 <xsl:otherwise>
143 <xsl:apply-templates/>
144 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
145 <xsl:if test="contains(string(),' -k ')">
146 <xsl:text> || true</xsl:text>
147 </xsl:if>
148 <xsl:text>&#xA;</xsl:text>
149 </xsl:otherwise>
150 </xsl:choose>
151 </xsl:template>
152
153 <xsl:template match="userinput" mode="screen">
154 <xsl:choose>
155 <!-- Estandarized package formats -->
156 <xsl:when test="contains(string(),'tar.gz')">
157 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
158 <xsl:text>tar.*</xsl:text>
159 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
160 <xsl:text>&#xA;</xsl:text>
161 </xsl:when>
162 <!-- Setting $LANG for /etc/profile -->
163 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
164 contains(string(),'export LANG=')">
165 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
166 <xsl:text>export LANG=</xsl:text>
167 <xsl:value-of select="$lang"/>
168 <xsl:value-of select="substring-after(string(),'charmap]')"/>
169 <xsl:text>&#xA;</xsl:text>
170 </xsl:when>
171 <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
172 <xsl:when test="contains(string(),'defkeymap')"/>
173 <!-- Copying the kernel config file -->
174 <xsl:when test="string() = 'make mrproper'">
175 <xsl:text>make mrproper&#xA;</xsl:text>
176 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
177 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
178 </xsl:if>
179 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
180 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
181 </xsl:if>
182 </xsl:when>
183 <!-- No interactive commands are needed if the .config file is the proper one -->
184 <xsl:when test="contains(string(),'menuconfig')"/>
185<!-- test instructions -->
186 <xsl:when test="@remap = 'test'">
187 <xsl:if test="not(ancestor::note[@os='a00'] and $method='chroot')">
188 <!-- Avoid executing the note before perl tests while in 'chroot' -->
189 <xsl:if test="
190 $testsuite = '0' or
191 $testsuite = '1' and
192 not(ancestor::sect1[@id='ch-system-gcc']) and
193 not(ancestor::sect1[contains(@id,'ch-system-eglibc')]) and
194 not(ancestor::sect1[contains(@id,'ch-system-glibc')]) and
195 not(ancestor::sect1[contains(@id,'ch-system-gmp')]) and
196 not(ancestor::sect1[contains(@id,'ch-system-mpfr')]) and
197 not(ancestor::sect1[contains(@id,'ch-system-mpc')]) and
198 not(ancestor::sect1[contains(@id,'ch-system-ppl')]) and
199 not(ancestor::sect1[contains(@id,'ch-system-isl')]) and
200 not(ancestor::sect1[contains(@id,'ch-system-cloog')]) and
201 not(ancestor::sect1[contains(@id,'ch-system-cloog-ppl')]) and
202 not(ancestor::sect1[@id='ch-system-binutils'])">
203 <xsl:text># </xsl:text>
204 </xsl:if>
205 <xsl:choose>
206 <xsl:when test="$bomb-testsuite = 'n'">
207 <xsl:choose>
208 <!-- special case for (e)glibc -->
209 <xsl:when test="contains(string(), 'glibc-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 (e)glibc -->
243 <xsl:when test="contains(string(), 'glibc-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:if><!-- avoid executing note before perl tests -->
275 </xsl:when>
276<!-- End of test instructions -->
277
278 <!-- Fixing toolchain test suites run XXX more to fix -->
279 <xsl:when test="contains(string(),'glibc-check-log')">
280 <xsl:choose>
281 <xsl:when test="$testsuite != '0'">
282 <xsl:value-of select="substring-before(string(),'2&gt;')"/>
283 <xsl:choose>
284 <xsl:when test="$bomb-testsuite = 'n'">
285 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
286 </xsl:when>
287 <xsl:otherwise>
288 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
289 <xsl:if test="contains(string(),' -k ')">
290 <xsl:text> || true</xsl:text>
291 </xsl:if>
292 <xsl:text>&#xA;</xsl:text>
293 </xsl:otherwise>
294 </xsl:choose>
295 </xsl:when>
296 </xsl:choose>
297 </xsl:when>
298 <xsl:when test="string() = 'make check' or
299 contains(string(), 'make -k check')">
300 <xsl:choose>
301 <xsl:when test="$testsuite != '0'">
302 <xsl:choose>
303 <xsl:when test="$bomb-testsuite = 'n'">
304 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
305 </xsl:when>
306 <xsl:otherwise>
307 <xsl:apply-templates/>
308 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
309 <xsl:if test="contains(string(),' -k ')">
310 <xsl:text> || true</xsl:text>
311 </xsl:if>
312 <xsl:text>&#xA;</xsl:text>
313 </xsl:otherwise>
314 </xsl:choose>
315 </xsl:when>
316 </xsl:choose>
317 </xsl:when>
318 <xsl:when test="contains(string(),'test_summary') or
319 contains(string(),'expect -c')">
320 <xsl:choose>
321 <xsl:when test="$testsuite != '0'">
322 <xsl:apply-templates/>
323 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
324 </xsl:when>
325 </xsl:choose>
326 </xsl:when>
327 <!-- Don't stop on strip run -->
328 <xsl:when test="contains(string(),'strip ')">
329 <xsl:apply-templates/>
330 <xsl:text> || true&#xA;</xsl:text>
331 </xsl:when>
332 <!-- Add -j1 to make install commands -->
333 <xsl:when test="contains(string(),'make ') and
334 contains(string(),'install')">
335 <xsl:value-of select="substring-before(string(),'make ')"/>
336 <xsl:text>make -j1 </xsl:text>
337 <xsl:value-of select="substring-after(string(),'make ')"/>
338 <xsl:text>&#xA;</xsl:text>
339 </xsl:when>
340 <!-- The rest of commands -->
341 <xsl:otherwise>
342 <xsl:apply-templates/>
343 <xsl:text>&#xA;</xsl:text>
344 </xsl:otherwise>
345 </xsl:choose>
346 </xsl:template>
347
348 <xsl:template match="replaceable">
349 <xsl:choose>
350 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
351 <xsl:value-of select="$timezone"/>
352 </xsl:when>
353 <xsl:when test="ancestor::sect1[@id='ch-system-eglibc']">
354 <xsl:value-of select="$timezone"/>
355 </xsl:when>
356 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
357 <xsl:value-of select="$page"/>
358 </xsl:when>
359 <xsl:when test="ancestor::sect1[@id='ch-cross-tools-flags']">
360 <xsl:choose>
361 <xsl:when test="contains(string(),'BUILD32')">
362 <xsl:choose>
363 <xsl:when test="$sparc = '1' or $sparc = '2'">
364 <xsl:text>-m32 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
365 </xsl:when>
366 <xsl:when test="$sparc = '3'">
367 <xsl:text>-m32 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
368 </xsl:when>
369 </xsl:choose>
370 </xsl:when>
371 <xsl:when test="contains(string(),'BUILD64')">
372 <xsl:choose>
373 <xsl:when test="$sparc = '1' or $sparc = '2'">
374 <xsl:text>-m64 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
375 </xsl:when>
376 <xsl:when test="$sparc = '3'">
377 <xsl:text>-m64 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
378 </xsl:when>
379 </xsl:choose>
380 </xsl:when>
381 <xsl:when test="contains(string(),'GCCTARGET')">
382 <xsl:choose>
383 <xsl:when test="$sparc = '1' or $sparc = '2'">
384 <xsl:text>-mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
385 </xsl:when>
386 <xsl:when test="$sparc = '3'">
387 <xsl:text>-mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
388 </xsl:when>
389 </xsl:choose>
390 </xsl:when>
391 </xsl:choose>
392 </xsl:when>
393 <xsl:when test="ancestor::sect1[@id='ch-final-preps-variables']">
394 <xsl:choose>
395 <xsl:when test="contains(string(),'target triplet')">
396 <xsl:value-of select="$x86"/>
397 </xsl:when>
398 <xsl:when test="contains(string(),'mips')">
399 <xsl:value-of select="$mips"/>
400 </xsl:when>
401 <xsl:when test="contains(string(),'BUILD32')">
402 <xsl:choose>
403 <xsl:when test="$sparc = '1' or $sparc = '2'">
404 <xsl:text>-m32 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
405 </xsl:when>
406 <xsl:when test="$sparc = '3'">
407 <xsl:text>-m32 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
408 </xsl:when>
409 </xsl:choose>
410 </xsl:when>
411 <xsl:when test="contains(string(),'BUILD64')">
412 <xsl:choose>
413 <xsl:when test="$sparc = '1' or $sparc = '2'">
414 <xsl:text>-m64 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
415 </xsl:when>
416 <xsl:when test="$sparc = '3'">
417 <xsl:text>-m64 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
418 </xsl:when>
419 </xsl:choose>
420 </xsl:when>
421 <xsl:when test="contains(string(),'GCCTARGET')">
422 <xsl:choose>
423 <xsl:when test="$sparc = '1' or $sparc = '2'">
424 <xsl:text>-mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
425 </xsl:when>
426 <xsl:when test="$sparc = '3'">
427 <xsl:text>-mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
428 </xsl:when>
429 </xsl:choose>
430 </xsl:when>
431 </xsl:choose>
432 </xsl:when>
433 <xsl:otherwise>
434 <xsl:text>**EDITME</xsl:text>
435 <xsl:apply-templates/>
436 <xsl:text>EDITME**</xsl:text>
437 </xsl:otherwise>
438 </xsl:choose>
439 </xsl:template>
440
441</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.