2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % general-entities SYSTEM
"FAKEDIR/general.ent">
9 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
10 xmlns:
exsl=
"http://exslt.org/common"
11 extension-element-prefixes=
"exsl"
14 <!-- XSLT stylesheet to create shell scripts from HLFS books. -->
16 <!-- What libc implentation must be used? -->
17 <xsl:param name=
"model" select=
"glibc"/>
19 <!-- What kernel serie must be used? -->
20 <xsl:param name=
"kernel" select=
"2.6"/>
22 <!-- Is the host kernel using grsecurity? -->
23 <xsl:param name=
"grsecurity_host" select=
"n"/>
27 1 = only chapter06 Glibc, GCC and Binutils testsuites
28 2 = all chapter06 testsuites
31 <xsl:param name=
"testsuite" select=
"1"/>
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
37 <xsl:param name=
"bomb-testsuite" select=
"n"/>
39 <!-- Additional features -->
40 <xsl:param name=
"features">,ssp,aslr,pax,hardened_tmp,warnings,misc,blowfish,
</xsl:param>
43 <xsl:param name=
"timezone" select=
"GMT"/>
46 <xsl:param name=
"page" select=
"letter"/>
48 <!-- Locale settings -->
49 <xsl:param name=
"lang" select=
"C"/>
51 <xsl:template match=
"/">
52 <xsl:apply-templates select=
"//sect1"/>
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) > 0 and
60 count(descendant::screen/userinput) >
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">
77 <xsl:when test=
"string-length($position) = 1">
78 <xsl:text>00</xsl:text>
79 <xsl:value-of select=
"$position"/>
81 <xsl:when test=
"string-length($position) = 2">
82 <xsl:text>0</xsl:text>
83 <xsl:value-of select=
"$position"/>
86 <xsl:value-of select=
"$position"/>
90 <!-- Creating dirs and files -->
91 <exsl:document href=
"{$dirname}/{$order}-{$filename}" method=
"text">
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

set +h

</xsl:text>
100 <xsl:text>#!/bin/bash

set +h

</xsl:text>
103 <xsl:if test=
"not(@id='ch-tools-stripping') and
104 not(@id='ch-system-strippingagain')">
105 <xsl:text>set -e

</xsl:text>
107 <xsl:text>
</xsl:text>
108 <xsl:if test=
"(sect2[@role='installation'])">
109 <xsl:text>cd $PKGDIR

</xsl:text>
110 <xsl:if test=
"@id='ch-system-uclibc'">
111 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd;

</xsl:text>
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;.*;

</xsl:text>
118 <xsl:text>tar -xvf binutils-&binutils-version;.*;

</xsl:text>
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;.*;

</xsl:text>
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;.*;

</xsl:text>
128 <!-- END SVN toolchain format -->
130 <xsl:apply-templates select=
".//para/userinput | .//screen"/>
131 <xsl:if test=
"not(@id='ch-system-chroot') and
132 not(@id='ch-system-revisedchroot')">
133 <xsl:text>echo -e
"\n\nTotalseconds: $SECONDS\n"
</xsl:text>
135 <xsl:text>exit
</xsl:text>
140 <xsl:template match=
"screen">
141 <xsl:if test=
"(@condition=$model or not(@condition)) and
142 (@vendor=$kernel or not(@vendor)) and
143 child::* = userinput and (not(@role) or
144 (@role and contains($features,concat(',',@role,','))))">
145 <xsl:apply-templates select=
"userinput" mode=
"screen"/>
149 <xsl:template match=
"para/userinput">
150 <xsl:if test=
"(contains(string(),'test') or
151 contains(string(),'check')) and
152 ($testsuite = '2' or $testsuite = '3')">
154 <xsl:when test=
"$bomb-testsuite = 'n'">
155 <xsl:value-of select=
"substring-before(string(),'make')"/>
156 <xsl:text>make -k
</xsl:text>
157 <xsl:value-of select=
"substring-after(string(),'make')"/>
158 <xsl:text> >> $TEST_LOG
2>&1 || true

</xsl:text>
161 <xsl:apply-templates/>
162 <xsl:text> >> $TEST_LOG
2>&1</xsl:text>
163 <xsl:if test=
"contains(string(),' -k ')">
164 <xsl:text> || true
</xsl:text>
166 <xsl:text>
</xsl:text>
172 <xsl:template match=
"userinput" mode=
"screen">
174 <!-- grsecurity kernel in the host? -->
175 <xsl:when test=
"ancestor::sect1[@id='ch-system-kernfs'] and
176 contains(string(),'sysctl')
177 and $grsecurity_host ='n'"/>
178 <!-- Setting $LANG for /etc/profile -->
179 <xsl:when test=
"ancestor::sect1[@id='bootable-profile'] and
180 contains(string(),'export LANG=')">
181 <xsl:value-of select=
"substring-before(string(),'export LANG=')"/>
182 <xsl:text>export LANG=
</xsl:text>
183 <xsl:value-of select=
"$lang"/>
184 <xsl:value-of select=
"substring-after(string(),'CC]')"/>
185 <xsl:text>
</xsl:text>
187 <!-- Copying the kernel config file -->
188 <xsl:when test=
"string() = 'make mrproper'">
189 <xsl:text>make mrproper

</xsl:text>
190 <xsl:text>cp -v /sources/kernel-config .config

</xsl:text>
192 <!-- No interactive commands are needed if the .config file is the proper one -->
193 <xsl:when test=
"string() = 'make menuconfig'"/>
194 <!-- For uClibc we need to set CONFIG_SITE -->
195 <xsl:when test=
"contains(string(),'CONFIG_SITE')">
196 <xsl:value-of select=
"substring-before(string(),'export')"/>
197 <xsl:text>echo
"export</xsl:text>
198 <xsl:value-of select="substring-after(string(),'export')
"/>
199 <xsl:text>" >> ~/.bashrc

</xsl:text>
201 <!-- For uClibc we need to cd to the Gettext package -->
202 <xsl:when test=
"contains(string(),'cd gettext-runtime/')">
203 <xsl:text>cd ../gettext-*/gettext-runtime
</xsl:text>
204 <xsl:value-of select=
"substring-after(string(),'gettext-runtime')"/>
205 <xsl:text>
</xsl:text>
207 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
208 <xsl:when test=
"(ancestor::sect1[@id='ch-system-coreutils'] or
209 ancestor::sect1[@id='ch-system-module-init-tools']) and
210 (contains(string(),'check') or
211 contains(string(),'distclean') or
212 contains(string(),'dummy'))">
214 <xsl:when test=
"$testsuite = '0' or $testsuite = '1'"/>
216 <xsl:if test=
"not(contains(string(),'check'))">
217 <xsl:apply-templates/>
218 <xsl:text>
</xsl:text>
220 <xsl:if test=
"contains(string(),'check')">
222 <xsl:when test=
"$bomb-testsuite = 'n'">
223 <xsl:value-of select=
"substring-before(string(),'check')"/>
224 <xsl:text>-k check
</xsl:text>
225 <xsl:value-of select=
"substring-after(string(),'check')"/>
226 <xsl:text> >> $TEST_LOG
2>&1 || true

</xsl:text>
229 <xsl:apply-templates/>
230 <xsl:text> >> $TEST_LOG
2>&1</xsl:text>
231 <xsl:if test=
"contains(string(),' -k ')">
232 <xsl:text> || true
</xsl:text>
234 <xsl:text>
</xsl:text>
241 <!-- Fixing butterfly toolchain test suite run -->
242 <xsl:when test=
"ancestor::sect1[@id='ch-system-butterfly-toolchain']
243 and string() = 'make -k check'">
245 <xsl:when test=
"$testsuite != '0'">
247 <xsl:when test=
"$bomb-testsuite = 'n'">
248 <xsl:text>make -k check
>> $TEST_LOG
2>&1 || true

</xsl:text>
251 <xsl:apply-templates/>
252 <xsl:text> >> $TEST_LOG
2>&1</xsl:text>
253 <xsl:if test=
"contains(string(),' -k ')">
254 <xsl:text> || true
</xsl:text>
256 <xsl:text>
</xsl:text>
262 <!-- Fixing Glbc test suite -->
263 <xsl:when test=
"contains(string(),'rm -v configparms') and
264 contains(string(),'-fno-stack-protector')">
266 <xsl:when test=
"$testsuite != '0'">
267 <xsl:apply-templates/>
268 <xsl:text>
</xsl:text>
272 <xsl:when test=
"contains(string(),'glibc-check-log')">
274 <xsl:when test=
"$testsuite != '0'">
275 <xsl:value-of select=
"substring-before(string(),'2>&1')"/>
276 <xsl:text>>> $TEST_LOG
2>&1 || true

</xsl:text>
280 <!-- Fixing Cocoon sanity checks -->
281 <xsl:when test=
"contains(string(),'./strcat-overflow')">
282 <xsl:text>set +e

</xsl:text>
283 <xsl:apply-templates/>
284 <xsl:text>
set -e

</xsl:text>
286 <!-- Fixing Butterfly sanity checks -->
287 <xsl:when test=
"contains(string(),'./fortify-test')
288 or contains(string(),'./ssp-test')">
289 <xsl:text>!
</xsl:text>
290 <xsl:apply-templates/>
291 <xsl:text>
</xsl:text>
293 <!-- Don't stop on strip run -->
294 <xsl:when test=
"contains(string(),'strip ')">
295 <xsl:apply-templates/>
296 <xsl:text> || true

</xsl:text>
298 <!-- The rest of commands -->
300 <xsl:apply-templates/>
301 <xsl:text>
</xsl:text>
306 <xsl:template match=
"literal">
307 <xsl:if test=
"(@condition=$model or not(@condition)) and
308 (@vendor=$kernel or not(@vendor))">
309 <xsl:apply-templates/>
313 <xsl:template match=
"replaceable">
315 <xsl:when test=
"ancestor::sect1[@id='ch-system-glibc'] or
316 ancestor::sect1[@id='ch-system-uclibc']">
317 <xsl:value-of select=
"$timezone"/>
319 <xsl:when test=
"ancestor::sect1[@id='ch-system-groff']">
320 <xsl:value-of select=
"$page"/>
323 <xsl:text>**EDITME
</xsl:text>
324 <xsl:apply-templates/>
325 <xsl:text>EDITME**
</xsl:text>