source: HLFS/hlfs.xsl@ 76d58bc

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

HLFS: Fixed Coccon sanity checks run.

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