source: LFS/lfs.xsl@ 4afcedb

2.3 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 4afcedb was 4afcedb, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

LFS: Qick fix to handle current SVN book.

  • Property mode set to 100644
File size: 12.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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:exsl="http://exslt.org/common"
11 extension-element-prefixes="exsl"
12 version="1.0">
13
14<!-- XSLT stylesheet to create shell scripts from LFS books. -->
15
16 <!-- Run test suites?
17 0 = none
18 1 = only chapter06 Glibc, GCC and Binutils testsuites
19 2 = all chapter06 testsuites
20 3 = all chapter05 and chapter06 testsuites
21 -->
22 <xsl:param name="testsuite" select="1"/>
23
24 <!-- Bomb on test suites failures?
25 n = no, I want to build the full system and review the logs
26 y = yes, bomb at the first test suite failure to can review the build dir
27 -->
28 <xsl:param name="bomb-testsuite" select="n"/>
29
30 <!-- Install vim-lang package? -->
31 <xsl:param name="vim-lang" select="y"/>
32
33 <!-- Time zone -->
34 <xsl:param name="timezone" select="GMT"/>
35
36 <!-- Page size -->
37 <xsl:param name="page" select="letter"/>
38
39 <!-- Locale settings -->
40 <xsl:param name="lang" select="C"/>
41
42 <xsl:template match="/">
43 <xsl:apply-templates select="//sect1"/>
44 </xsl:template>
45
46 <xsl:template match="sect1">
47 <xsl:if test="(../@id='chapter-temporary-tools' or
48 ../@id='chapter-building-system' or
49 ../@id='chapter-bootscripts' or
50 ../@id='chapter-bootable') and
51 count(descendant::screen/userinput) &gt; 0 and
52 count(descendant::screen/userinput) &gt;
53 count(descendant::screen[@role='nodump'])">
54 <!-- The dirs names -->
55 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
56 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
57 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
58 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
59 <!-- The file names -->
60 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
61 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
62 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
63 <!-- The build order -->
64 <xsl:variable name="position" select="position()"/>
65 <xsl:variable name="order">
66 <xsl:choose>
67 <xsl:when test="string-length($position) = 1">
68 <xsl:text>00</xsl:text>
69 <xsl:value-of select="$position"/>
70 </xsl:when>
71 <xsl:when test="string-length($position) = 2">
72 <xsl:text>0</xsl:text>
73 <xsl:value-of select="$position"/>
74 </xsl:when>
75 <xsl:otherwise>
76 <xsl:value-of select="$position"/>
77 </xsl:otherwise>
78 </xsl:choose>
79 </xsl:variable>
80 <!-- Creating dirs and files -->
81 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
82 <xsl:choose>
83 <xsl:when test="@id='ch-system-creatingdirs' or
84 @id='ch-system-createfiles' or
85 @id='ch-system-strippingagain'">
86 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
87 </xsl:when>
88 <xsl:otherwise>
89 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
90 </xsl:otherwise>
91 </xsl:choose>
92 <xsl:if test="not(@id='ch-tools-stripping') and
93 not(@id='ch-system-strippingagain')">
94 <xsl:text>set -e&#xA;</xsl:text>
95 </xsl:if>
96 <xsl:text>&#xA;</xsl:text>
97 <xsl:if test="sect2[@role='installation']">
98 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
99 <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
100 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
101 </xsl:if>
102 </xsl:if>
103 <xsl:apply-templates select=".//screen"/>
104 <xsl:if test="$testsuite='3' and @id='ch-tools-glibc'">
105 <xsl:copy-of select="//userinput[@remap='locale-test']"/>
106 <xsl:text>&#xA;</xsl:text>
107 </xsl:if>
108 <xsl:if test="not(@id='ch-system-chroot') and
109 not(@id='ch-system-revisedchroot')">
110 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
111 </xsl:if>
112 <xsl:text>exit&#xA;</xsl:text>
113 </exsl:document>
114 </xsl:if>
115 </xsl:template>
116
117 <xsl:template match="screen">
118 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
119 <xsl:apply-templates select="userinput" mode="screen"/>
120 </xsl:if>
121 </xsl:template>
122
123 <xsl:template match="userinput" mode="screen">
124 <xsl:choose>
125 <!-- Estandarized package formats -->
126 <xsl:when test="contains(string(),'tar.gz')">
127 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
128 <xsl:text>tar.*</xsl:text>
129 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
130 <xsl:text>&#xA;</xsl:text>
131 </xsl:when>
132 <!-- Avoiding a race condition in a patch -->
133 <xsl:when test="contains(string(),'debian_fixes')">
134 <xsl:value-of select="substring-before(string(),'patch')"/>
135 <xsl:text>patch -Z</xsl:text>
136 <xsl:value-of select="substring-after(string(),'patch')"/>
137 <xsl:text>&#xA;</xsl:text>
138 </xsl:when>
139 <!-- Fix Udev reinstallation after a build failure -->
140 <xsl:when test="contains(string(),'firmware,udev')">
141 <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
142 <xsl:apply-templates/>
143 <xsl:text>&#xA;fi&#xA;</xsl:text>
144 </xsl:when>
145 <!-- Setting $LANG for /etc/profile -->
146 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
147 contains(string(),'export LANG=')">
148 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
149 <xsl:text>export LANG=</xsl:text>
150 <xsl:value-of select="$lang"/>
151 <xsl:value-of select="substring-after(string(),'modifiers>')"/>
152 <xsl:text>&#xA;</xsl:text>
153 </xsl:when>
154 <!-- Copying the kernel config file -->
155 <xsl:when test="string() = 'make mrproper'">
156 <xsl:text>make mrproper&#xA;</xsl:text>
157 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
158 </xsl:when>
159 <!-- The Bash, Coreutils, and Module-Init-Tools test suites are optional -->
160 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
161 ancestor::sect1[@id='ch-system-bash'] or
162 ancestor::sect1[@id='ch-system-module-init-tools'])
163 and @remap = 'test'">
164 <xsl:choose>
165 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
166 <xsl:otherwise>
167 <xsl:if test="not(contains(string(),'check')) and
168 not(contains(string(),'make tests'))">
169 <xsl:apply-templates/>
170 <xsl:text>&#xA;</xsl:text>
171 </xsl:if>
172 <!-- Coreutils and Module-Init-Tools -->
173 <xsl:if test="contains(string(),'check')">
174 <xsl:choose>
175 <xsl:when test="$bomb-testsuite = 'n'">
176 <xsl:value-of select="substring-before(string(),'check')"/>
177 <xsl:text>-k check</xsl:text>
178 <xsl:value-of select="substring-after(string(),'check')"/>
179 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
180 </xsl:when>
181 <xsl:otherwise>
182 <xsl:apply-templates/>
183 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
184 <xsl:if test="contains(string(),' -k ')">
185 <xsl:text> || true</xsl:text>
186 </xsl:if>
187 <xsl:text>&#xA;</xsl:text>
188 </xsl:otherwise>
189 </xsl:choose>
190 </xsl:if>
191 <!-- Bash -->
192 <xsl:if test="contains(string(),'make tests')">
193 <xsl:choose>
194 <xsl:when test="$bomb-testsuite = 'n'">
195 <xsl:value-of select="substring-before(string(),'tests')"/>
196 <xsl:text>-k tests</xsl:text>
197 <xsl:value-of select="substring-after(string(),'tests')"/>
198 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
199 </xsl:when>
200 <xsl:otherwise>
201 <xsl:apply-templates/>
202 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
203 <xsl:if test="contains(string(),' -k ')">
204 <xsl:text> || true</xsl:text>
205 </xsl:if>
206 <xsl:text>&#xA;</xsl:text>
207 </xsl:otherwise>
208 </xsl:choose>
209 </xsl:if>
210 </xsl:otherwise>
211 </xsl:choose>
212 </xsl:when>
213 <!-- Fixing toolchain test suites run -->
214 <xsl:when test="(string() = 'make check' or
215 string() = 'make -k check') and
216 (ancestor::sect1[@id='ch-system-gcc'] or
217 ancestor::sect1[@id='ch-system-glibc'] or
218 ancestor::sect1[@id='ch-system-binutils'] or
219 ancestor::sect1[@id='ch-tools-gcc-pass2'])">
220 <xsl:choose>
221 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
222 ancestor::chapter[@id='chapter-building-system']) or
223 $testsuite = '3'">
224 <xsl:choose>
225 <xsl:when test="$bomb-testsuite = 'n'">
226 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
227 </xsl:when>
228 <xsl:otherwise>
229 <xsl:apply-templates/>
230 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
231 <xsl:if test="contains(string(),' -k ')">
232 <xsl:text> || true</xsl:text>
233 </xsl:if>
234 <xsl:text>&#xA;</xsl:text>
235 </xsl:otherwise>
236 </xsl:choose>
237 </xsl:when>
238 </xsl:choose>
239 </xsl:when>
240 <xsl:when test="contains(string(),'glibc-check-log')">
241 <xsl:choose>
242 <xsl:when test="$testsuite != '0'">
243 <xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
244 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
245 </xsl:when>
246 </xsl:choose>
247 </xsl:when>
248 <xsl:when test="contains(string(),'test_summary') or
249 contains(string(),'expect -c')">
250 <xsl:choose>
251 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
252 ancestor::chapter[@id='chapter-building-system']) or
253 $testsuite = '3'">
254 <xsl:apply-templates/>
255 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
256 </xsl:when>
257 </xsl:choose>
258 </xsl:when>
259 <!-- The rest of testsuites -->
260 <xsl:when test="@remap = 'test'">
261 <xsl:choose>
262 <xsl:when test="$testsuite = '0'"/>
263 <xsl:when test="$testsuite = '1' and
264 not(ancestor::sect1[@id='ch-system-gcc']) and
265 not(ancestor::sect1[@id='ch-system-glibc']) and
266 not(ancestor::sect1[@id='ch-system-binutils'])"/>
267 <xsl:when test="$testsuite = '2' and
268 ancestor::chapter[@id='chapter-temporary-tools']"/>
269 <xsl:otherwise>
270 <xsl:choose>
271 <xsl:when test="$bomb-testsuite = 'n'">
272 <xsl:value-of select="substring-before(string(),'make')"/>
273 <xsl:text>make -k</xsl:text>
274 <xsl:value-of select="substring-after(string(),'make')"/>
275 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
276 </xsl:when>
277 <xsl:otherwise>
278 <xsl:apply-templates/>
279 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
280 <xsl:if test="contains(string(),' -k ')">
281 <xsl:text> || true</xsl:text>
282 </xsl:if>
283 <xsl:text>&#xA;</xsl:text>
284 </xsl:otherwise>
285 </xsl:choose>
286 </xsl:otherwise>
287 </xsl:choose>
288 </xsl:when>
289 <!-- Don't stop on strip run -->
290 <xsl:when test="contains(string(),'strip ')">
291 <xsl:apply-templates/>
292 <xsl:text> || true&#xA;</xsl:text>
293 </xsl:when>
294 <!-- The rest of commands -->
295 <xsl:otherwise>
296 <xsl:apply-templates/>
297 <xsl:text>&#xA;</xsl:text>
298 </xsl:otherwise>
299 </xsl:choose>
300 </xsl:template>
301
302 <xsl:template match="replaceable">
303 <xsl:choose>
304 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
305 <xsl:value-of select="$timezone"/>
306 </xsl:when>
307 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
308 <xsl:value-of select="$page"/>
309 </xsl:when>
310 <xsl:otherwise>
311 <xsl:text>**EDITME</xsl:text>
312 <xsl:apply-templates/>
313 <xsl:text>EDITME**</xsl:text>
314 </xsl:otherwise>
315 </xsl:choose>
316 </xsl:template>
317
318</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.