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) > 0 and
|
---|
56 | count(descendant::screen/userinput) >
|
---|
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'">
|
---|
89 | <xsl:text>#!/tools/bin/bash
set +h
</xsl:text>
|
---|
90 | </xsl:when>
|
---|
91 | <xsl:otherwise>
|
---|
92 | <xsl:text>#!/bin/bash
set +h
</xsl:text>
|
---|
93 | </xsl:otherwise>
|
---|
94 | </xsl:choose>
|
---|
95 | <xsl:if test="not(@id='ch-tools-stripping') and
|
---|
96 | not(@id='ch-system-strippingagain')">
|
---|
97 | <xsl:text>set -e
</xsl:text>
|
---|
98 | </xsl:if>
|
---|
99 | <xsl:text>
</xsl:text>
|
---|
100 | <xsl:if test="(sect2[@role='installation'] and
|
---|
101 | not(@id='bootable-kernel'))">
|
---|
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 | <xsl:if test="@id='bootable-bootscripts'">
|
---|
134 | <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; 
</xsl:text>
|
---|
135 | </xsl:if>
|
---|
136 | </xsl:if>
|
---|
137 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
138 | <xsl:text>exit</xsl:text>
|
---|
139 | </exsl:document>
|
---|
140 | </xsl:if>
|
---|
141 | </xsl:template>
|
---|
142 |
|
---|
143 | <xsl:template match="screen">
|
---|
144 | <xsl:if test="(@condition=$model or not(@condition)) and
|
---|
145 | child::* = userinput and not(@role = 'nodump')">
|
---|
146 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
147 | </xsl:if>
|
---|
148 | </xsl:template>
|
---|
149 |
|
---|
150 | <xsl:template match="para/userinput">
|
---|
151 | <xsl:if test="(contains(string(),'test') or
|
---|
152 | contains(string(),'check')) and
|
---|
153 | ($testsuite = '2' or $testsuite = '3')">
|
---|
154 | <xsl:choose>
|
---|
155 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
156 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
157 | <xsl:text>make -k</xsl:text>
|
---|
158 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
159 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
160 | </xsl:when>
|
---|
161 | <xsl:otherwise>
|
---|
162 | <xsl:apply-templates/>
|
---|
163 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
164 | <xsl:if test="contains(string(),' -k ')">
|
---|
165 | <xsl:text> || true</xsl:text>
|
---|
166 | </xsl:if>
|
---|
167 | <xsl:text>
</xsl:text>
|
---|
168 | </xsl:otherwise>
|
---|
169 | </xsl:choose>
|
---|
170 | </xsl:if>
|
---|
171 | </xsl:template>
|
---|
172 |
|
---|
173 | <xsl:template match="userinput" mode="screen">
|
---|
174 | <xsl:choose>
|
---|
175 | <!-- Estandarized package formats -->
|
---|
176 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
177 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
178 | <xsl:text>tar.*</xsl:text>
|
---|
179 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
180 | <xsl:text>
</xsl:text>
|
---|
181 | </xsl:when>
|
---|
182 | <!-- grsecurity kernel in the host? -->
|
---|
183 | <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
|
---|
184 | contains(string(),'sysctl')
|
---|
185 | and $grsecurity_host ='n'"/>
|
---|
186 | <!-- We need to have /dev/console and /dev/null availables before
|
---|
187 | entering to the chroot -->
|
---|
188 | <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
|
---|
189 | contains(string(),'600 /dev/console')"/>
|
---|
190 | <!-- Fix MAKEDEV installation in 2.4-branch -->
|
---|
191 | <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
|
---|
192 | contains(string(),'bzcat MAKEDEV')">
|
---|
193 | <xsl:text>bzcat /sources/</xsl:text>
|
---|
194 | <xsl:value-of select="substring-after(string(),'bzcat ')"/>
|
---|
195 | <xsl:text>
</xsl:text>
|
---|
196 | </xsl:when>
|
---|
197 | <!-- Setting $LC_ALL and $LANG for /etc/profile -->
|
---|
198 | <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
|
---|
199 | contains(string(),'export LANG=')">
|
---|
200 | <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
|
---|
201 | <xsl:text>export LC_ALL=</xsl:text>
|
---|
202 | <xsl:value-of select="$lc_all"/>
|
---|
203 | <xsl:text>
export LANG=</xsl:text>
|
---|
204 | <xsl:value-of select="$lang"/>
|
---|
205 | <xsl:text>
export INPUTRC</xsl:text>
|
---|
206 | <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
|
---|
207 | <xsl:text>
</xsl:text>
|
---|
208 | </xsl:when>
|
---|
209 | <!-- Fixing bootscripts installation -->
|
---|
210 | <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
|
---|
211 | string() = 'make install'">
|
---|
212 | <xsl:text>make install
</xsl:text>
|
---|
213 | <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;
</xsl:text>
|
---|
214 | </xsl:when>
|
---|
215 | <!-- Compile the keymap into the kernel has been dissabled -->
|
---|
216 | <xsl:when test="contains(string(),'defkeymap')"/>
|
---|
217 | <!-- Copying the kernel config file -->
|
---|
218 | <xsl:when test="string() = 'make mrproper'">
|
---|
219 | <xsl:text>make mrproper
</xsl:text>
|
---|
220 | <xsl:text>cp -v /sources/kernel-config .config
</xsl:text>
|
---|
221 | </xsl:when>
|
---|
222 | <!-- No interactive commands are needed if the .config file is the proper one -->
|
---|
223 | <xsl:when test="string() = 'make menuconfig'"/>
|
---|
224 | <!-- For uClibc we need to cd to the Gettext package -->
|
---|
225 | <xsl:when test="contains(string(),'cd gettext-runtime/')">
|
---|
226 | <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
|
---|
227 | <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
|
---|
228 | <xsl:text>
</xsl:text>
|
---|
229 | </xsl:when>
|
---|
230 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
231 | <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
232 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
233 | (contains(string(),'check') or
|
---|
234 | contains(string(),'distclean') or
|
---|
235 | contains(string(),'dummy'))">
|
---|
236 | <xsl:choose>
|
---|
237 | <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
|
---|
238 | <xsl:otherwise>
|
---|
239 | <xsl:if test="not(contains(string(),'check'))">
|
---|
240 | <xsl:apply-templates/>
|
---|
241 | <xsl:text>
</xsl:text>
|
---|
242 | </xsl:if>
|
---|
243 | <xsl:if test="contains(string(),'check')">
|
---|
244 | <xsl:choose>
|
---|
245 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
246 | <xsl:value-of select="substring-before(string(),'check')"/>
|
---|
247 | <xsl:text>-k check</xsl:text>
|
---|
248 | <xsl:value-of select="substring-after(string(),'check')"/>
|
---|
249 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
250 | </xsl:when>
|
---|
251 | <xsl:otherwise>
|
---|
252 | <xsl:apply-templates/>
|
---|
253 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
254 | <xsl:if test="contains(string(),' -k ')">
|
---|
255 | <xsl:text> || true</xsl:text>
|
---|
256 | </xsl:if>
|
---|
257 | <xsl:text>
</xsl:text>
|
---|
258 | </xsl:otherwise>
|
---|
259 | </xsl:choose>
|
---|
260 | </xsl:if>
|
---|
261 | </xsl:otherwise>
|
---|
262 | </xsl:choose>
|
---|
263 | </xsl:when>
|
---|
264 | <!-- Fixing butterfly and 2.4-branch toolchain plus other packages test suites run -->
|
---|
265 | <xsl:when test="string() = 'make -k check'
|
---|
266 | or string() = 'make check'
|
---|
267 | or string() = 'make tests'">
|
---|
268 | <xsl:choose>
|
---|
269 | <xsl:when test="((ancestor::sect1[@id='ch-system-butterfly-toolchain']
|
---|
270 | or ancestor::sect1[@id='ch-system-gcc'] or
|
---|
271 | ancestor::sect1[@id='ch-system-binutils'])
|
---|
272 | and $testsuite != '0') or
|
---|
273 | $testsuite = '2' or $testsuite = '3'">
|
---|
274 | <xsl:choose>
|
---|
275 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
276 | <xsl:text>make -k check >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
277 | </xsl:when>
|
---|
278 | <xsl:otherwise>
|
---|
279 | <xsl:apply-templates/>
|
---|
280 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
281 | <xsl:if test="contains(string(),' -k ')">
|
---|
282 | <xsl:text> || true</xsl:text>
|
---|
283 | </xsl:if>
|
---|
284 | <xsl:text>
</xsl:text>
|
---|
285 | </xsl:otherwise>
|
---|
286 | </xsl:choose>
|
---|
287 | </xsl:when>
|
---|
288 | </xsl:choose>
|
---|
289 | </xsl:when>
|
---|
290 | <!-- Fixing Glbc test suite -->
|
---|
291 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
292 | <xsl:choose>
|
---|
293 | <xsl:when test="$testsuite != '0'">
|
---|
294 | <xsl:value-of select="substring-before(string(),'2>&1')"/>
|
---|
295 | <xsl:text>>> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
296 | </xsl:when>
|
---|
297 | </xsl:choose>
|
---|
298 | </xsl:when>
|
---|
299 | <!-- Don't stop on strip run -->
|
---|
300 | <xsl:when test="contains(string(),'strip ')">
|
---|
301 | <xsl:apply-templates/>
|
---|
302 | <xsl:text> || true
</xsl:text>
|
---|
303 | </xsl:when>
|
---|
304 | <!-- The rest of commands -->
|
---|
305 | <xsl:otherwise>
|
---|
306 | <xsl:apply-templates/>
|
---|
307 | <xsl:text>
</xsl:text>
|
---|
308 | </xsl:otherwise>
|
---|
309 | </xsl:choose>
|
---|
310 | </xsl:template>
|
---|
311 |
|
---|
312 | <xsl:template match="literal">
|
---|
313 | <xsl:if test="@condition=$model or not(@condition)">
|
---|
314 | <xsl:apply-templates/>
|
---|
315 | </xsl:if>
|
---|
316 | </xsl:template>
|
---|
317 |
|
---|
318 | <xsl:template match="replaceable">
|
---|
319 | <xsl:choose>
|
---|
320 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
|
---|
321 | ancestor::sect1[@id='ch-system-uclibc']">
|
---|
322 | <xsl:value-of select="$timezone"/>
|
---|
323 | </xsl:when>
|
---|
324 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
325 | <xsl:value-of select="$page"/>
|
---|
326 | </xsl:when>
|
---|
327 | <xsl:otherwise>
|
---|
328 | <xsl:text>**EDITME</xsl:text>
|
---|
329 | <xsl:apply-templates/>
|
---|
330 | <xsl:text>EDITME**</xsl:text>
|
---|
331 | </xsl:otherwise>
|
---|
332 | </xsl:choose>
|
---|
333 | </xsl:template>
|
---|
334 |
|
---|
335 | </xsl:stylesheet>
|
---|