source: CLFS/clfs.xsl@ 7d6d6f7

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 7d6d6f7 was 1330ebc, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Fixed chroot environment to be more closed to the one expected by the books.
Need be full tested.

  • Property mode set to 100644
File size: 11.3 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 <!-- Run test suites?
20 0 = none
21 1 = only Glibc, GCC and Binutils testsuites
22 2 = all testsuites
23 3 = alias to 2
24 -->
25 <xsl:param name="testsuite" select="1"/>
26
27 <!-- Bomb on test suites failures?
28 n = no, I want to build the full system and review the logs
29 y = yes, bomb at the first test suite failure to can review the build dir
30 -->
31 <xsl:param name="bomb-testsuite" select="n"/>
32
33 <!-- Install vim-lang package? -->
34 <xsl:param name="vim-lang" select="y"/>
35
36 <!-- Time zone -->
37 <xsl:param name="timezone" select="GMT"/>
38
39 <!-- Page size -->
40 <xsl:param name="page" select="letter"/>
41
42 <!-- Locale settings -->
43 <xsl:param name="lang" select="C"/>
44
45 <xsl:template match="/">
46 <xsl:apply-templates select="//sect1"/>
47 </xsl:template>
48
49 <xsl:template match="sect1">
50 <xsl:choose>
51 <xsl:when test="../@id='chapter-partitioning' or
52 ../@id='chapter-getting-materials' or
53 ../@id='chapter-final-preps'"/>
54 <xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
55 <xsl:when test="../@id='chapter-boot' and $method='chroot'"/>
56 <xsl:when test="../@id='chapter-chroot' and $method='boot'"/>
57 <xsl:otherwise>
58 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
59 count(descendant::screen/userinput) &gt;
60 count(descendant::screen[@role='nodump'])">
61 <!-- The dirs names -->
62 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
63 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
64 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
65 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
66 <!-- The file names -->
67 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
68 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
69 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
70 <!-- The build order -->
71 <xsl:variable name="position" select="position()"/>
72 <xsl:variable name="order">
73 <xsl:choose>
74 <xsl:when test="string-length($position) = 1">
75 <xsl:text>00</xsl:text>
76 <xsl:value-of select="$position"/>
77 </xsl:when>
78 <xsl:when test="string-length($position) = 2">
79 <xsl:text>0</xsl:text>
80 <xsl:value-of select="$position"/>
81 </xsl:when>
82 <xsl:otherwise>
83 <xsl:value-of select="$position"/>
84 </xsl:otherwise>
85 </xsl:choose>
86 </xsl:variable>
87 <!-- Creating dirs and files -->
88 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
89 <xsl:choose>
90 <xsl:when test="@id='ch-chroot-changingowner' or
91 @id='ch-chroot-creatingdirs' or
92 @id='ch-chroot-createfiles'">
93 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
94 </xsl:when>
95 <xsl:otherwise>
96 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
97 </xsl:otherwise>
98 </xsl:choose>
99 <xsl:if test="not(@id='ch-system-stripping')">
100 <xsl:text>set -e</xsl:text>
101 </xsl:if>
102 <xsl:text>&#xA;</xsl:text>
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 <!-- Setting $LANG for /etc/profile -->
156 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
157 contains(string(),'export LANG=')">
158 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
159 <xsl:text>export LANG=</xsl:text>
160 <xsl:value-of select="$lang"/>
161 <xsl:value-of select="substring-after(string(),'charmap]')"/>
162 <xsl:text>&#xA;</xsl:text>
163 </xsl:when>
164 <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
165 <xsl:when test="contains(string(),'defkeymap')"/>
166 <!-- Copying the kernel config file -->
167 <xsl:when test="string() = 'make mrproper'">
168 <xsl:text>make mrproper&#xA;</xsl:text>
169 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
170 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
171 </xsl:if>
172 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
173 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
174 </xsl:if>
175 </xsl:when>
176 <!-- No interactive commands are needed if the .config file is the proper one -->
177 <xsl:when test="contains(string(),'menuconfig')"/>
178 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
179 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
180 ancestor::sect1[@id='ch-system-module-init-tools']) and
181 (contains(string(),'check') or
182 contains(string(),'dummy'))">
183 <xsl:choose>
184 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
185 <xsl:otherwise>
186 <xsl:if test="not(contains(string(),'check'))">
187 <xsl:apply-templates/>
188 <xsl:text>&#xA;</xsl:text>
189 </xsl:if>
190 <xsl:if test="contains(string(),'check')">
191 <xsl:choose>
192 <xsl:when test="$bomb-testsuite = 'n'">
193 <xsl:value-of select="substring-before(string(),'check')"/>
194 <xsl:text>-k check</xsl:text>
195 <xsl:value-of select="substring-after(string(),'check')"/>
196 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
197 </xsl:when>
198 <xsl:otherwise>
199 <xsl:apply-templates/>
200 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
201 <xsl:if test="contains(string(),' -k ')">
202 <xsl:text> || true</xsl:text>
203 </xsl:if>
204 <xsl:text>&#xA;</xsl:text>
205 </xsl:otherwise>
206 </xsl:choose>
207 </xsl:if>
208 </xsl:otherwise>
209 </xsl:choose>
210 </xsl:when>
211 <!-- Fixing toolchain test suites run -->
212 <xsl:when test="string() = 'make check' or
213 string() = 'make -k check'">
214 <xsl:choose>
215 <xsl:when test="$testsuite != '0'">
216 <xsl:choose>
217 <xsl:when test="$bomb-testsuite = 'n'">
218 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
219 </xsl:when>
220 <xsl:otherwise>
221 <xsl:apply-templates/>
222 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
223 <xsl:if test="contains(string(),' -k ')">
224 <xsl:text> || true</xsl:text>
225 </xsl:if>
226 <xsl:text>&#xA;</xsl:text>
227 </xsl:otherwise>
228 </xsl:choose>
229 </xsl:when>
230 </xsl:choose>
231 </xsl:when>
232 <xsl:when test="contains(string(),'glibc-check-log')">
233 <xsl:choose>
234 <xsl:when test="$testsuite != '0'">
235 <xsl:value-of select="substring-before(string(),'&gt;g')"/>
236 <xsl:choose>
237 <xsl:when test="$bomb-testsuite = 'n'">
238 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
239 </xsl:when>
240 <xsl:otherwise>
241 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
242 <xsl:if test="contains(string(),' -k ')">
243 <xsl:text> || true</xsl:text>
244 </xsl:if>
245 <xsl:text>&#xA;</xsl:text>
246 </xsl:otherwise>
247 </xsl:choose>
248 </xsl:when>
249 </xsl:choose>
250 </xsl:when>
251 <xsl:when test="contains(string(),'test_summary') or
252 contains(string(),'expect -c')">
253 <xsl:choose>
254 <xsl:when test="$testsuite != '0'">
255 <xsl:apply-templates/>
256 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
257 </xsl:when>
258 </xsl:choose>
259 </xsl:when>
260 <!-- Don't stop on strip run -->
261 <xsl:when test="contains(string(),'strip ')">
262 <xsl:apply-templates/>
263 <xsl:text> || true&#xA;</xsl:text>
264 </xsl:when>
265 <!-- The rest of commands -->
266 <xsl:otherwise>
267 <xsl:apply-templates/>
268 <xsl:text>&#xA;</xsl:text>
269 </xsl:otherwise>
270 </xsl:choose>
271 </xsl:template>
272
273 <xsl:template match="replaceable">
274 <xsl:choose>
275 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
276 <xsl:value-of select="$timezone"/>
277 </xsl:when>
278 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
279 <xsl:value-of select="$page"/>
280 </xsl:when>
281 <xsl:otherwise>
282 <xsl:text>**EDITME</xsl:text>
283 <xsl:apply-templates/>
284 <xsl:text>EDITME**</xsl:text>
285 </xsl:otherwise>
286 </xsl:choose>
287 </xsl:template>
288
289</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.