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 |
|
---|
45 | <xsl:template match="/">
|
---|
46 | <xsl:apply-templates select="//sect1"/>
|
---|
47 | </xsl:template>
|
---|
48 |
|
---|
49 | <xsl:template match="sect1">
|
---|
50 | <xsl:if test="(../@id='chapter-temporary-tools' or
|
---|
51 | ../@id='chapter-building-system' or
|
---|
52 | ../@id='chapter-bootable') and
|
---|
53 | ((@condition=$model or not(@condition)) and
|
---|
54 | count(descendant::screen/userinput) > 0 and
|
---|
55 | count(descendant::screen/userinput) >
|
---|
56 | count(descendant::screen[@role='nodump']))">
|
---|
57 | <!-- The dirs names -->
|
---|
58 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
59 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
60 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
61 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
62 | <!-- The file names -->
|
---|
63 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
64 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
65 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
66 | <!-- The build order -->
|
---|
67 | <xsl:variable name="position" select="position()"/>
|
---|
68 | <xsl:variable name="order">
|
---|
69 | <xsl:choose>
|
---|
70 | <xsl:when test="string-length($position) = 1">
|
---|
71 | <xsl:text>00</xsl:text>
|
---|
72 | <xsl:value-of select="$position"/>
|
---|
73 | </xsl:when>
|
---|
74 | <xsl:when test="string-length($position) = 2">
|
---|
75 | <xsl:text>0</xsl:text>
|
---|
76 | <xsl:value-of select="$position"/>
|
---|
77 | </xsl:when>
|
---|
78 | <xsl:otherwise>
|
---|
79 | <xsl:value-of select="$position"/>
|
---|
80 | </xsl:otherwise>
|
---|
81 | </xsl:choose>
|
---|
82 | </xsl:variable>
|
---|
83 | <!-- Creating dirs and files -->
|
---|
84 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
85 | <xsl:choose>
|
---|
86 | <xsl:when test="@id='ch-system-creatingdirs' or
|
---|
87 | @id='ch-system-createfiles' or
|
---|
88 | @id='ch-system-changingowner' or
|
---|
89 | @id='ch-system-strippingagain'">
|
---|
90 | <xsl:text>#!/tools/bin/bash
set +h
</xsl:text>
|
---|
91 | </xsl:when>
|
---|
92 | <xsl:otherwise>
|
---|
93 | <xsl:text>#!/bin/bash
set +h
</xsl:text>
|
---|
94 | </xsl:otherwise>
|
---|
95 | </xsl:choose>
|
---|
96 | <xsl:if test="not(@id='ch-tools-stripping') and
|
---|
97 | not(@id='ch-system-strippingagain')">
|
---|
98 | <xsl:text>set -e
</xsl:text>
|
---|
99 | </xsl:if>
|
---|
100 | <xsl:text>
</xsl:text>
|
---|
101 | <xsl:if test="(sect2[@role='installation'])">
|
---|
102 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
103 | <xsl:if test="@id='ch-system-uclibc'">
|
---|
104 | <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; 
</xsl:text>
|
---|
105 | </xsl:if>
|
---|
106 |
|
---|
107 | <!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
|
---|
108 | <xsl:if test="@id='ch-tools-embryo-toolchain' or
|
---|
109 | @id='ch-tools-cocoon-toolchain' or
|
---|
110 | @id='ch-system-butterfly-toolchain'">
|
---|
111 | <xsl:text>tar -xvf gcc-core-&gcc-version;.*; 
</xsl:text>
|
---|
112 | <xsl:text>tar -xvf binutils-&binutils-version;.*; 
</xsl:text>
|
---|
113 | </xsl:if>
|
---|
114 | <xsl:if test="@id='ch-tools-cocoon-toolchain' or
|
---|
115 | @id='ch-system-butterfly-toolchain'">
|
---|
116 | <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; 
</xsl:text>
|
---|
117 | </xsl:if>
|
---|
118 | <!-- ONLY butterfly has a testsuite -->
|
---|
119 | <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
|
---|
120 | <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; 
</xsl:text>
|
---|
121 | </xsl:if>
|
---|
122 | <!-- END SVN toolchain format -->
|
---|
123 |
|
---|
124 | <!-- 2.4-branch toolchain -->
|
---|
125 | <xsl:if test="@id='ch-tools-gcc-pass2' or @id='ch-system-gcc'">
|
---|
126 | <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; 
</xsl:text>
|
---|
127 | </xsl:if>
|
---|
128 | <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
|
---|
129 | <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; 
</xsl:text>
|
---|
130 | </xsl:if>
|
---|
131 | <!-- END 2.4-branch toolchain -->
|
---|
132 |
|
---|
133 | <!-- temporary
|
---|
134 | <xsl:if test="@id='bootable-bootscripts'">
|
---|
135 | <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; 
</xsl:text>
|
---|
136 | </xsl:if>
|
---|
137 | -->
|
---|
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> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
162 | </xsl:when>
|
---|
163 | <xsl:otherwise>
|
---|
164 | <xsl:apply-templates/>
|
---|
165 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
166 | <xsl:if test="contains(string(),' -k ')">
|
---|
167 | <xsl:text> || true</xsl:text>
|
---|
168 | </xsl:if>
|
---|
169 | <xsl:text>
</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>
</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>
</xsl:text>
|
---|
198 | </xsl:when>
|
---|
199 | <!-- Setting $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 LANG=')"/>
|
---|
203 | <xsl:text>export LANG=</xsl:text>
|
---|
204 | <xsl:value-of select="$lang"/>
|
---|
205 | <xsl:value-of select="substring-after(string(),'CC]')"/>
|
---|
206 | <xsl:text>
</xsl:text>
|
---|
207 | </xsl:when>
|
---|
208 | <!-- Fixing bootscripts installation -->
|
---|
209 |
|
---|
210 | <!-- temporary
|
---|
211 | <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
|
---|
212 | string() = 'make install'">
|
---|
213 | <xsl:text>make install
</xsl:text>
|
---|
214 | <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;
</xsl:text>
|
---|
215 | </xsl:when>
|
---|
216 | -->
|
---|
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
</xsl:text>
|
---|
222 | <xsl:text>cp -v /sources/kernel-config .config
</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>
</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>
</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> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
252 | </xsl:when>
|
---|
253 | <xsl:otherwise>
|
---|
254 | <xsl:apply-templates/>
|
---|
255 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
256 | <xsl:if test="contains(string(),' -k ')">
|
---|
257 | <xsl:text> || true</xsl:text>
|
---|
258 | </xsl:if>
|
---|
259 | <xsl:text>
</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 >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
279 | </xsl:when>
|
---|
280 | <xsl:otherwise>
|
---|
281 | <xsl:apply-templates/>
|
---|
282 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
283 | <xsl:if test="contains(string(),' -k ')">
|
---|
284 | <xsl:text> || true</xsl:text>
|
---|
285 | </xsl:if>
|
---|
286 | <xsl:text>
</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>&1')"/>
|
---|
297 | <xsl:text>>> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
298 | </xsl:when>
|
---|
299 | </xsl:choose>
|
---|
300 | </xsl:when>
|
---|
301 | <!-- Fixing Butterfly sanity checks -->
|
---|
302 | <xsl:when test="contains(string(),'./fortify-test')
|
---|
303 | or contains(string(),'./ssp-test')">
|
---|
304 | <xsl:text>! </xsl:text>
|
---|
305 | <xsl:apply-templates/>
|
---|
306 | <xsl:text>
</xsl:text>
|
---|
307 | </xsl:when>
|
---|
308 | <!-- Don't stop on strip run -->
|
---|
309 | <xsl:when test="contains(string(),'strip ')">
|
---|
310 | <xsl:apply-templates/>
|
---|
311 | <xsl:text> || true
</xsl:text>
|
---|
312 | </xsl:when>
|
---|
313 | <!-- The rest of commands -->
|
---|
314 | <xsl:otherwise>
|
---|
315 | <xsl:apply-templates/>
|
---|
316 | <xsl:text>
</xsl:text>
|
---|
317 | </xsl:otherwise>
|
---|
318 | </xsl:choose>
|
---|
319 | </xsl:template>
|
---|
320 |
|
---|
321 | <xsl:template match="literal">
|
---|
322 | <xsl:if test="@condition=$model or not(@condition)">
|
---|
323 | <xsl:apply-templates/>
|
---|
324 | </xsl:if>
|
---|
325 | </xsl:template>
|
---|
326 |
|
---|
327 | <xsl:template match="replaceable">
|
---|
328 | <xsl:choose>
|
---|
329 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
|
---|
330 | ancestor::sect1[@id='ch-system-uclibc']">
|
---|
331 | <xsl:value-of select="$timezone"/>
|
---|
332 | </xsl:when>
|
---|
333 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
334 | <xsl:value-of select="$page"/>
|
---|
335 | </xsl:when>
|
---|
336 | <xsl:otherwise>
|
---|
337 | <xsl:text>**EDITME</xsl:text>
|
---|
338 | <xsl:apply-templates/>
|
---|
339 | <xsl:text>EDITME**</xsl:text>
|
---|
340 | </xsl:otherwise>
|
---|
341 | </xsl:choose>
|
---|
342 | </xsl:template>
|
---|
343 |
|
---|
344 | </xsl:stylesheet>
|
---|