source: HLFS/hlfs.xsl@ ac35c8e

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

Simplified sha-bang addition.
We are creating the /bin/bash symlink before entering to the chroot jail.

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