source: HLFS/hlfs.xsl@ d0249fc

experimental
Last change on this file since d0249fc was d0249fc, checked in by George Boudreau <georgeb@…>, 18 years ago

Removed code from xsl script, is now performed by book script

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