source: HLFS/hlfs.xsl@ e900430

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

HLFS: Added support for additional build features.

  • Property mode set to 100644
File size: 14.4 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 <!-- What kernel serie must be used? -->
20 <xsl:param name="kernel" select="2.6"/>
21
22 <!-- Is the host kernel using grsecurity? -->
23 <xsl:param name="grsecurity_host" select="n"/>
24
25 <!-- Run test suites?
26 0 = none
27 1 = only chapter06 Glibc, GCC and Binutils testsuites
28 2 = all chapter06 testsuites
29 3 = alias to 2
30 -->
31 <xsl:param name="testsuite" select="1"/>
32
33 <!-- Bomb on test suites failures?
34 n = no, I want to build the full system and review the logs
35 y = yes, bomb at the first test suite failure to can review the build dir
36 -->
37 <xsl:param name="bomb-testsuite" select="n"/>
38
39 <!-- Additional features -->
40 <xsl:param name="features">,ssp,aslr,pax,hardened_tmp,warnings,misc,blowfish,</xsl:param>
41
42 <!-- Time zone -->
43 <xsl:param name="timezone" select="GMT"/>
44
45 <!-- Page size -->
46 <xsl:param name="page" select="letter"/>
47
48 <!-- Locale settings -->
49 <xsl:param name="lang" select="C"/>
50
51 <xsl:template match="/">
52 <xsl:apply-templates select="//sect1"/>
53 </xsl:template>
54
55 <xsl:template match="sect1">
56 <xsl:if test="(../@id='chapter-temporary-tools' or
57 ../@id='chapter-building-system' or
58 ../@id='chapter-bootable') and
59 (count(descendant::screen/userinput) &gt; 0 and
60 count(descendant::screen/userinput) &gt;
61 count(descendant::screen[@role='nodump'])) and
62 ((@condition=$model or not(@condition)) and
63 (@vendor=$kernel or not(@vendor)))">
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='ch-system-creatingdirs' or
94 @id='ch-system-createfiles' or
95 @id='ch-system-changingowner' or
96 @id='ch-system-strippingagain'">
97 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
98 </xsl:when>
99 <xsl:otherwise>
100 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
101 </xsl:otherwise>
102 </xsl:choose>
103 <xsl:if test="not(@id='ch-tools-stripping') and
104 not(@id='ch-system-strippingagain')">
105 <xsl:text>set -e&#xA;</xsl:text>
106 </xsl:if>
107 <xsl:text>&#xA;</xsl:text>
108 <xsl:if test="(sect2[@role='installation'])">
109 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
110 <xsl:if test="@id='ch-system-uclibc'">
111 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
112 </xsl:if>
113
114 <!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
115 <xsl:if test="@id='ch-tools-embryo-toolchain' or
116 @id='ch-tools-cocoon-toolchain' or
117 @id='ch-system-butterfly-toolchain'">
118 <xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
119 <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
120 </xsl:if>
121 <xsl:if test="@id='ch-tools-cocoon-toolchain' or
122 @id='ch-system-butterfly-toolchain'">
123 <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
124 </xsl:if>
125 <!-- ONLY butterfly has a testsuite -->
126 <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
127 <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
128 </xsl:if>
129 <!-- END SVN toolchain format -->
130
131 <!-- 2.4-branch toolchain -->
132 <xsl:if test="@id='ch-tools-gcc-pass2' or @id='ch-system-gcc'">
133 <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
134 </xsl:if>
135 <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
136 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
137 </xsl:if>
138 <!-- END 2.4-branch toolchain -->
139
140<!-- temporary
141 <xsl:if test="@id='bootable-bootscripts'">
142 <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; &#xA;</xsl:text>
143 </xsl:if>
144-->
145 </xsl:if>
146 <xsl:apply-templates select=".//para/userinput | .//screen"/>
147 <xsl:text>exit</xsl:text>
148 </exsl:document>
149 </xsl:if>
150 </xsl:template>
151
152 <xsl:template match="screen">
153 <xsl:if test="(@condition=$model or not(@condition)) and
154 (@vendor=$kernel or not(@vendor)) and
155 child::* = userinput and (not(@role) or
156 (@role and contains($features,concat(',',@role,','))))">
157 <xsl:apply-templates select="userinput" mode="screen"/>
158 </xsl:if>
159 </xsl:template>
160
161 <xsl:template match="para/userinput">
162 <xsl:if test="(contains(string(),'test') or
163 contains(string(),'check')) and
164 ($testsuite = '2' or $testsuite = '3')">
165 <xsl:choose>
166 <xsl:when test="$bomb-testsuite = 'n'">
167 <xsl:value-of select="substring-before(string(),'make')"/>
168 <xsl:text>make -k</xsl:text>
169 <xsl:value-of select="substring-after(string(),'make')"/>
170 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
171 </xsl:when>
172 <xsl:otherwise>
173 <xsl:apply-templates/>
174 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
175 <xsl:if test="contains(string(),' -k ')">
176 <xsl:text> || true</xsl:text>
177 </xsl:if>
178 <xsl:text>&#xA;</xsl:text>
179 </xsl:otherwise>
180 </xsl:choose>
181 </xsl:if>
182 </xsl:template>
183
184 <xsl:template match="userinput" mode="screen">
185 <xsl:choose>
186 <!-- Estandarized package formats -->
187 <xsl:when test="contains(string(),'tar.gz')">
188 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
189 <xsl:text>tar.*</xsl:text>
190 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
191 <xsl:text>&#xA;</xsl:text>
192 </xsl:when>
193 <!-- grsecurity kernel in the host? -->
194 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
195 contains(string(),'sysctl')
196 and $grsecurity_host ='n'"/>
197 <!-- We need to have /dev/console and /dev/null availables before
198 entering to the chroot -->
199 <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
200 contains(string(),'600 /dev/console')"/>
201 <!-- Fix MAKEDEV installation in 2.4-branch -->
202 <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
203 contains(string(),'bzcat MAKEDEV')">
204 <xsl:text>bzcat /sources/</xsl:text>
205 <xsl:value-of select="substring-after(string(),'bzcat ')"/>
206 <xsl:text>&#xA;</xsl:text>
207 </xsl:when>
208 <!-- Setting $LANG for /etc/profile -->
209 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
210 contains(string(),'export LANG=')">
211 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
212 <xsl:text>export LANG=</xsl:text>
213 <xsl:value-of select="$lang"/>
214 <xsl:value-of select="substring-after(string(),'CC]')"/>
215 <xsl:text>&#xA;</xsl:text>
216 </xsl:when>
217 <!-- Fixing bootscripts installation -->
218
219<!-- temporary
220 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
221 string() = 'make install'">
222 <xsl:text>make install&#xA;</xsl:text>
223 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
224 </xsl:when>
225-->
226 <!-- Compile the keymap into the kernel has been dissabled -->
227 <xsl:when test="contains(string(),'defkeymap')"/>
228 <!-- Copying the kernel config file -->
229 <xsl:when test="string() = 'make mrproper'">
230 <xsl:text>make mrproper&#xA;</xsl:text>
231 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
232 </xsl:when>
233 <!-- No interactive commands are needed if the .config file is the proper one -->
234 <xsl:when test="string() = 'make menuconfig'"/>
235 <!-- For uClibc we need to cd to the Gettext package -->
236 <xsl:when test="contains(string(),'cd gettext-runtime/')">
237 <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
238 <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
239 <xsl:text>&#xA;</xsl:text>
240 </xsl:when>
241 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
242 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
243 ancestor::sect1[@id='ch-system-module-init-tools']) and
244 (contains(string(),'check') or
245 contains(string(),'distclean') or
246 contains(string(),'dummy'))">
247 <xsl:choose>
248 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
249 <xsl:otherwise>
250 <xsl:if test="not(contains(string(),'check'))">
251 <xsl:apply-templates/>
252 <xsl:text>&#xA;</xsl:text>
253 </xsl:if>
254 <xsl:if test="contains(string(),'check')">
255 <xsl:choose>
256 <xsl:when test="$bomb-testsuite = 'n'">
257 <xsl:value-of select="substring-before(string(),'check')"/>
258 <xsl:text>-k check</xsl:text>
259 <xsl:value-of select="substring-after(string(),'check')"/>
260 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
261 </xsl:when>
262 <xsl:otherwise>
263 <xsl:apply-templates/>
264 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
265 <xsl:if test="contains(string(),' -k ')">
266 <xsl:text> || true</xsl:text>
267 </xsl:if>
268 <xsl:text>&#xA;</xsl:text>
269 </xsl:otherwise>
270 </xsl:choose>
271 </xsl:if>
272 </xsl:otherwise>
273 </xsl:choose>
274 </xsl:when>
275 <!-- Fixing butterfly and 2.4-branch toolchain plus other packages test suites run -->
276 <xsl:when test="string() = 'make -k check'
277 or string() = 'make check'
278 or string() = 'make tests'">
279 <xsl:choose>
280 <xsl:when test="((ancestor::sect1[@id='ch-system-butterfly-toolchain']
281 or ancestor::sect1[@id='ch-system-gcc'] or
282 ancestor::sect1[@id='ch-system-binutils'])
283 and $testsuite != '0') or
284 $testsuite = '2' or $testsuite = '3'">
285 <xsl:choose>
286 <xsl:when test="$bomb-testsuite = 'n'">
287 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
288 </xsl:when>
289 <xsl:otherwise>
290 <xsl:apply-templates/>
291 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
292 <xsl:if test="contains(string(),' -k ')">
293 <xsl:text> || true</xsl:text>
294 </xsl:if>
295 <xsl:text>&#xA;</xsl:text>
296 </xsl:otherwise>
297 </xsl:choose>
298 </xsl:when>
299 </xsl:choose>
300 </xsl:when>
301 <!-- Fixing Glbc test suite -->
302 <xsl:when test="contains(string(),'glibc-check-log')">
303 <xsl:choose>
304 <xsl:when test="$testsuite != '0'">
305 <xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
306 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
307 </xsl:when>
308 </xsl:choose>
309 </xsl:when>
310 <!-- Fixing Butterfly sanity checks -->
311 <xsl:when test="contains(string(),'./fortify-test')
312 or contains(string(),'./ssp-test')">
313 <xsl:text>! </xsl:text>
314 <xsl:apply-templates/>
315 <xsl:text>&#xA;</xsl:text>
316 </xsl:when>
317 <!-- Don't stop on strip run -->
318 <xsl:when test="contains(string(),'strip ')">
319 <xsl:apply-templates/>
320 <xsl:text> || true&#xA;</xsl:text>
321 </xsl:when>
322 <!-- The rest of commands -->
323 <xsl:otherwise>
324 <xsl:apply-templates/>
325 <xsl:text>&#xA;</xsl:text>
326 </xsl:otherwise>
327 </xsl:choose>
328 </xsl:template>
329
330 <xsl:template match="literal">
331 <xsl:if test="(@condition=$model or not(@condition)) and
332 (@vendor=$kernel or not(@vendor))">
333 <xsl:apply-templates/>
334 </xsl:if>
335 </xsl:template>
336
337 <xsl:template match="replaceable">
338 <xsl:choose>
339 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
340 ancestor::sect1[@id='ch-system-uclibc']">
341 <xsl:value-of select="$timezone"/>
342 </xsl:when>
343 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
344 <xsl:value-of select="$page"/>
345 </xsl:when>
346 <xsl:otherwise>
347 <xsl:text>**EDITME</xsl:text>
348 <xsl:apply-templates/>
349 <xsl:text>EDITME**</xsl:text>
350 </xsl:otherwise>
351 </xsl:choose>
352 </xsl:template>
353
354</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.