source: CLFS/clfs.xsl@ 9575278

2.4 ablfs-more legacy trunk
Last change on this file since 9575278 was 3f83cb0, checked in by Pierre Labastie <pierre@…>, 10 years ago

For CLFS 3.0, variable setting is now in final-prep chapter.
Adapt CLFS for that

  • 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
140 ($testsuite = '2' or $testsuite = '3')">
[28f4756]141 <xsl:choose>
[401f81e]142 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]143 <xsl:value-of select="substring-before(string(),'make')"/>
144 <xsl:text>make -k</xsl:text>
145 <xsl:value-of select="substring-after(string(),'make')"/>
146 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
147 </xsl:when>
148 <xsl:otherwise>
149 <xsl:apply-templates/>
[a1f1969]150 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
151 <xsl:if test="contains(string(),' -k ')">
152 <xsl:text> || true</xsl:text>
153 </xsl:if>
154 <xsl:text>&#xA;</xsl:text>
[28f4756]155 </xsl:otherwise>
156 </xsl:choose>
[877cc6a]157 </xsl:if>
158 </xsl:template>
159
160 <xsl:template match="userinput" mode="screen">
161 <xsl:choose>
162 <!-- Estandarized package formats -->
163 <xsl:when test="contains(string(),'tar.gz')">
164 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
165 <xsl:text>tar.*</xsl:text>
166 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
167 <xsl:text>&#xA;</xsl:text>
168 </xsl:when>
169 <!-- Setting $LANG for /etc/profile -->
170 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
171 contains(string(),'export LANG=')">
172 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
173 <xsl:text>export LANG=</xsl:text>
174 <xsl:value-of select="$lang"/>
175 <xsl:value-of select="substring-after(string(),'charmap]')"/>
176 <xsl:text>&#xA;</xsl:text>
177 </xsl:when>
[f4caf9c]178 <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
179 <xsl:when test="contains(string(),'defkeymap')"/>
[877cc6a]180 <!-- Copying the kernel config file -->
181 <xsl:when test="string() = 'make mrproper'">
182 <xsl:text>make mrproper&#xA;</xsl:text>
183 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
184 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
185 </xsl:if>
186 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
187 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
188 </xsl:if>
189 </xsl:when>
190 <!-- No interactive commands are needed if the .config file is the proper one -->
191 <xsl:when test="contains(string(),'menuconfig')"/>
[c3b96a9]192<!-- test instructions -->
193 <xsl:when test="@remap = 'test'">
[a229600]194 <xsl:choose>
[ee2c45c]195 <!-- Avoid executing the note before perl tests while in 'chroot' -->
196 <xsl:when test="ancestor::note[@os='a00'] and $method='chroot'"/>
[c3b96a9]197 <xsl:when test="$testsuite = '0'"/>
[ee2c45c]198 <xsl:when test=
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'])"/>
[a229600]211 <xsl:otherwise>
[c3b96a9]212 <xsl:choose>
213 <xsl:when test="$bomb-testsuite = 'n'">
214 <xsl:choose>
[ee2c45c]215 <!-- special case for (e)glibc -->
216 <xsl:when test="contains(string(), 'glibc-check-log')">
[c3b96a9]217 <xsl:value-of
218 select="substring-before(string(),'2&gt;&amp;1')"/>
219 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
220 </xsl:when>
221 <!-- special case for procps-ng -->
222 <xsl:when test="contains(string(), 'pushd')">
223 <xsl:text>{ </xsl:text>
224 <xsl:apply-templates/>
225 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
226 </xsl:when>
227 <xsl:when test="contains(string(), 'make -k')">
228 <xsl:apply-templates/>
229 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
230 </xsl:when>
231 <xsl:when test="contains(string(), 'make')">
232 <xsl:value-of select="substring-before(string(),'make')"/>
233 <xsl:text>make -k</xsl:text>
234 <xsl:value-of select="substring-after(string(),'make')"/>
235 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
236 </xsl:when>
237 <xsl:otherwise>
238 <xsl:apply-templates/>
239 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
240 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
241 </xsl:if>
242 <xsl:text>&#xA;</xsl:text>
243 </xsl:otherwise>
244 </xsl:choose>
245 </xsl:when>
246 <xsl:otherwise>
247 <!-- bomb-testsuite != 'n'-->
248 <xsl:choose>
[ee2c45c]249 <!-- special case for (e)glibc -->
250 <xsl:when test="contains(string(), 'glibc-check-log')">
[c3b96a9]251 <xsl:value-of
252 select="substring-before(string(),'2&gt;&amp;1')"/>
253 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
254 </xsl:when>
255 <!-- special case for gmp -->
256 <xsl:when test="contains(string(), 'tee gmp-check-log')">
257 <xsl:text>(</xsl:text>
258 <xsl:apply-templates/>
259 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 &amp;&amp; exit $PIPESTATUS)&#xA;</xsl:text>
260 </xsl:when>
261 <!-- special case for procps-ng -->
262 <xsl:when test="contains(string(), 'pushd')">
263 <xsl:text>{ </xsl:text>
264 <xsl:apply-templates/>
265 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
266 </xsl:when>
267 <xsl:when test="contains(string(), 'make -k')">
268 <xsl:apply-templates/>
269 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
270 </xsl:when>
271 <xsl:otherwise>
272 <xsl:apply-templates/>
273 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
274 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
275 </xsl:if>
276 <xsl:text>&#xA;</xsl:text>
277 </xsl:otherwise>
278 </xsl:choose>
279 </xsl:otherwise>
280 </xsl:choose>
[a229600]281 </xsl:otherwise>
282 </xsl:choose>
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.