source: HLFS/hlfs.xsl@ 1a39790

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 1a39790 was 1a39790, checked in by George Boudreau <georgeb@…>, 18 years ago

Corrected typo in chapter name

  • Property mode set to 100644
File size: 13.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 HLFS books. -->
15
16 <!-- What libc implentation must be used? -->
17 <xsl:param name="model" select="glibc"/>
18
19 <!-- Is the host kernel using grsecurity? -->
20 <xsl:param name="grsecurity_host" select="n"/>
21
22 <!-- Run test suites?
23 0 = none
24 1 = only chapter06 Glibc, GCC and Binutils testsuites
25 2 = all chapter06 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 <!-- 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 <xsl:param name="lc_all" select="C"/>
45
46 <xsl:template match="/">
47 <xsl:apply-templates select="//sect1"/>
48 </xsl:template>
49
50 <xsl:template match="sect1">
51 <xsl:if test="(../@id='chapter-temporary-tools' or
52 ../@id='chapter-building-system' or
53 ../@id='chapter-bootable') and
54 ((@condition=$model or not(@condition)) and
55 count(descendant::screen/userinput) &gt; 0 and
56 count(descendant::screen/userinput) &gt;
57 count(descendant::screen[@role='nodump']))">
58 <!-- The dirs names -->
59 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
60 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
61 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
62 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
63 <!-- The file names -->
64 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
65 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
66 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
67 <!-- The build order -->
68 <xsl:variable name="position" select="position()"/>
69 <xsl:variable name="order">
70 <xsl:choose>
71 <xsl:when test="string-length($position) = 1">
72 <xsl:text>00</xsl:text>
73 <xsl:value-of select="$position"/>
74 </xsl:when>
75 <xsl:when test="string-length($position) = 2">
76 <xsl:text>0</xsl:text>
77 <xsl:value-of select="$position"/>
78 </xsl:when>
79 <xsl:otherwise>
80 <xsl:value-of select="$position"/>
81 </xsl:otherwise>
82 </xsl:choose>
83 </xsl:variable>
84 <!-- Creating dirs and files -->
85 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
86 <xsl:choose>
87 <xsl:when test="@id='ch-system-creatingdirs' or
88 @id='ch-system-createfiles' or
89 @id='ch-system-changingowner' or
90 @id='ch-system-strippingagain'">
91 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
92 </xsl:when>
93 <xsl:otherwise>
94 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
95 </xsl:otherwise>
96 </xsl:choose>
97 <xsl:if test="not(@id='ch-tools-stripping') and
98 not(@id='ch-system-strippingagain')">
99 <xsl:text>set -e&#xA;</xsl:text>
100 </xsl:if>
101 <xsl:text>&#xA;</xsl:text>
102 <xsl:if test="(sect2[@role='installation'] and
103 not(@id='bootable-kernel'))">
104 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
105 <xsl:if test="@id='ch-system-uclibc'">
106 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
107 </xsl:if>
108
109 <!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
110 <xsl:if test="@id='ch-tools-embryo-toolchain' or
111 @id='ch-tools-cocoon-toolchain' or
112 @id='ch-system-butterfly-toolchain'">
113 <xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
114 <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
115 </xsl:if>
116 <xsl:if test="@id='ch-tools-cocoon-toolchain' or
117 @id='ch-system-butterfly-toolchain'">
118 <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
119 </xsl:if>
120 <!-- ONLY butterfly has a testsuite -->
121 <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
122 <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
123 </xsl:if>
124 <!-- END SVN toolchain format -->
125
126 <!-- 2.4-branch toolchain -->
127 <xsl:if test="@id='ch-tools-gcc-pass2' or @id='ch-system-gcc'">
128 <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
129 </xsl:if>
130 <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
131 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
132 </xsl:if>
133 <!-- END 2.4-branch toolchain -->
134
135 <xsl:if test="@id='bootable-bootscripts'">
136 <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; &#xA;</xsl:text>
137 </xsl:if>
138 </xsl:if>
139 <xsl:apply-templates select=".//para/userinput | .//screen"/>
140 <xsl:text>exit</xsl:text>
141 </exsl:document>
142 </xsl:if>
143 </xsl:template>
144
145 <xsl:template match="screen">
146 <xsl:if test="(@condition=$model or not(@condition)) and
147 child::* = userinput and not(@role = 'nodump')">
148 <xsl:apply-templates select="userinput" mode="screen"/>
149 </xsl:if>
150 </xsl:template>
151
152 <xsl:template match="para/userinput">
153 <xsl:if test="(contains(string(),'test') or
154 contains(string(),'check')) and
155 ($testsuite = '2' or $testsuite = '3')">
156 <xsl:choose>
157 <xsl:when test="$bomb-testsuite = 'n'">
158 <xsl:value-of select="substring-before(string(),'make')"/>
159 <xsl:text>make -k</xsl:text>
160 <xsl:value-of select="substring-after(string(),'make')"/>
161 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
162 </xsl:when>
163 <xsl:otherwise>
164 <xsl:apply-templates/>
165 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
166 <xsl:if test="contains(string(),' -k ')">
167 <xsl:text> || true</xsl:text>
168 </xsl:if>
169 <xsl:text>&#xA;</xsl:text>
170 </xsl:otherwise>
171 </xsl:choose>
172 </xsl:if>
173 </xsl:template>
174
175 <xsl:template match="userinput" mode="screen">
176 <xsl:choose>
177 <!-- Estandarized package formats -->
178 <xsl:when test="contains(string(),'tar.gz')">
179 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
180 <xsl:text>tar.*</xsl:text>
181 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
182 <xsl:text>&#xA;</xsl:text>
183 </xsl:when>
184 <!-- grsecurity kernel in the host? -->
185 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
186 contains(string(),'sysctl')
187 and $grsecurity_host ='n'"/>
188 <!-- We need to have /dev/console and /dev/null availables before
189 entering to the chroot -->
190 <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
191 contains(string(),'600 /dev/console')"/>
192 <!-- Fix MAKEDEV installation in 2.4-branch -->
193 <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
194 contains(string(),'bzcat MAKEDEV')">
195 <xsl:text>bzcat /sources/</xsl:text>
196 <xsl:value-of select="substring-after(string(),'bzcat ')"/>
197 <xsl:text>&#xA;</xsl:text>
198 </xsl:when>
199 <!-- Setting $LC_ALL and $LANG for /etc/profile -->
200 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
201 contains(string(),'export LANG=')">
202 <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
203 <xsl:text>export LC_ALL=</xsl:text>
204 <xsl:value-of select="$lc_all"/>
205 <xsl:text>&#xA;export LANG=</xsl:text>
206 <xsl:value-of select="$lang"/>
207 <xsl:text>&#xA;export INPUTRC</xsl:text>
208 <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
209 <xsl:text>&#xA;</xsl:text>
210 </xsl:when>
211 <!-- Fixing bootscripts installation -->
212 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
213 string() = 'make install'">
214 <xsl:text>make install&#xA;</xsl:text>
215 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
216 </xsl:when>
217 <!-- Compile the keymap into the kernel has been dissabled -->
218 <xsl:when test="contains(string(),'defkeymap')"/>
219 <!-- Copying the kernel config file -->
220 <xsl:when test="string() = 'make mrproper'">
221 <xsl:text>make mrproper&#xA;</xsl:text>
222 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
223 </xsl:when>
224 <!-- No interactive commands are needed if the .config file is the proper one -->
225 <xsl:when test="string() = 'make menuconfig'"/>
226 <!-- For uClibc we need to cd to the Gettext package -->
227 <xsl:when test="contains(string(),'cd gettext-runtime/')">
228 <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
229 <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
230 <xsl:text>&#xA;</xsl:text>
231 </xsl:when>
232 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
233 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
234 ancestor::sect1[@id='ch-system-module-init-tools']) and
235 (contains(string(),'check') or
236 contains(string(),'distclean') or
237 contains(string(),'dummy'))">
238 <xsl:choose>
239 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
240 <xsl:otherwise>
241 <xsl:if test="not(contains(string(),'check'))">
242 <xsl:apply-templates/>
243 <xsl:text>&#xA;</xsl:text>
244 </xsl:if>
245 <xsl:if test="contains(string(),'check')">
246 <xsl:choose>
247 <xsl:when test="$bomb-testsuite = 'n'">
248 <xsl:value-of select="substring-before(string(),'check')"/>
249 <xsl:text>-k check</xsl:text>
250 <xsl:value-of select="substring-after(string(),'check')"/>
251 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
252 </xsl:when>
253 <xsl:otherwise>
254 <xsl:apply-templates/>
255 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
256 <xsl:if test="contains(string(),' -k ')">
257 <xsl:text> || true</xsl:text>
258 </xsl:if>
259 <xsl:text>&#xA;</xsl:text>
260 </xsl:otherwise>
261 </xsl:choose>
262 </xsl:if>
263 </xsl:otherwise>
264 </xsl:choose>
265 </xsl:when>
266 <!-- Fixing butterfly and 2.4-branch toolchain plus other packages test suites run -->
267 <xsl:when test="string() = 'make -k check'
268 or string() = 'make check'
269 or string() = 'make tests'">
270 <xsl:choose>
271 <xsl:when test="((ancestor::sect1[@id='ch-system-butterfly-toolchain']
272 or ancestor::sect1[@id='ch-system-gcc'] or
273 ancestor::sect1[@id='ch-system-binutils'])
274 and $testsuite != '0') or
275 $testsuite = '2' or $testsuite = '3'">
276 <xsl:choose>
277 <xsl:when test="$bomb-testsuite = 'n'">
278 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
279 </xsl:when>
280 <xsl:otherwise>
281 <xsl:apply-templates/>
282 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
283 <xsl:if test="contains(string(),' -k ')">
284 <xsl:text> || true</xsl:text>
285 </xsl:if>
286 <xsl:text>&#xA;</xsl:text>
287 </xsl:otherwise>
288 </xsl:choose>
289 </xsl:when>
290 </xsl:choose>
291 </xsl:when>
292 <!-- Fixing Glbc test suite -->
293 <xsl:when test="contains(string(),'glibc-check-log')">
294 <xsl:choose>
295 <xsl:when test="$testsuite != '0'">
296 <xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
297 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
298 </xsl:when>
299 </xsl:choose>
300 </xsl:when>
301 <!-- Don't stop on strip run -->
302 <xsl:when test="contains(string(),'strip ')">
303 <xsl:apply-templates/>
304 <xsl:text> || true&#xA;</xsl:text>
305 </xsl:when>
306 <!-- The rest of commands -->
307 <xsl:otherwise>
308 <xsl:apply-templates/>
309 <xsl:text>&#xA;</xsl:text>
310 </xsl:otherwise>
311 </xsl:choose>
312 </xsl:template>
313
314 <xsl:template match="literal">
315 <xsl:if test="@condition=$model or not(@condition)">
316 <xsl:apply-templates/>
317 </xsl:if>
318 </xsl:template>
319
320 <xsl:template match="replaceable">
321 <xsl:choose>
322 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
323 ancestor::sect1[@id='ch-system-uclibc']">
324 <xsl:value-of select="$timezone"/>
325 </xsl:when>
326 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
327 <xsl:value-of select="$page"/>
328 </xsl:when>
329 <xsl:otherwise>
330 <xsl:text>**EDITME</xsl:text>
331 <xsl:apply-templates/>
332 <xsl:text>EDITME**</xsl:text>
333 </xsl:otherwise>
334 </xsl:choose>
335 </xsl:template>
336
337</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.