source: CLFS/clfs.xsl@ f56e662

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since f56e662 was fc6076c, checked in by George Boudreau <georgeb@…>, 18 years ago

Who knew make would not like embedded control codes in its strings. For now tab_ works but nl_ doesn't

  • Property mode set to 100644
File size: 11.5 KB
RevLine 
[877cc6a]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 CLFS books. -->
15
16 <!-- Build method used -->
17 <xsl:param name="method" select="chroot"/>
18
19 <!-- Run test suites?
20 0 = none
21 1 = only Glibc, GCC and Binutils testsuites
22 2 = all testsuites
[28f4756]23 3 = alias to 2
24 -->
[877cc6a]25 <xsl:param name="testsuite" select="1"/>
26
[28f4756]27 <!-- Bomb on test suites failures?
[401f81e]28 n = no, I want to build the full system and review the logs
29 y = yes, bomb at the first test suite failure to can review the build dir
[28f4756]30 -->
[401f81e]31 <xsl:param name="bomb-testsuite" select="n"/>
[28f4756]32
[877cc6a]33 <!-- Install vim-lang package? -->
[401f81e]34 <xsl:param name="vim-lang" select="y"/>
[877cc6a]35
36 <!-- Time zone -->
[a229600]37 <xsl:param name="timezone" select="GMT"/>
[877cc6a]38
39 <!-- Page size -->
40 <xsl:param name="page" select="letter"/>
41
42 <!-- Locale settings -->
[a229600]43 <xsl:param name="lang" select="C"/>
[877cc6a]44
45 <xsl:template match="/">
46 <xsl:apply-templates select="//sect1"/>
47 </xsl:template>
48
49 <xsl:template match="sect1">
50 <xsl:choose>
51 <xsl:when test="../@id='chapter-partitioning' or
52 ../@id='chapter-getting-materials' or
53 ../@id='chapter-final-preps'"/>
54 <xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
55 <xsl:when test="../@id='chapter-boot' and $method='chroot'"/>
56 <xsl:when test="../@id='chapter-chroot' and $method='boot'"/>
57 <xsl:otherwise>
58 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
59 count(descendant::screen/userinput) &gt;
60 count(descendant::screen[@role='nodump'])">
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='chapter-chroot'">
91 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
92 </xsl:when>
93 <xsl:when test="@id='ch-system-stripping'">
[fc6076c]94 <xsl:text>#!/bin/bash&#xA;</xsl:text>
[877cc6a]95 </xsl:when>
96 <xsl:otherwise>
[fc6076c]97 <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
[877cc6a]98 </xsl:otherwise>
99 </xsl:choose>
100 <xsl:if test="sect2[@role='installation']">
101 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
[401f81e]102 <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
[877cc6a]103 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
104 </xsl:if>
105 </xsl:if>
106 <xsl:apply-templates select=".//para/userinput | .//screen"/>
107 <xsl:text>exit</xsl:text>
108 </exsl:document>
109 </xsl:if>
110 </xsl:otherwise>
111 </xsl:choose>
112 </xsl:template>
113
114 <xsl:template match="screen">
115 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
116 <xsl:apply-templates select="userinput" mode="screen"/>
117 </xsl:if>
118 </xsl:template>
119
120 <xsl:template match="para/userinput">
121 <xsl:if test="(contains(string(),'test') or
122 contains(string(),'check')) and
123 ($testsuite = '2' or $testsuite = '3')">
[28f4756]124 <xsl:choose>
[401f81e]125 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]126 <xsl:value-of select="substring-before(string(),'make')"/>
127 <xsl:text>make -k</xsl:text>
128 <xsl:value-of select="substring-after(string(),'make')"/>
129 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
130 </xsl:when>
131 <xsl:otherwise>
132 <xsl:apply-templates/>
[a1f1969]133 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
134 <xsl:if test="contains(string(),' -k ')">
135 <xsl:text> || true</xsl:text>
136 </xsl:if>
137 <xsl:text>&#xA;</xsl:text>
[28f4756]138 </xsl:otherwise>
139 </xsl:choose>
[877cc6a]140 </xsl:if>
141 </xsl:template>
142
143 <xsl:template match="userinput" mode="screen">
144 <xsl:choose>
145 <!-- Estandarized package formats -->
146 <xsl:when test="contains(string(),'tar.gz')">
147 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
148 <xsl:text>tar.*</xsl:text>
149 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
150 <xsl:text>&#xA;</xsl:text>
151 </xsl:when>
152 <!-- Avoiding a race condition in a patch -->
153 <xsl:when test="contains(string(),'debian_fixes')">
154 <xsl:value-of select="substring-before(string(),'patch')"/>
155 <xsl:text>patch -Z</xsl:text>
156 <xsl:value-of select="substring-after(string(),'patch')"/>
157 <xsl:text>&#xA;</xsl:text>
158 </xsl:when>
159 <!-- Setting $LANG for /etc/profile -->
160 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
161 contains(string(),'export LANG=')">
162 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
163 <xsl:text>export LANG=</xsl:text>
164 <xsl:value-of select="$lang"/>
165 <xsl:value-of select="substring-after(string(),'charmap]')"/>
166 <xsl:text>&#xA;</xsl:text>
167 </xsl:when>
[f4caf9c]168 <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
169 <xsl:when test="contains(string(),'defkeymap')"/>
[877cc6a]170 <!-- Copying the kernel config file -->
171 <xsl:when test="string() = 'make mrproper'">
172 <xsl:text>make mrproper&#xA;</xsl:text>
173 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
174 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
175 </xsl:if>
176 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
177 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
178 </xsl:if>
179 </xsl:when>
180 <!-- No interactive commands are needed if the .config file is the proper one -->
181 <xsl:when test="contains(string(),'menuconfig')"/>
182 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[a229600]183 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
[877cc6a]184 ancestor::sect1[@id='ch-system-module-init-tools']) and
185 (contains(string(),'check') or
[a229600]186 contains(string(),'dummy'))">
187 <xsl:choose>
188 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
189 <xsl:otherwise>
[28f4756]190 <xsl:if test="not(contains(string(),'check'))">
191 <xsl:apply-templates/>
192 <xsl:text>&#xA;</xsl:text>
193 </xsl:if>
[a229600]194 <xsl:if test="contains(string(),'check')">
[28f4756]195 <xsl:choose>
[401f81e]196 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]197 <xsl:value-of select="substring-before(string(),'check')"/>
198 <xsl:text>-k check</xsl:text>
199 <xsl:value-of select="substring-after(string(),'check')"/>
200 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
201 </xsl:when>
202 <xsl:otherwise>
203 <xsl:apply-templates/>
[3014928]204 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
[a1f1969]205 <xsl:if test="contains(string(),' -k ')">
206 <xsl:text> || true</xsl:text>
207 </xsl:if>
[f98695c]208 <xsl:text>&#xA;</xsl:text>
[28f4756]209 </xsl:otherwise>
210 </xsl:choose>
[a229600]211 </xsl:if>
212 </xsl:otherwise>
213 </xsl:choose>
214 </xsl:when>
[877cc6a]215 <!-- Fixing toolchain test suites run -->
216 <xsl:when test="string() = 'make check' or
217 string() = 'make -k check'">
218 <xsl:choose>
219 <xsl:when test="$testsuite != '0'">
[28f4756]220 <xsl:choose>
[401f81e]221 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]222 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
223 </xsl:when>
224 <xsl:otherwise>
225 <xsl:apply-templates/>
[a1f1969]226 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
227 <xsl:if test="contains(string(),' -k ')">
228 <xsl:text> || true</xsl:text>
229 </xsl:if>
230 <xsl:text>&#xA;</xsl:text>
[28f4756]231 </xsl:otherwise>
232 </xsl:choose>
[877cc6a]233 </xsl:when>
234 </xsl:choose>
235 </xsl:when>
236 <xsl:when test="contains(string(),'glibc-check-log')">
237 <xsl:choose>
238 <xsl:when test="$testsuite != '0'">
[a229600]239 <xsl:value-of select="substring-before(string(),'&gt;g')"/>
[28f4756]240 <xsl:choose>
[401f81e]241 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]242 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
243 </xsl:when>
244 <xsl:otherwise>
[a1f1969]245 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
246 <xsl:if test="contains(string(),' -k ')">
247 <xsl:text> || true</xsl:text>
248 </xsl:if>
249 <xsl:text>&#xA;</xsl:text>
[28f4756]250 </xsl:otherwise>
251 </xsl:choose>
[877cc6a]252 </xsl:when>
253 </xsl:choose>
254 </xsl:when>
255 <xsl:when test="contains(string(),'test_summary') or
256 contains(string(),'expect -c')">
257 <xsl:choose>
258 <xsl:when test="$testsuite != '0'">
259 <xsl:apply-templates/>
[28f4756]260 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
[877cc6a]261 </xsl:when>
262 </xsl:choose>
263 </xsl:when>
264 <!-- Don't stop on strip run -->
265 <xsl:when test="contains(string(),'strip ')">
266 <xsl:apply-templates/>
267 <xsl:text> || true&#xA;</xsl:text>
268 </xsl:when>
269 <!-- The rest of commands -->
270 <xsl:otherwise>
271 <xsl:apply-templates/>
272 <xsl:text>&#xA;</xsl:text>
273 </xsl:otherwise>
274 </xsl:choose>
275 </xsl:template>
276
277 <xsl:template match="replaceable">
278 <xsl:choose>
279 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
280 <xsl:value-of select="$timezone"/>
281 </xsl:when>
282 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
283 <xsl:value-of select="$page"/>
284 </xsl:when>
285 <xsl:otherwise>
286 <xsl:text>**EDITME</xsl:text>
287 <xsl:apply-templates/>
288 <xsl:text>EDITME**</xsl:text>
289 </xsl:otherwise>
290 </xsl:choose>
291 </xsl:template>
292
293</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.