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
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
29 3 = all chapter05 and chapter06 testsuites-->
30 <xsl:param name="testsuite" select="1"/>
[0170229]31
[ad71d98]32 <!-- Time zone -->
[e35e794]33 <xsl:param name="timezone" select="GMT"/>
[ad71d98]34
35 <!-- Page size -->
36 <xsl:param name="page" select="letter"/>
37
[d87b293]38 <!-- Locale settings -->
[e35e794]39 <xsl:param name="lang" select="C"/>
40 <xsl:param name="lc_all" select="C"/>
[d87b293]41
[0170229]42 <xsl:template match="/">
43 <xsl:apply-templates select="//sect1"/>
44 </xsl:template>
45
46 <xsl:template match="sect1">
[174a8e9]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']))">
[0170229]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
[174a8e9]84 @id='ch-system-creatingdirs' or
85 @id='ch-system-createfiles'">
[0170229]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
[174a8e9]89 @id='ch-system-strippingagain'">
[0170229]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>
[d540567]96 <xsl:if test="(sect2[@role='installation'] and
[a82bbc0]97 not(@id='bootable-kernel'))">
[0170229]98 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
[174a8e9]99 <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
[0170229]100 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
101 </xsl:if>
[a82bbc0]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>
[0170229]108 </xsl:if>
[a82bbc0]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>
[174a8e9]118 </xsl:if>
[a82bbc0]119 <!-- ONLY butterfly has a testsuite -->
120 <xsl:if test="@id='ch-tools-butterfly-toolchain' and $testsuite = '3'">
[174a8e9]121 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
[0170229]122 </xsl:if>
[a82bbc0]123 <!-- END new toolchain format -->
124
[0170229]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
[65a2be6]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
[0170229]141 <xsl:template match="screen">
[174a8e9]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"/>
[0170229]145 </xsl:if>
146 </xsl:template>
147
148 <xsl:template match="para/userinput">
[174a8e9]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')">
[1f89002]157 <xsl:choose>
158 <xsl:when test="ancestor::sect1[@id='ch-system-gcc']">
[e35e794]159 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[1f89002]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')"/>
[e35e794]165 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[1f89002]166 </xsl:otherwise>
167 </xsl:choose>
[0170229]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>
[d540567]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'"/>
[174a8e9]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=')"/>
[d87b293]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>
[174a8e9]200 <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
201 <xsl:text>&#xA;</xsl:text>
202 </xsl:when>
[a82bbc0]203
204
[d540567]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'"/>
[0170229]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>
[9a4f673]219 <!-- No interactive commands are needed if the .config file is the proper one -->
220 <xsl:when test="string() = 'make menuconfig'"/>
[582feec]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>
[0170229]227 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[e35e794]228 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
[174a8e9]229 ancestor::sect1[@id='ch-system-module-init-tools']) and
[0170229]230 (contains(string(),'check') or
[174a8e9]231 contains(string(),'distclean') or
[e35e794]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>
[0170229]244 <!-- Fixing toolchain test suites run -->
245 <xsl:when test="string() = 'make check' or
[174a8e9]246 string() = 'make -k check'">
[0170229]247 <xsl:choose>
[174a8e9]248 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
249 ancestor::chapter[@id='chapter-building-system']) or
250 $testsuite = '3'">
[e35e794]251 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[174a8e9]252 </xsl:when>
[0170229]253 </xsl:choose>
254 </xsl:when>
[174a8e9]255 <xsl:when test="contains(string(),'make check') and
256 ancestor::sect1[@id='ch-system-binutils']">
[0170229]257 <xsl:choose>
[174a8e9]258 <xsl:when test="$testsuite != '0'">
259 <xsl:value-of select="substring-before(string(),'make check')"/>
[e35e794]260 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[174a8e9]261 </xsl:when>
[0170229]262 </xsl:choose>
263 </xsl:when>
[1f89002]264 <xsl:when test="contains(string(),'hardened-specs') and
265 ancestor::sect1[@id='ch-system-binutils']
266 and $testsuite = '0'"/>
[d540567]267 <!-- Don't stop on strip run and chapter05 GCC installation test-->
268 <xsl:when test="contains(string(),'strip ') or
[ad71d98]269 ancestor::sect2[@id='testing-gcc'] and
270 not(contains(string(),'EOF'))">
[0170229]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>
[174a8e9]284 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
285 ancestor::sect1[@id='ch-system-uclibc']">
[ad71d98]286 <xsl:value-of select="$timezone"/>
[0170229]287 </xsl:when>
288 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
[ad71d98]289 <xsl:value-of select="$page"/>
[0170229]290 </xsl:when>
[d540567]291 <xsl:when test="ancestor::sect1[@id='bootable-kernel']">
292 <xsl:value-of select="$keymap"/>
293 </xsl:when>
[0170229]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.