source: HLFS/hlfs.xsl@ 93346ee

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

bug fix

  • Property mode set to 100644
File size: 14.1 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'])">
103 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
104 <xsl:if test="@id='ch-system-uclibc'">
105 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
106 </xsl:if>
107
108 <!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
109 <xsl:if test="@id='ch-tools-embryo-toolchain' or
110 @id='ch-tools-cocoon-toolchain' or
111 @id='ch-system-butterfly-toolchain'">
112 <xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
113 <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
114 </xsl:if>
115 <xsl:if test="@id='ch-tools-cocoon-toolchain' or
116 @id='ch-system-butterfly-toolchain'">
117 <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
118 </xsl:if>
119 <!-- ONLY butterfly has a testsuite -->
120 <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
121 <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
122 </xsl:if>
123 <!-- END SVN toolchain format -->
124
125 <!-- 2.4-branch toolchain -->
126 <xsl:if test="@id='ch-tools-gcc-pass2' or @id='ch-system-gcc'">
127 <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
128 </xsl:if>
129 <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
130 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
131 </xsl:if>
132 <!-- END 2.4-branch toolchain -->
133
134<!-- temporary
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-->
139 </xsl:if>
140 <xsl:apply-templates select=".//para/userinput | .//screen"/>
141 <xsl:text>exit</xsl:text>
142 </exsl:document>
143 </xsl:if>
144 </xsl:template>
145
146 <xsl:template match="screen">
147 <xsl:if test="(@condition=$model or not(@condition)) and
148 child::* = userinput and not(@role = 'nodump')">
149 <xsl:apply-templates select="userinput" mode="screen"/>
150 </xsl:if>
151 </xsl:template>
152
153 <xsl:template match="para/userinput">
154 <xsl:if test="(contains(string(),'test') or
155 contains(string(),'check')) and
156 ($testsuite = '2' or $testsuite = '3')">
157 <xsl:choose>
158 <xsl:when test="$bomb-testsuite = 'n'">
159 <xsl:value-of select="substring-before(string(),'make')"/>
160 <xsl:text>make -k</xsl:text>
161 <xsl:value-of select="substring-after(string(),'make')"/>
162 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
163 </xsl:when>
164 <xsl:otherwise>
165 <xsl:apply-templates/>
166 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
167 <xsl:if test="contains(string(),' -k ')">
168 <xsl:text> || true</xsl:text>
169 </xsl:if>
170 <xsl:text>&#xA;</xsl:text>
171 </xsl:otherwise>
172 </xsl:choose>
173 </xsl:if>
174 </xsl:template>
175
176 <xsl:template match="userinput" mode="screen">
177 <xsl:choose>
178 <!-- Estandarized package formats -->
179 <xsl:when test="contains(string(),'tar.gz')">
180 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
181 <xsl:text>tar.*</xsl:text>
182 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
183 <xsl:text>&#xA;</xsl:text>
184 </xsl:when>
185 <!-- grsecurity kernel in the host? -->
186 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
187 contains(string(),'sysctl')
188 and $grsecurity_host ='n'"/>
189 <!-- We need to have /dev/console and /dev/null availables before
190 entering to the chroot -->
191 <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
192 contains(string(),'600 /dev/console')"/>
193 <!-- Fix MAKEDEV installation in 2.4-branch -->
194 <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
195 contains(string(),'bzcat MAKEDEV')">
196 <xsl:text>bzcat /sources/</xsl:text>
197 <xsl:value-of select="substring-after(string(),'bzcat ')"/>
198 <xsl:text>&#xA;</xsl:text>
199 </xsl:when>
200 <!-- Setting $LC_ALL and $LANG for /etc/profile -->
201 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
202 contains(string(),'export LANG=')">
203 <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
204 <xsl:text>export LC_ALL=</xsl:text>
205 <xsl:value-of select="$lc_all"/>
206 <xsl:text>&#xA;export LANG=</xsl:text>
207 <xsl:value-of select="$lang"/>
208 <xsl:text>&#xA;export INPUTRC</xsl:text>
209 <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
210 <xsl:text>&#xA;</xsl:text>
211 </xsl:when>
212 <!-- Fixing bootscripts installation -->
213
214<!-- temporary
215 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
216 string() = 'make install'">
217 <xsl:text>make install&#xA;</xsl:text>
218 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
219 </xsl:when>
220-->
221 <!-- Compile the keymap into the kernel has been dissabled -->
222 <xsl:when test="contains(string(),'defkeymap')"/>
223 <!-- Copying the kernel config file -->
224 <xsl:when test="string() = 'make mrproper'">
225 <xsl:text>make mrproper&#xA;</xsl:text>
226 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
227 </xsl:when>
228 <!-- No interactive commands are needed if the .config file is the proper one -->
229 <xsl:when test="string() = 'make menuconfig'"/>
230 <!-- For uClibc we need to cd to the Gettext package -->
231 <xsl:when test="contains(string(),'cd gettext-runtime/')">
232 <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
233 <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
234 <xsl:text>&#xA;</xsl:text>
235 </xsl:when>
236 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
237 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
238 ancestor::sect1[@id='ch-system-module-init-tools']) and
239 (contains(string(),'check') or
240 contains(string(),'distclean') or
241 contains(string(),'dummy'))">
242 <xsl:choose>
243 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
244 <xsl:otherwise>
245 <xsl:if test="not(contains(string(),'check'))">
246 <xsl:apply-templates/>
247 <xsl:text>&#xA;</xsl:text>
248 </xsl:if>
249 <xsl:if test="contains(string(),'check')">
250 <xsl:choose>
251 <xsl:when test="$bomb-testsuite = 'n'">
252 <xsl:value-of select="substring-before(string(),'check')"/>
253 <xsl:text>-k check</xsl:text>
254 <xsl:value-of select="substring-after(string(),'check')"/>
255 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
256 </xsl:when>
257 <xsl:otherwise>
258 <xsl:apply-templates/>
259 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
260 <xsl:if test="contains(string(),' -k ')">
261 <xsl:text> || true</xsl:text>
262 </xsl:if>
263 <xsl:text>&#xA;</xsl:text>
264 </xsl:otherwise>
265 </xsl:choose>
266 </xsl:if>
267 </xsl:otherwise>
268 </xsl:choose>
269 </xsl:when>
270 <!-- Fixing butterfly and 2.4-branch toolchain plus other packages test suites run -->
271 <xsl:when test="string() = 'make -k check'
272 or string() = 'make check'
273 or string() = 'make tests'">
274 <xsl:choose>
275 <xsl:when test="((ancestor::sect1[@id='ch-system-butterfly-toolchain']
276 or ancestor::sect1[@id='ch-system-gcc'] or
277 ancestor::sect1[@id='ch-system-binutils'])
278 and $testsuite != '0') or
279 $testsuite = '2' or $testsuite = '3'">
280 <xsl:choose>
281 <xsl:when test="$bomb-testsuite = 'n'">
282 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
283 </xsl:when>
284 <xsl:otherwise>
285 <xsl:apply-templates/>
286 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
287 <xsl:if test="contains(string(),' -k ')">
288 <xsl:text> || true</xsl:text>
289 </xsl:if>
290 <xsl:text>&#xA;</xsl:text>
291 </xsl:otherwise>
292 </xsl:choose>
293 </xsl:when>
294 </xsl:choose>
295 </xsl:when>
296 <!-- Fixing Glbc test suite -->
297 <xsl:when test="contains(string(),'glibc-check-log')">
298 <xsl:choose>
299 <xsl:when test="$testsuite != '0'">
300 <xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
301 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
302 </xsl:when>
303 </xsl:choose>
304 </xsl:when>
305 <!-- Fixing Butterfly sanity checks -->
306 <xsl:when test="contains(string(),'./fortify-test')
307 or contains(string(),'./ssp-test')">
308 <xsl:text>! </xsl:text>
309 <xsl:apply-templates/>
310 <xsl:text>&#xA;</xsl:text>
311 </xsl:when>
312 <!-- Don't stop on strip run -->
313 <xsl:when test="contains(string(),'strip ')">
314 <xsl:apply-templates/>
315 <xsl:text> || true&#xA;</xsl:text>
316 </xsl:when>
317 <!-- The rest of commands -->
318 <xsl:otherwise>
319 <xsl:apply-templates/>
320 <xsl:text>&#xA;</xsl:text>
321 </xsl:otherwise>
322 </xsl:choose>
323 </xsl:template>
324
325 <xsl:template match="literal">
326 <xsl:if test="@condition=$model or not(@condition)">
327 <xsl:apply-templates/>
328 </xsl:if>
329 </xsl:template>
330
331 <xsl:template match="replaceable">
332 <xsl:choose>
333 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
334 ancestor::sect1[@id='ch-system-uclibc']">
335 <xsl:value-of select="$timezone"/>
336 </xsl:when>
337 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
338 <xsl:value-of select="$page"/>
339 </xsl:when>
340 <xsl:otherwise>
341 <xsl:text>**EDITME</xsl:text>
342 <xsl:apply-templates/>
343 <xsl:text>EDITME**</xsl:text>
344 </xsl:otherwise>
345 </xsl:choose>
346 </xsl:template>
347
348</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.