source: HLFS/hlfs.xsl@ ef87eed

experimental
Last change on this file since ef87eed was 056486c, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Ported r2882 from trunk.

  • Property mode set to 100644
File size: 12.7 KB
RevLine 
[0170229]1<?xml version="1.0"?>
2<!DOCTYPE xsl:stylesheet [
3 <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
4 %general-entities;
5]>
6
[174a8e9]7<!-- $Id$ -->
8
[0170229]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
[174a8e9]14<!-- XSLT stylesheet to create shell scripts from HLFS books. -->
[0170229]15
[174a8e9]16 <!-- What libc implentation must be used? -->
17 <xsl:param name="model" select="glibc"/>
[0170229]18
[d540567]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
[174a8e9]25 <!-- Run test suites?
26 0 = none
27 1 = only chapter06 Glibc, GCC and Binutils testsuites
28 2 = all chapter06 testsuites
[056486c]29 3 = alias to 2
30 -->
[174a8e9]31 <xsl:param name="testsuite" select="1"/>
[0170229]32
[056486c]33 <!-- Bomb on test suites failures?
34 0 = no, I want to build the full system and review the logs
35 1 = yes, bomb at the first test suite failure to can review the build dir
36 -->
37 <xsl:param name="bomb-testsuite" select="0"/>
38
[ad71d98]39 <!-- Time zone -->
[e35e794]40 <xsl:param name="timezone" select="GMT"/>
[ad71d98]41
42 <!-- Page size -->
43 <xsl:param name="page" select="letter"/>
44
[d87b293]45 <!-- Locale settings -->
[e35e794]46 <xsl:param name="lang" select="C"/>
47 <xsl:param name="lc_all" select="C"/>
[d87b293]48
[0170229]49 <xsl:template match="/">
50 <xsl:apply-templates select="//sect1"/>
51 </xsl:template>
52
53 <xsl:template match="sect1">
[174a8e9]54 <xsl:if test="(../@id='chapter-temporary-tools' or
55 ../@id='chapter-building-system' or
56 ../@id='chapter-bootable') and
57 ((@condition=$model or not(@condition)) and
58 count(descendant::screen/userinput) &gt; 0 and
59 count(descendant::screen/userinput) &gt;
60 count(descendant::screen[@role='nodump']))">
[0170229]61 <!-- The dirs names -->
62 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
63 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
64 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
65 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
66 <!-- The file names -->
67 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
68 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
69 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
70 <!-- The build order -->
71 <xsl:variable name="position" select="position()"/>
72 <xsl:variable name="order">
73 <xsl:choose>
74 <xsl:when test="string-length($position) = 1">
75 <xsl:text>00</xsl:text>
76 <xsl:value-of select="$position"/>
77 </xsl:when>
78 <xsl:when test="string-length($position) = 2">
79 <xsl:text>0</xsl:text>
80 <xsl:value-of select="$position"/>
81 </xsl:when>
82 <xsl:otherwise>
83 <xsl:value-of select="$position"/>
84 </xsl:otherwise>
85 </xsl:choose>
86 </xsl:variable>
87 <!-- Creating dirs and files -->
88 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
89 <xsl:choose>
90 <xsl:when test="@id='ch-system-changingowner' or
[174a8e9]91 @id='ch-system-creatingdirs' or
92 @id='ch-system-createfiles'">
[0170229]93 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
94 </xsl:when>
95 <xsl:when test="@id='ch-tools-stripping' or
[174a8e9]96 @id='ch-system-strippingagain'">
[0170229]97 <xsl:text>#!/bin/sh&#xA;</xsl:text>
98 </xsl:when>
99 <xsl:otherwise>
100 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
101 </xsl:otherwise>
102 </xsl:choose>
[d540567]103 <xsl:if test="(sect2[@role='installation'] and
[a82bbc0]104 not(@id='bootable-kernel'))">
[0170229]105 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
[174a8e9]106 <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
[0170229]107 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
108 </xsl:if>
[f83bcee]109
[7c4730c]110 <!-- NEW toolchain format, from inside ./sources dir unpack binutils and gcc -->
[f83bcee]111 <xsl:if test="@id='ch-tools-embryo-toolchain' or
112 @id='ch-tools-cocoon-toolchain' or
113 @id='ch-system-butterfly-toolchain'">
[a82bbc0]114 <xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
115 <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
116 <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
[174a8e9]117 </xsl:if>
[a82bbc0]118 <!-- ONLY butterfly has a testsuite -->
[00818a6]119 <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
[7c4730c]120 <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
[0170229]121 </xsl:if>
[a82bbc0]122 <!-- END new toolchain format -->
[f83bcee]123
[0170229]124 <xsl:if test="@id='bootable-bootscripts'">
125 <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; &#xA;</xsl:text>
126 </xsl:if>
127 </xsl:if>
128 <xsl:apply-templates select=".//para/userinput | .//screen"/>
129 <xsl:text>exit</xsl:text>
130 </exsl:document>
131 </xsl:if>
132 </xsl:template>
133
134 <xsl:template match="screen">
[174a8e9]135 <xsl:if test="(@condition=$model or not(@condition)) and
136 child::* = userinput and not(@role = 'nodump')">
137 <xsl:apply-templates select="userinput" mode="screen"/>
[0170229]138 </xsl:if>
139 </xsl:template>
140
141 <xsl:template match="para/userinput">
[174a8e9]142 <xsl:if test="(contains(string(),'test') or
[f83bcee]143 contains(string(),'check')) and
144 ($testsuite = '2' or $testsuite = '3')">
[056486c]145 <xsl:choose>
146 <xsl:when test="$bomb-testsuite = '0'">
147 <xsl:value-of select="substring-before(string(),'make')"/>
148 <xsl:text>make -k</xsl:text>
149 <xsl:value-of select="substring-after(string(),'make')"/>
150 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
151 </xsl:when>
152 <xsl:otherwise>
153 <xsl:apply-templates/>
154 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
155 </xsl:otherwise>
156 </xsl:choose>
[0170229]157 </xsl:if>
158 </xsl:template>
159
160 <xsl:template match="userinput" mode="screen">
161 <xsl:choose>
162 <!-- Estandarized package formats -->
163 <xsl:when test="contains(string(),'tar.gz')">
164 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
165 <xsl:text>tar.*</xsl:text>
166 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
167 <xsl:text>&#xA;</xsl:text>
168 </xsl:when>
169 <!-- Avoiding a race condition in a patch -->
170 <xsl:when test="contains(string(),'debian_fixes')">
171 <xsl:value-of select="substring-before(string(),'patch')"/>
172 <xsl:text>patch -Z</xsl:text>
173 <xsl:value-of select="substring-after(string(),'patch')"/>
174 <xsl:text>&#xA;</xsl:text>
175 </xsl:when>
[d540567]176 <!-- grsecurity kernel in the host? -->
177 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
178 contains(string(),'sysctl')
179 and $grsecurity_host ='0'"/>
[174a8e9]180 <!-- Setting $LC_ALL and $LANG for /etc/profile -->
181 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
182 contains(string(),'export LANG=')">
183 <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
[d87b293]184 <xsl:text>export LC_ALL=</xsl:text>
185 <xsl:value-of select="$lc_all"/>
186 <xsl:text>&#xA;export LANG=</xsl:text>
187 <xsl:value-of select="$lang"/>
188 <xsl:text>&#xA;export INPUTRC</xsl:text>
[174a8e9]189 <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
190 <xsl:text>&#xA;</xsl:text>
191 </xsl:when>
[d540567]192 <!-- Fixing bootscripts installation -->
193 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
194 string() = 'make install'">
195 <xsl:text>make install&#xA;</xsl:text>
196 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
197 </xsl:when>
198 <!-- Compile the keymap into the kernel? -->
199 <xsl:when test="contains(string(),'defkeymap') and
200 $keymap = 'none'"/>
[0170229]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>
[9a4f673]206 <!-- No interactive commands are needed if the .config file is the proper one -->
207 <xsl:when test="string() = 'make menuconfig'"/>
[582feec]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>
[0170229]214 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[e35e794]215 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
[174a8e9]216 ancestor::sect1[@id='ch-system-module-init-tools']) and
[0170229]217 (contains(string(),'check') or
[174a8e9]218 contains(string(),'distclean') or
[e35e794]219 contains(string(),'dummy'))">
220 <xsl:choose>
221 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
222 <xsl:otherwise>
[056486c]223 <xsl:if test="not(contains(string(),'check'))">
224 <xsl:apply-templates/>
225 <xsl:text>&#xA;</xsl:text>
226 </xsl:if>
[e35e794]227 <xsl:if test="contains(string(),'check')">
[056486c]228 <xsl:choose>
229 <xsl:when test="$bomb-testsuite = '0'">
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&#xA;</xsl:text>
238 </xsl:otherwise>
239 </xsl:choose>
[e35e794]240 </xsl:if>
241 </xsl:otherwise>
242 </xsl:choose>
243 </xsl:when>
[f83bcee]244 <!-- Fixing butterfly toolchain test suites run -->
245 <xsl:when test="string() = 'make -k check'">
[0170229]246 <xsl:choose>
[f83bcee]247 <xsl:when test="$testsuite != '0'">
[056486c]248 <xsl:apply-templates/>
249 <xsl:choose>
250 <xsl:when test="$bomb-testsuite = '0'">
251 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
252 </xsl:when>
253 <xsl:otherwise>
254 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
255 </xsl:otherwise>
256 </xsl:choose>
[174a8e9]257 </xsl:when>
[0170229]258 </xsl:choose>
259 </xsl:when>
[f83bcee]260 <!-- Fixing Glbc test suite -->
261 <xsl:when test="contains(string(),'glibc-check-log')">
262 <xsl:choose>
263 <xsl:when test="$testsuite != '0'">
264 <xsl:value-of select="substring-before(string(),'&gt; glibc-')"/>
[056486c]265 <xsl:choose>
266 <xsl:when test="$bomb-testsuite = '0'">
267 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
268 </xsl:when>
269 <xsl:otherwise>
270 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
271 </xsl:otherwise>
272 </xsl:choose>
[f83bcee]273 </xsl:when>
274 </xsl:choose>
275 </xsl:when>
[d540567]276 <!-- Don't stop on strip run and chapter05 GCC installation test-->
277 <xsl:when test="contains(string(),'strip ') or
[ad71d98]278 ancestor::sect2[@id='testing-gcc'] and
279 not(contains(string(),'EOF'))">
[0170229]280 <xsl:apply-templates/>
281 <xsl:text> || true&#xA;</xsl:text>
282 </xsl:when>
283 <!-- The rest of commands -->
284 <xsl:otherwise>
285 <xsl:apply-templates/>
286 <xsl:text>&#xA;</xsl:text>
287 </xsl:otherwise>
288 </xsl:choose>
289 </xsl:template>
290
[f83bcee]291 <xsl:template match="literal">
292 <xsl:if test="@condition=$model or not(@condition)">
293 <xsl:apply-templates/>
294 </xsl:if>
295 </xsl:template>
296
[0170229]297 <xsl:template match="replaceable">
298 <xsl:choose>
[174a8e9]299 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
300 ancestor::sect1[@id='ch-system-uclibc']">
[ad71d98]301 <xsl:value-of select="$timezone"/>
[0170229]302 </xsl:when>
303 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
[ad71d98]304 <xsl:value-of select="$page"/>
[0170229]305 </xsl:when>
[d540567]306 <xsl:when test="ancestor::sect1[@id='bootable-kernel']">
307 <xsl:value-of select="$keymap"/>
308 </xsl:when>
[0170229]309 <xsl:otherwise>
310 <xsl:text>**EDITME</xsl:text>
311 <xsl:apply-templates/>
312 <xsl:text>EDITME**</xsl:text>
313 </xsl:otherwise>
314 </xsl:choose>
315 </xsl:template>
316
317</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.