source: HLFS/hlfs.xsl@ e5f5970

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

Dumped tetsuite logs into a separate dir.
Fixed few bugs.

  • Property mode set to 100644
File size: 11.9 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="0"/>
21
22 <!-- Compile the keymap into the kernel? -->
23 <xsl:param name="keymap" select="none"/>
24
25 <!-- Run test suites?
26 0 = none
27 1 = only chapter06 Glibc, GCC and Binutils testsuites
28 2 = all chapter06 testsuites
29 3 = all chapter05 and chapter06 testsuites-->
30 <xsl:param name="testsuite" select="1"/>
31
32 <!-- Time zone -->
33 <xsl:param name="timezone" select="GMT"/>
34
35 <!-- Page size -->
36 <xsl:param name="page" select="letter"/>
37
38 <!-- Locale settings -->
39 <xsl:param name="lang" select="C"/>
40 <xsl:param name="lc_all" select="C"/>
41
42 <xsl:template match="/">
43 <xsl:apply-templates select="//sect1"/>
44 </xsl:template>
45
46 <xsl:template match="sect1">
47 <xsl:if test="(../@id='chapter-temporary-tools' or
48 ../@id='chapter-building-system' or
49 ../@id='chapter-bootable') and
50 ((@condition=$model or not(@condition)) and
51 count(descendant::screen/userinput) &gt; 0 and
52 count(descendant::screen/userinput) &gt;
53 count(descendant::screen[@role='nodump']))">
54 <!-- The dirs names -->
55 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
56 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
57 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
58 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
59 <!-- The file names -->
60 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
61 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
62 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
63 <!-- The build order -->
64 <xsl:variable name="position" select="position()"/>
65 <xsl:variable name="order">
66 <xsl:choose>
67 <xsl:when test="string-length($position) = 1">
68 <xsl:text>00</xsl:text>
69 <xsl:value-of select="$position"/>
70 </xsl:when>
71 <xsl:when test="string-length($position) = 2">
72 <xsl:text>0</xsl:text>
73 <xsl:value-of select="$position"/>
74 </xsl:when>
75 <xsl:otherwise>
76 <xsl:value-of select="$position"/>
77 </xsl:otherwise>
78 </xsl:choose>
79 </xsl:variable>
80 <!-- Creating dirs and files -->
81 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
82 <xsl:choose>
83 <xsl:when test="@id='ch-system-changingowner' or
84 @id='ch-system-creatingdirs' or
85 @id='ch-system-createfiles'">
86 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
87 </xsl:when>
88 <xsl:when test="@id='ch-tools-stripping' or
89 @id='ch-system-strippingagain'">
90 <xsl:text>#!/bin/sh&#xA;</xsl:text>
91 </xsl:when>
92 <xsl:otherwise>
93 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
94 </xsl:otherwise>
95 </xsl:choose>
96 <xsl:if test="(sect2[@role='installation'] and
97 not(@id='bootable-kernel')) or
98 @id='ch-tools-adjusting' or
99 @id='ch-system-readjusting'">
100 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
101 <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
102 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
103 </xsl:if>
104 <xsl:if test="@id='ch-tools-glibc' or @id='ch-system-glibc'">
105 <xsl:text>tar -xvf ../glibc-libidn-&glibc-version;.*&#xA;</xsl:text>
106 </xsl:if>
107 <xsl:if test="@id='ch-tools-gcc' or @id='ch-system-gcc'">
108 <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
109 </xsl:if>
110 <xsl:if test="@id='ch-tools-gcc' and $testsuite = '3'">
111 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
112 </xsl:if>
113 <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
114 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
115 </xsl:if>
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:if test="@id='ch-system-kernfs'">
121 <xsl:text>export HLFS=$LFS&#xA;</xsl:text>
122 </xsl:if>
123 <xsl:apply-templates select=".//para/userinput | .//screen"/>
124 <xsl:text>exit</xsl:text>
125 </exsl:document>
126 </xsl:if>
127 </xsl:template>
128
129 <xsl:template match="screen">
130 <xsl:if test="(@condition=$model or not(@condition)) and
131 child::* = userinput and not(@role = 'nodump')">
132 <xsl:apply-templates select="userinput" mode="screen"/>
133 </xsl:if>
134 </xsl:template>
135
136 <xsl:template match="para/userinput">
137 <xsl:if test="(contains(string(),'test') or
138 contains(string(),'check')) and
139 (($testsuite = '1' and
140 (ancestor::sect1[@id='ch-system-gcc'] or
141 ancestor::sect1[@id='ch-system-glibc'])) or
142 ($testsuite = '2' and
143 ancestor::chapter[@id='chapter-building-system']) or
144 $testsuite = '3')">
145 <xsl:choose>
146 <xsl:when test="ancestor::sect1[@id='ch-system-gcc']">
147 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
148 </xsl:when>
149 <xsl:otherwise>
150 <xsl:value-of select="substring-before(string(),'make')"/>
151 <xsl:text>make -k</xsl:text>
152 <xsl:value-of select="substring-after(string(),'make')"/>
153 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
154 </xsl:otherwise>
155 </xsl:choose>
156 </xsl:if>
157 </xsl:template>
158
159 <xsl:template match="userinput" mode="screen">
160 <xsl:choose>
161 <!-- Estandarized package formats -->
162 <xsl:when test="contains(string(),'tar.gz')">
163 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
164 <xsl:text>tar.*</xsl:text>
165 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
166 <xsl:text>&#xA;</xsl:text>
167 </xsl:when>
168 <!-- Avoiding a race condition in a patch -->
169 <xsl:when test="contains(string(),'debian_fixes')">
170 <xsl:value-of select="substring-before(string(),'patch')"/>
171 <xsl:text>patch -Z</xsl:text>
172 <xsl:value-of select="substring-after(string(),'patch')"/>
173 <xsl:text>&#xA;</xsl:text>
174 </xsl:when>
175 <!-- grsecurity kernel in the host? -->
176 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
177 contains(string(),'sysctl')
178 and $grsecurity_host ='0'"/>
179 <!-- Setting $LC_ALL and $LANG for /etc/profile -->
180 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
181 contains(string(),'export LANG=')">
182 <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
183 <xsl:text>export LC_ALL=</xsl:text>
184 <xsl:value-of select="$lc_all"/>
185 <xsl:text>&#xA;export LANG=</xsl:text>
186 <xsl:value-of select="$lang"/>
187 <xsl:text>&#xA;export INPUTRC</xsl:text>
188 <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
189 <xsl:text>&#xA;</xsl:text>
190 </xsl:when>
191 <!-- Fixing bootscripts installation -->
192 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
193 string() = 'make install'">
194 <xsl:text>make install&#xA;</xsl:text>
195 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
196 </xsl:when>
197 <!-- Compile the keymap into the kernel? -->
198 <xsl:when test="contains(string(),'defkeymap') and
199 $keymap = 'none'"/>
200 <!-- Copying the kernel config file -->
201 <xsl:when test="string() = 'make mrproper'">
202 <xsl:text>make mrproper&#xA;</xsl:text>
203 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
204 </xsl:when>
205 <!-- No interactive commands are needed if the .config file is the proper one -->
206 <xsl:when test="string() = 'make menuconfig'"/>
207 <!-- For uClibc we need to cd to the Gettext package -->
208 <xsl:when test="contains(string(),'cd gettext-runtime/')">
209 <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
210 <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
211 <xsl:text>&#xA;</xsl:text>
212 </xsl:when>
213 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
214 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
215 ancestor::sect1[@id='ch-system-module-init-tools']) and
216 (contains(string(),'check') or
217 contains(string(),'distclean') or
218 contains(string(),'dummy'))">
219 <xsl:choose>
220 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
221 <xsl:otherwise>
222 <xsl:apply-templates/>
223 <xsl:if test="contains(string(),'check')">
224 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
225 </xsl:if>
226 <xsl:text>&#xA;</xsl:text>
227 </xsl:otherwise>
228 </xsl:choose>
229 </xsl:when>
230 <!-- Fixing toolchain test suites run -->
231 <xsl:when test="string() = 'make check' or
232 string() = 'make -k check'">
233 <xsl:choose>
234 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
235 ancestor::chapter[@id='chapter-building-system']) or
236 $testsuite = '3'">
237 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
238 </xsl:when>
239 </xsl:choose>
240 </xsl:when>
241 <xsl:when test="contains(string(),'make check') and
242 ancestor::sect1[@id='ch-system-binutils']">
243 <xsl:choose>
244 <xsl:when test="$testsuite != '0'">
245 <xsl:value-of select="substring-before(string(),'make check')"/>
246 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
247 </xsl:when>
248 </xsl:choose>
249 </xsl:when>
250 <xsl:when test="contains(string(),'hardened-specs') and
251 ancestor::sect1[@id='ch-system-binutils']
252 and $testsuite = '0'"/>
253 <!-- Don't stop on strip run and chapter05 GCC installation test-->
254 <xsl:when test="contains(string(),'strip ') or
255 ancestor::sect2[@id='testing-gcc'] and
256 not(contains(string(),'EOF'))">
257 <xsl:apply-templates/>
258 <xsl:text> || true&#xA;</xsl:text>
259 </xsl:when>
260 <!-- The rest of commands -->
261 <xsl:otherwise>
262 <xsl:apply-templates/>
263 <xsl:text>&#xA;</xsl:text>
264 </xsl:otherwise>
265 </xsl:choose>
266 </xsl:template>
267
268 <xsl:template match="replaceable">
269 <xsl:choose>
270 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
271 ancestor::sect1[@id='ch-system-uclibc']">
272 <xsl:value-of select="$timezone"/>
273 </xsl:when>
274 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
275 <xsl:value-of select="$page"/>
276 </xsl:when>
277 <xsl:when test="ancestor::sect1[@id='bootable-kernel']">
278 <xsl:value-of select="$keymap"/>
279 </xsl:when>
280 <xsl:otherwise>
281 <xsl:text>**EDITME</xsl:text>
282 <xsl:apply-templates/>
283 <xsl:text>EDITME**</xsl:text>
284 </xsl:otherwise>
285 </xsl:choose>
286 </xsl:template>
287
288</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.