source: CLFS/clfs.xsl@ ac35c8e

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since ac35c8e was 5f4982d, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Simplified sha-bang addition.
We are creating the /bin/bash symlink before entering to the chroot jail.

  • Property mode set to 100644
File size: 11.2 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">
[5f4982d]89 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
90 <xsl:if test="not(@id='ch-system-stripping')">
91 <xsl:text>set -e</xsl:text>
92 </xsl:if>
93 <xsl:text>&#xA;</xsl:text>
[877cc6a]94 <xsl:if test="sect2[@role='installation']">
95 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
[401f81e]96 <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
[877cc6a]97 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
98 </xsl:if>
99 </xsl:if>
100 <xsl:apply-templates select=".//para/userinput | .//screen"/>
101 <xsl:text>exit</xsl:text>
102 </exsl:document>
103 </xsl:if>
104 </xsl:otherwise>
105 </xsl:choose>
106 </xsl:template>
107
108 <xsl:template match="screen">
109 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
110 <xsl:apply-templates select="userinput" mode="screen"/>
111 </xsl:if>
112 </xsl:template>
113
114 <xsl:template match="para/userinput">
115 <xsl:if test="(contains(string(),'test') or
116 contains(string(),'check')) and
117 ($testsuite = '2' or $testsuite = '3')">
[28f4756]118 <xsl:choose>
[401f81e]119 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]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')"/>
123 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
124 </xsl:when>
125 <xsl:otherwise>
126 <xsl:apply-templates/>
[a1f1969]127 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
128 <xsl:if test="contains(string(),' -k ')">
129 <xsl:text> || true</xsl:text>
130 </xsl:if>
131 <xsl:text>&#xA;</xsl:text>
[28f4756]132 </xsl:otherwise>
133 </xsl:choose>
[877cc6a]134 </xsl:if>
135 </xsl:template>
136
137 <xsl:template match="userinput" mode="screen">
138 <xsl:choose>
139 <!-- Estandarized package formats -->
140 <xsl:when test="contains(string(),'tar.gz')">
141 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
142 <xsl:text>tar.*</xsl:text>
143 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
144 <xsl:text>&#xA;</xsl:text>
145 </xsl:when>
146 <!-- Avoiding a race condition in a patch -->
147 <xsl:when test="contains(string(),'debian_fixes')">
148 <xsl:value-of select="substring-before(string(),'patch')"/>
149 <xsl:text>patch -Z</xsl:text>
150 <xsl:value-of select="substring-after(string(),'patch')"/>
151 <xsl:text>&#xA;</xsl:text>
152 </xsl:when>
153 <!-- Setting $LANG for /etc/profile -->
154 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
155 contains(string(),'export LANG=')">
156 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
157 <xsl:text>export LANG=</xsl:text>
158 <xsl:value-of select="$lang"/>
159 <xsl:value-of select="substring-after(string(),'charmap]')"/>
160 <xsl:text>&#xA;</xsl:text>
161 </xsl:when>
[f4caf9c]162 <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
163 <xsl:when test="contains(string(),'defkeymap')"/>
[877cc6a]164 <!-- Copying the kernel config file -->
165 <xsl:when test="string() = 'make mrproper'">
166 <xsl:text>make mrproper&#xA;</xsl:text>
167 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
168 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
169 </xsl:if>
170 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
171 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
172 </xsl:if>
173 </xsl:when>
174 <!-- No interactive commands are needed if the .config file is the proper one -->
175 <xsl:when test="contains(string(),'menuconfig')"/>
176 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[a229600]177 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
[877cc6a]178 ancestor::sect1[@id='ch-system-module-init-tools']) and
179 (contains(string(),'check') or
[a229600]180 contains(string(),'dummy'))">
181 <xsl:choose>
182 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
183 <xsl:otherwise>
[28f4756]184 <xsl:if test="not(contains(string(),'check'))">
185 <xsl:apply-templates/>
186 <xsl:text>&#xA;</xsl:text>
187 </xsl:if>
[a229600]188 <xsl:if test="contains(string(),'check')">
[28f4756]189 <xsl:choose>
[401f81e]190 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]191 <xsl:value-of select="substring-before(string(),'check')"/>
192 <xsl:text>-k check</xsl:text>
193 <xsl:value-of select="substring-after(string(),'check')"/>
194 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
195 </xsl:when>
196 <xsl:otherwise>
197 <xsl:apply-templates/>
[3014928]198 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
[a1f1969]199 <xsl:if test="contains(string(),' -k ')">
200 <xsl:text> || true</xsl:text>
201 </xsl:if>
[f98695c]202 <xsl:text>&#xA;</xsl:text>
[28f4756]203 </xsl:otherwise>
204 </xsl:choose>
[a229600]205 </xsl:if>
206 </xsl:otherwise>
207 </xsl:choose>
208 </xsl:when>
[877cc6a]209 <!-- Fixing toolchain test suites run -->
210 <xsl:when test="string() = 'make check' or
211 string() = 'make -k check'">
212 <xsl:choose>
213 <xsl:when test="$testsuite != '0'">
[28f4756]214 <xsl:choose>
[401f81e]215 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]216 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
217 </xsl:when>
218 <xsl:otherwise>
219 <xsl:apply-templates/>
[a1f1969]220 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
221 <xsl:if test="contains(string(),' -k ')">
222 <xsl:text> || true</xsl:text>
223 </xsl:if>
224 <xsl:text>&#xA;</xsl:text>
[28f4756]225 </xsl:otherwise>
226 </xsl:choose>
[877cc6a]227 </xsl:when>
228 </xsl:choose>
229 </xsl:when>
230 <xsl:when test="contains(string(),'glibc-check-log')">
231 <xsl:choose>
232 <xsl:when test="$testsuite != '0'">
[a229600]233 <xsl:value-of select="substring-before(string(),'&gt;g')"/>
[28f4756]234 <xsl:choose>
[401f81e]235 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]236 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
237 </xsl:when>
238 <xsl:otherwise>
[a1f1969]239 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
240 <xsl:if test="contains(string(),' -k ')">
241 <xsl:text> || true</xsl:text>
242 </xsl:if>
243 <xsl:text>&#xA;</xsl:text>
[28f4756]244 </xsl:otherwise>
245 </xsl:choose>
[877cc6a]246 </xsl:when>
247 </xsl:choose>
248 </xsl:when>
249 <xsl:when test="contains(string(),'test_summary') or
250 contains(string(),'expect -c')">
251 <xsl:choose>
252 <xsl:when test="$testsuite != '0'">
253 <xsl:apply-templates/>
[28f4756]254 <xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
[877cc6a]255 </xsl:when>
256 </xsl:choose>
257 </xsl:when>
258 <!-- Don't stop on strip run -->
259 <xsl:when test="contains(string(),'strip ')">
260 <xsl:apply-templates/>
261 <xsl:text> || true&#xA;</xsl:text>
262 </xsl:when>
263 <!-- The rest of commands -->
264 <xsl:otherwise>
265 <xsl:apply-templates/>
266 <xsl:text>&#xA;</xsl:text>
267 </xsl:otherwise>
268 </xsl:choose>
269 </xsl:template>
270
271 <xsl:template match="replaceable">
272 <xsl:choose>
273 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
274 <xsl:value-of select="$timezone"/>
275 </xsl:when>
276 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
277 <xsl:value-of select="$page"/>
278 </xsl:when>
279 <xsl:otherwise>
280 <xsl:text>**EDITME</xsl:text>
281 <xsl:apply-templates/>
282 <xsl:text>EDITME**</xsl:text>
283 </xsl:otherwise>
284 </xsl:choose>
285 </xsl:template>
286
287</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.