source: HLFS/hlfs.xsl@ 7fe73c8

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

Final system strip command scripts need to use #!/tools/bin/bash

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