source: HLFS/hlfs.xsl@ 91ff6a9

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

Replaced /bin/sh by /bin/bash

  • Property mode set to 100644
File size: 13.2 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-changingowner' or
88 @id='ch-system-creatingdirs' or
89 @id='ch-system-createfiles'">
90 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
91 </xsl:when>
92 <xsl:when test="@id='ch-tools-stripping' or
93 @id='ch-system-strippingagain'">
94 <xsl:text>#!/bin/bash&#xA;</xsl:text>
95 </xsl:when>
96 <xsl:otherwise>
97 <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
98 </xsl:otherwise>
99 </xsl:choose>
100 <xsl:if test="(sect2[@role='installation'] and
101 not(@id='bootable-kernel'))">
102 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
103 <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
104 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
105 </xsl:if>
106
107 <!-- NEW 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;.*; &#xA;</xsl:text>
112 <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
113 <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
114 </xsl:if>
115 <!-- ONLY butterfly has a testsuite -->
116 <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
117 <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
118 </xsl:if>
119 <!-- END new toolchain format -->
120
121 <xsl:if test="@id='bootable-bootscripts'">
122 <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; &#xA;</xsl:text>
123 </xsl:if>
124 </xsl:if>
125 <xsl:apply-templates select=".//para/userinput | .//screen"/>
126 <xsl:text>exit</xsl:text>
127 </exsl:document>
128 </xsl:if>
129 </xsl:template>
130
131 <xsl:template match="screen">
132 <xsl:if test="(@condition=$model or not(@condition)) and
133 child::* = userinput and not(@role = 'nodump')">
134 <xsl:apply-templates select="userinput" mode="screen"/>
135 </xsl:if>
136 </xsl:template>
137
138 <xsl:template match="para/userinput">
139 <xsl:if test="(contains(string(),'test') or
140 contains(string(),'check')) and
141 ($testsuite = '2' or $testsuite = '3')">
142 <xsl:choose>
143 <xsl:when test="$bomb-testsuite = 'n'">
144 <xsl:value-of select="substring-before(string(),'make')"/>
145 <xsl:text>make -k</xsl:text>
146 <xsl:value-of select="substring-after(string(),'make')"/>
147 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
148 </xsl:when>
149 <xsl:otherwise>
150 <xsl:apply-templates/>
151 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
152 <xsl:if test="contains(string(),' -k ')">
153 <xsl:text> || true</xsl:text>
154 </xsl:if>
155 <xsl:text>&#xA;</xsl:text>
156 </xsl:otherwise>
157 </xsl:choose>
158 </xsl:if>
159 </xsl:template>
160
161 <xsl:template match="userinput" mode="screen">
162 <xsl:choose>
163 <!-- Estandarized package formats -->
164 <xsl:when test="contains(string(),'tar.gz')">
165 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
166 <xsl:text>tar.*</xsl:text>
167 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
168 <xsl:text>&#xA;</xsl:text>
169 </xsl:when>
170 <!-- Avoiding a race condition in a patch -->
171 <xsl:when test="contains(string(),'debian_fixes')">
172 <xsl:value-of select="substring-before(string(),'patch')"/>
173 <xsl:text>patch -Z</xsl:text>
174 <xsl:value-of select="substring-after(string(),'patch')"/>
175 <xsl:text>&#xA;</xsl:text>
176 </xsl:when>
177 <!-- grsecurity kernel in the host? -->
178 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
179 contains(string(),'sysctl')
180 and $grsecurity_host ='n'"/>
181 <!-- Setting $LC_ALL and $LANG for /etc/profile -->
182 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
183 contains(string(),'export LANG=')">
184 <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
185 <xsl:text>export LC_ALL=</xsl:text>
186 <xsl:value-of select="$lc_all"/>
187 <xsl:text>&#xA;export LANG=</xsl:text>
188 <xsl:value-of select="$lang"/>
189 <xsl:text>&#xA;export INPUTRC</xsl:text>
190 <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
191 <xsl:text>&#xA;</xsl:text>
192 </xsl:when>
193 <!-- Fixing bootscripts installation -->
194 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
195 string() = 'make install'">
196 <xsl:text>make install&#xA;</xsl:text>
197 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
198 </xsl:when>
199 <!-- Compile the keymap into the kernel has been dissabled -->
200 <xsl:when test="contains(string(),'defkeymap')"/>
201 <!-- Copying the kernel config file -->
202 <xsl:when test="string() = 'make mrproper'">
203 <xsl:text>make mrproper&#xA;</xsl:text>
204 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
205 </xsl:when>
206 <!-- No interactive commands are needed if the .config file is the proper one -->
207 <xsl:when test="string() = 'make menuconfig'"/>
208 <!-- For uClibc we need to cd to the Gettext package -->
209 <xsl:when test="contains(string(),'cd gettext-runtime/')">
210 <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
211 <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
212 <xsl:text>&#xA;</xsl:text>
213 </xsl:when>
214 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
215 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
216 ancestor::sect1[@id='ch-system-module-init-tools']) and
217 (contains(string(),'check') or
218 contains(string(),'distclean') or
219 contains(string(),'dummy'))">
220 <xsl:choose>
221 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
222 <xsl:otherwise>
223 <xsl:if test="not(contains(string(),'check'))">
224 <xsl:apply-templates/>
225 <xsl:text>&#xA;</xsl:text>
226 </xsl:if>
227 <xsl:if test="contains(string(),'check')">
228 <xsl:choose>
229 <xsl:when test="$bomb-testsuite = 'n'">
230 <xsl:value-of select="substring-before(string(),'check')"/>
231 <xsl:text>-k check</xsl:text>
232 <xsl:value-of select="substring-after(string(),'check')"/>
233 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
234 </xsl:when>
235 <xsl:otherwise>
236 <xsl:apply-templates/>
237 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
238 <xsl:if test="contains(string(),' -k ')">
239 <xsl:text> || true</xsl:text>
240 </xsl:if>
241 <xsl:text>&#xA;</xsl:text>
242 </xsl:otherwise>
243 </xsl:choose>
244 </xsl:if>
245 </xsl:otherwise>
246 </xsl:choose>
247 </xsl:when>
248 <!-- Fixing butterfly toolchain test suites run -->
249 <xsl:when test="string() = 'make -k check' or string() = 'make check'">
250 <xsl:choose>
251 <xsl:when test="$testsuite != '0'">
252 <xsl:apply-templates/>
253 <xsl:choose>
254 <xsl:when test="$bomb-testsuite = 'n'">
255 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
256 </xsl:when>
257 <xsl:otherwise>
258 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
259 <xsl:if test="contains(string(),' -k ')">
260 <xsl:text> || true</xsl:text>
261 </xsl:if>
262 <xsl:text>&#xA;</xsl:text>
263 </xsl:otherwise>
264 </xsl:choose>
265 </xsl:when>
266 </xsl:choose>
267 </xsl:when>
268 <!-- Fixing Glbc test suite -->
269 <xsl:when test="contains(string(),'glibc-check-log')">
270 <xsl:choose>
271 <xsl:when test="$testsuite != '0'">
272 <xsl:value-of select="substring-before(string(),'&gt; glibc-')"/>
273 <xsl:choose>
274 <xsl:when test="$bomb-testsuite = 'n'">
275 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
276 </xsl:when>
277 <xsl:otherwise>
278 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
279 <xsl:if test="contains(string(),' -k ')">
280 <xsl:text> || true</xsl:text>
281 </xsl:if>
282 <xsl:text>&#xA;</xsl:text>
283 </xsl:otherwise>
284 </xsl:choose>
285 </xsl:when>
286 </xsl:choose>
287 </xsl:when>
288 <!-- Don't stop on strip run and chapter05 GCC installation test-->
289 <xsl:when test="contains(string(),'strip ') or
290 ancestor::sect2[@id='testing-gcc'] and
291 not(contains(string(),'EOF'))">
292 <xsl:apply-templates/>
293 <xsl:text> || true&#xA;</xsl:text>
294 </xsl:when>
295 <!-- The rest of commands -->
296 <xsl:otherwise>
297 <xsl:apply-templates/>
298 <xsl:text>&#xA;</xsl:text>
299 </xsl:otherwise>
300 </xsl:choose>
301 </xsl:template>
302
303 <xsl:template match="literal">
304 <xsl:if test="@condition=$model or not(@condition)">
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.