source: CLFS/clfs.xsl@ 8b0d3b3

experimental
Last change on this file since 8b0d3b3 was 4aede02, checked in by George Boudreau <georgeb@…>, 18 years ago

Correct small typo in clfs.xsl

  • Property mode set to 100644
File size: 11.8 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 CLFS books. -->
15
16 <!-- Build method used -->
17 <xsl:param name="method" select="chroot"/>
18
19 <!-- Compile the keymap into the kernel? -->
20 <xsl:param name="keymap" select="none"/>
21
22 <!-- Run test suites?
23 0 = none
24 1 = only Glibc, GCC and Binutils testsuites
25 2 = all testsuites
26 3 = alias to 2
27 -->
28 <xsl:param name="testsuite" select="1"/>
29
30 <!-- Bomb on test suites failures?
31 n = no, I want to build the full system and review the logs
32 y = yes, bomb at the first test suite failure to can review the build dir
33 -->
34 <xsl:param name="bomb-testsuite" select="n"/>
35
36 <!-- Install vim-lang package? -->
37 <xsl:param name="vim-lang" select="y"/>
38
39 <!-- Time zone -->
40 <xsl:param name="timezone" select="GMT"/>
41
42 <!-- Page size -->
43 <xsl:param name="page" select="letter"/>
44
45 <!-- Locale settings -->
46 <xsl:param name="lang" select="C"/>
47
48 <xsl:template match="/">
49 <xsl:apply-templates select="//sect1"/>
50 </xsl:template>
51
52 <xsl:template match="sect1">
53 <xsl:choose>
54 <xsl:when test="../@id='chapter-partitioning' or
55 ../@id='chapter-getting-materials' or
56 ../@id='chapter-final-preps'"/>
57 <xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
58 <xsl:when test="../@id='chapter-boot' and $method='chroot'"/>
59 <xsl:when test="../@id='chapter-chroot' and $method='boot'"/>
60 <xsl:otherwise>
61 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
62 count(descendant::screen/userinput) &gt;
63 count(descendant::screen[@role='nodump'])">
64 <!-- The dirs names -->
65 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
66 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
67 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
68 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
69 <!-- The file names -->
70 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
71 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
72 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
73 <!-- The build order -->
74 <xsl:variable name="position" select="position()"/>
75 <xsl:variable name="order">
76 <xsl:choose>
77 <xsl:when test="string-length($position) = 1">
78 <xsl:text>00</xsl:text>
79 <xsl:value-of select="$position"/>
80 </xsl:when>
81 <xsl:when test="string-length($position) = 2">
82 <xsl:text>0</xsl:text>
83 <xsl:value-of select="$position"/>
84 </xsl:when>
85 <xsl:otherwise>
86 <xsl:value-of select="$position"/>
87 </xsl:otherwise>
88 </xsl:choose>
89 </xsl:variable>
90 <!-- Creating dirs and files -->
91 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
92 <xsl:choose>
93 <xsl:when test="../@id='chapter-chroot'">
94 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
95 </xsl:when>
96 <xsl:when test="@id='ch-system-stripping'">
97 <xsl:text>#!/bin/sh&#xA;</xsl:text>
98 </xsl:when>
99 <xsl:otherwise>
100 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
101 </xsl:otherwise>
102 </xsl:choose>
103 <xsl:if test="sect2[@role='installation']">
104 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
105 <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
106 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
107 </xsl:if>
108 </xsl:if>
109 <xsl:apply-templates select=".//para/userinput | .//screen"/>
110 <xsl:text>exit</xsl:text>
111 </exsl:document>
112 </xsl:if>
113 </xsl:otherwise>
114 </xsl:choose>
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="para/userinput">
124 <xsl:if test="(contains(string(),'test') or
125 contains(string(),'check')) and
126 ($testsuite = '2' or $testsuite = '3')">
127 <xsl:choose>
128 <xsl:when test="$bomb-testsuite = 'n'">
129 <xsl:value-of select="substring-before(string(),'make')"/>
130 <xsl:text>make -k</xsl:text>
131 <xsl:value-of select="substring-after(string(),'make')"/>
132 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
133 </xsl:when>
134 <xsl:otherwise>
135 <xsl:apply-templates/>
136 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
137 <xsl:if test="contains(string(),' -k ')">
138 <xsl:text> || true</xsl:text>
139 </xsl:if>
140 <xsl:text>&#xA;</xsl:text>
141 </xsl:otherwise>
142 </xsl:choose>
143 </xsl:if>
144 </xsl:template>
145
146 <xsl:template match="userinput" mode="screen">
147 <xsl:choose>
148 <!-- Estandarized package formats -->
149 <xsl:when test="contains(string(),'tar.gz')">
150 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
151 <xsl:text>tar.*</xsl:text>
152 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
153 <xsl:text>&#xA;</xsl:text>
154 </xsl:when>
155 <!-- Avoiding a race condition in a patch -->
156 <xsl:when test="contains(string(),'debian_fixes')">
157 <xsl:value-of select="substring-before(string(),'patch')"/>
158 <xsl:text>patch -Z</xsl:text>
159 <xsl:value-of select="substring-after(string(),'patch')"/>
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? -->
172 <xsl:when test="contains(string(),'defkeymap') and
173 $keymap = 'none'"/>
174 <!-- Copying the kernel config file -->
175 <xsl:when test="string() = 'make mrproper'">
176 <xsl:text>make mrproper&#xA;</xsl:text>
177 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
178 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
179 </xsl:if>
180 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
181 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
182 </xsl:if>
183 </xsl:when>
184 <!-- No interactive commands are needed if the .config file is the proper one -->
185 <xsl:when test="contains(string(),'menuconfig')"/>
186 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
187 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
188 ancestor::sect1[@id='ch-system-module-init-tools']) and
189 (contains(string(),'check') or
190 contains(string(),'dummy'))">
191 <xsl:choose>
192 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
193 <xsl:otherwise>
194 <xsl:if test="not(contains(string(),'check'))">
195 <xsl:apply-templates/>
196 <xsl:text>&#xA;</xsl:text>
197 </xsl:if>
198 <xsl:if test="contains(string(),'check')">
199 <xsl:choose>
200 <xsl:when test="$bomb-testsuite = 'n'">
201 <xsl:value-of select="substring-before(string(),'check')"/>
202 <xsl:text>-k check</xsl:text>
203 <xsl:value-of select="substring-after(string(),'check')"/>
204 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
205 </xsl:when>
206 <xsl:otherwise>
207 <xsl:apply-templates/>
208 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
209 <xsl:if test="contains(string(),' -k ')">
210 <xsl:text> || true</xsl:text>
211 </xsl:if>
212 <xsl:text>&#xA;</xsl:text>
213 </xsl:otherwise>
214 </xsl:choose>
215 </xsl:if>
216 </xsl:otherwise>
217 </xsl:choose>
218 </xsl:when>
219 <!-- Fixing toolchain test suites run -->
220 <xsl:when test="string() = 'make check' or
221 string() = 'make -k check'">
222 <xsl:choose>
223 <xsl:when test="$testsuite != '0'">
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(),'&gt;g')"/>
244 <xsl:choose>
245 <xsl:when test="$bomb-testsuite = 'n'">
246 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
247 </xsl:when>
248 <xsl:otherwise>
249 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
250 <xsl:if test="contains(string(),' -k ')">
251 <xsl:text> || true</xsl:text>
252 </xsl:if>
253 <xsl:text>&#xA;</xsl:text>
254 </xsl:otherwise>
255 </xsl:choose>
256 </xsl:when>
257 </xsl:choose>
258 </xsl:when>
259 <xsl:when test="contains(string(),'test_summary') or
260 contains(string(),'expect -c')">
261 <xsl:choose>
262 <xsl:when test="$testsuite != '0'">
263 <xsl:apply-templates/>
264 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
265 </xsl:when>
266 </xsl:choose>
267 </xsl:when>
268 <!-- Don't stop on strip run -->
269 <xsl:when test="contains(string(),'strip ')">
270 <xsl:apply-templates/>
271 <xsl:text> || true&#xA;</xsl:text>
272 </xsl:when>
273 <!-- The rest of commands -->
274 <xsl:otherwise>
275 <xsl:apply-templates/>
276 <xsl:text>&#xA;</xsl:text>
277 </xsl:otherwise>
278 </xsl:choose>
279 </xsl:template>
280
281 <xsl:template match="replaceable">
282 <xsl:choose>
283 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
284 <xsl:value-of select="$timezone"/>
285 </xsl:when>
286 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
287 <xsl:value-of select="$page"/>
288 </xsl:when>
289 <xsl:when test="ancestor::sect1[@id='ch-boot-kernel'] or
290 ancestor::sect1[@id='ch-bootable-kernel']">
291 <xsl:value-of select="$keymap"/>
292 </xsl:when>
293 <xsl:otherwise>
294 <xsl:text>**EDITME</xsl:text>
295 <xsl:apply-templates/>
296 <xsl:text>EDITME**</xsl:text>
297 </xsl:otherwise>
298 </xsl:choose>
299 </xsl:template>
300
301</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.