source: CLFS/clfs.xsl@ 725ae5a

experimental
Last change on this file since 725ae5a was 3b63c8c, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Updated experimental branch to current trunk code.

  • Property mode set to 100644
File size: 9.5 KB
RevLine 
[a9490ab]1<?xml version="1.0"?>
[e676ffa]2<!DOCTYPE xsl:stylesheet [
3 <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
4 %general-entities;
5]>
6
7<!-- $Id$ -->
8
[a9490ab]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
[e676ffa]14<!-- XSLT stylesheet to create shell scripts from CLFS books. -->
15
16 <!-- Build method used -->
17 <xsl:param name="method" select="chroot"/>
18
19 <!-- Compile the keymap into the kernel? -->
20 <xsl:param name="keymap" select="none"/>
21
22 <!-- Run test suites?
23 0 = none
24 1 = only Glibc, GCC and Binutils testsuites
25 2 = all testsuites
26 3 = alias to 2 -->
27 <xsl:param name="testsuite" select="1"/>
28
29 <!-- Install vim-lang package? -->
30 <xsl:param name="vim-lang" select="1"/>
31
32 <!-- Time zone -->
[e35e794]33 <xsl:param name="timezone" select="GMT"/>
[e676ffa]34
35 <!-- Page size -->
36 <xsl:param name="page" select="letter"/>
37
38 <!-- Locale settings -->
[e35e794]39 <xsl:param name="lang" select="C"/>
[a9490ab]40
41 <xsl:template match="/">
42 <xsl:apply-templates select="//sect1"/>
43 </xsl:template>
44
45 <xsl:template match="sect1">
[e676ffa]46 <xsl:choose>
47 <xsl:when test="../@id='chapter-partitioning' or
48 ../@id='chapter-getting-materials' or
49 ../@id='chapter-final-preps'"/>
50 <xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
51 <xsl:when test="../@id='chapter-boot' and $method='chroot'"/>
52 <xsl:when test="../@id='chapter-chroot' and $method='boot'"/>
53 <xsl:otherwise>
54 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
55 count(descendant::screen/userinput) &gt;
56 count(descendant::screen[@role='nodump'])">
57 <!-- The dirs names -->
58 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
59 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
60 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
61 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
62 <!-- The file names -->
63 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
64 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
65 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
66 <!-- The build order -->
67 <xsl:variable name="position" select="position()"/>
68 <xsl:variable name="order">
69 <xsl:choose>
70 <xsl:when test="string-length($position) = 1">
71 <xsl:text>00</xsl:text>
72 <xsl:value-of select="$position"/>
73 </xsl:when>
74 <xsl:when test="string-length($position) = 2">
75 <xsl:text>0</xsl:text>
76 <xsl:value-of select="$position"/>
77 </xsl:when>
78 <xsl:otherwise>
79 <xsl:value-of select="$position"/>
80 </xsl:otherwise>
81 </xsl:choose>
82 </xsl:variable>
83 <!-- Creating dirs and files -->
84 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
85 <xsl:choose>
86 <xsl:when test="../@id='chapter-chroot'">
87 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
88 </xsl:when>
89 <xsl:when test="@id='ch-system-stripping'">
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']">
97 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
98 <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
99 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
100 </xsl:if>
101 </xsl:if>
102 <xsl:apply-templates select=".//para/userinput | .//screen"/>
103 <xsl:text>exit</xsl:text>
104 </exsl:document>
105 </xsl:if>
106 </xsl:otherwise>
107 </xsl:choose>
[a9490ab]108 </xsl:template>
109
110 <xsl:template match="screen">
[e676ffa]111 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
112 <xsl:apply-templates select="userinput" mode="screen"/>
[a9490ab]113 </xsl:if>
114 </xsl:template>
115
[e676ffa]116 <xsl:template match="para/userinput">
117 <xsl:if test="(contains(string(),'test') or
118 contains(string(),'check')) and
119 ($testsuite = '2' or $testsuite = '3')">
120 <xsl:value-of select="substring-before(string(),'make')"/>
121 <xsl:text>make -k</xsl:text>
122 <xsl:value-of select="substring-after(string(),'make')"/>
[e35e794]123 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[a9490ab]124 </xsl:if>
[e676ffa]125 </xsl:template>
126
127 <xsl:template match="userinput" mode="screen">
128 <xsl:choose>
129 <!-- Estandarized package formats -->
130 <xsl:when test="contains(string(),'tar.gz')">
131 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
132 <xsl:text>tar.*</xsl:text>
133 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
134 <xsl:text>&#xA;</xsl:text>
135 </xsl:when>
136 <!-- Avoiding a race condition in a patch -->
137 <xsl:when test="contains(string(),'debian_fixes')">
138 <xsl:value-of select="substring-before(string(),'patch')"/>
139 <xsl:text>patch -Z</xsl:text>
140 <xsl:value-of select="substring-after(string(),'patch')"/>
141 <xsl:text>&#xA;</xsl:text>
142 </xsl:when>
143 <!-- Setting $LANG for /etc/profile -->
144 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
145 contains(string(),'export LANG=')">
146 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
147 <xsl:text>export LANG=</xsl:text>
148 <xsl:value-of select="$lang"/>
[62033d2]149 <xsl:value-of select="substring-after(string(),'charmap]')"/>
[e676ffa]150 <xsl:text>&#xA;</xsl:text>
151 </xsl:when>
152 <!-- Compile the keymap into the kernel? -->
153 <xsl:when test="contains(string(),'defkeymap') and
154 $keymap = 'none'"/>
155 <!-- Copying the kernel config file -->
156 <xsl:when test="string() = 'make mrproper'">
157 <xsl:text>make mrproper&#xA;</xsl:text>
158 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
159 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
160 </xsl:if>
161 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
162 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
163 </xsl:if>
164 </xsl:when>
[9a4f673]165 <!-- No interactive commands are needed if the .config file is the proper one -->
166 <xsl:when test="contains(string(),'menuconfig')"/>
[e676ffa]167 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[e35e794]168 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
[e676ffa]169 ancestor::sect1[@id='ch-system-module-init-tools']) and
170 (contains(string(),'check') or
[e35e794]171 contains(string(),'dummy'))">
172 <xsl:choose>
173 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
174 <xsl:otherwise>
175 <xsl:apply-templates/>
176 <xsl:if test="contains(string(),'check')">
177 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
178 </xsl:if>
179 <xsl:text>&#xA;</xsl:text>
180 </xsl:otherwise>
181 </xsl:choose>
182 </xsl:when>
[e676ffa]183 <!-- Fixing toolchain test suites run -->
184 <xsl:when test="string() = 'make check' or
185 string() = 'make -k check'">
186 <xsl:choose>
187 <xsl:when test="$testsuite != '0'">
[e35e794]188 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[e676ffa]189 </xsl:when>
190 </xsl:choose>
191 </xsl:when>
192 <xsl:when test="contains(string(),'glibc-check-log')">
193 <xsl:choose>
194 <xsl:when test="$testsuite != '0'">
[e35e794]195 <xsl:value-of select="substring-before(string(),'&gt;g')"/>
196 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[e676ffa]197 </xsl:when>
198 </xsl:choose>
199 </xsl:when>
200 <xsl:when test="contains(string(),'test_summary') or
201 contains(string(),'expect -c')">
202 <xsl:choose>
203 <xsl:when test="$testsuite != '0'">
204 <xsl:apply-templates/>
[e35e794]205 <xsl:if test="contains(string(),'test_summary')">
206 <xsl:text> &gt;&gt; $TEST_LOG</xsl:text>
207 </xsl:if>
[e676ffa]208 <xsl:text>&#xA;</xsl:text>
209 </xsl:when>
210 </xsl:choose>
211 </xsl:when>
212 <!-- Don't stop on strip run -->
213 <xsl:when test="contains(string(),'strip ')">
214 <xsl:apply-templates/>
215 <xsl:text> || true&#xA;</xsl:text>
216 </xsl:when>
217 <!-- The rest of commands -->
218 <xsl:otherwise>
219 <xsl:apply-templates/>
220 <xsl:text>&#xA;</xsl:text>
221 </xsl:otherwise>
222 </xsl:choose>
[a9490ab]223 </xsl:template>
224
225 <xsl:template match="replaceable">
[e676ffa]226 <xsl:choose>
227 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
228 <xsl:value-of select="$timezone"/>
229 </xsl:when>
230 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
231 <xsl:value-of select="$page"/>
232 </xsl:when>
[3b63c8c]233 <xsl:when test="ancestor::sect1[@id='ch-boot-kernel'] or
234 ancestor::sect1[@id='ch-bootable-kernel']">
235 <xsl:value-of select="$keymap"/>
236 </xsl:when>
[e676ffa]237 <xsl:otherwise>
238 <xsl:text>**EDITME</xsl:text>
239 <xsl:apply-templates/>
240 <xsl:text>EDITME**</xsl:text>
241 </xsl:otherwise>
242 </xsl:choose>
[a9490ab]243 </xsl:template>
244
245</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.