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 | <!-- 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 -->
|
---|
33 | <xsl:param name="timezone" select="America/Toronto"/>
|
---|
34 |
|
---|
35 | <!-- Page size -->
|
---|
36 | <xsl:param name="page" select="letter"/>
|
---|
37 |
|
---|
38 | <!-- Locale settings -->
|
---|
39 | <xsl:param name="lang" select="en_CA"/>
|
---|
40 |
|
---|
41 | <xsl:template match="/">
|
---|
42 | <xsl:apply-templates select="//sect1"/>
|
---|
43 | </xsl:template>
|
---|
44 |
|
---|
45 | <xsl:template match="sect1">
|
---|
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) > 0 and
|
---|
55 | count(descendant::screen/userinput) >
|
---|
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
set -e

</xsl:text>
|
---|
88 | </xsl:when>
|
---|
89 | <xsl:when test="@id='ch-system-stripping'">
|
---|
90 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
91 | </xsl:when>
|
---|
92 | <xsl:otherwise>
|
---|
93 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
94 | </xsl:otherwise>
|
---|
95 | </xsl:choose>
|
---|
96 | <xsl:if test="sect2[@role='installation']">
|
---|
97 | <xsl:text>cd $PKGDIR
</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
</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>
|
---|
108 | </xsl:template>
|
---|
109 |
|
---|
110 | <xsl:template match="screen">
|
---|
111 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
112 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
113 | </xsl:if>
|
---|
114 | </xsl:template>
|
---|
115 |
|
---|
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')"/>
|
---|
123 | <xsl:text> || true
</xsl:text>
|
---|
124 | </xsl:if>
|
---|
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>
</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>
</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"/>
|
---|
149 | <xsl:value-of select="substring-after(string(),'modifiers]')"/>
|
---|
150 | <xsl:text>
</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
</xsl:text>
|
---|
158 | <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
|
---|
159 | <xsl:text>cp -v ../bootkernel-config .config
</xsl:text>
|
---|
160 | </xsl:if>
|
---|
161 | <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
|
---|
162 | <xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
---|
163 | </xsl:if>
|
---|
164 | </xsl:when>
|
---|
165 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
166 | <xsl:when test="($testsuite = '0' or $testsuite = '1') and
|
---|
167 | (ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
168 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
169 | (contains(string(),'check') or
|
---|
170 | contains(string(),'dummy'))"/>
|
---|
171 | <!-- Fixing toolchain test suites run -->
|
---|
172 | <xsl:when test="string() = 'make check' or
|
---|
173 | string() = 'make -k check'">
|
---|
174 | <xsl:choose>
|
---|
175 | <xsl:when test="$testsuite != '0'">
|
---|
176 | <xsl:text>make -k check || true
</xsl:text>
|
---|
177 | </xsl:when>
|
---|
178 | </xsl:choose>
|
---|
179 | </xsl:when>
|
---|
180 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
181 | <xsl:choose>
|
---|
182 | <xsl:when test="$testsuite != '0'">
|
---|
183 | <xsl:value-of select="substring-before(string(),';')"/>
|
---|
184 | <xsl:text> || true
</xsl:text>
|
---|
185 | <xsl:value-of select="substring-after(string(),';')"/>
|
---|
186 | <xsl:text>
</xsl:text>
|
---|
187 | </xsl:when>
|
---|
188 | </xsl:choose>
|
---|
189 | </xsl:when>
|
---|
190 | <xsl:when test="contains(string(),'test_summary') or
|
---|
191 | contains(string(),'expect -c')">
|
---|
192 | <xsl:choose>
|
---|
193 | <xsl:when test="$testsuite != '0'">
|
---|
194 | <xsl:apply-templates/>
|
---|
195 | <xsl:text>
</xsl:text>
|
---|
196 | </xsl:when>
|
---|
197 | </xsl:choose>
|
---|
198 | </xsl:when>
|
---|
199 | <!-- Don't stop on strip run -->
|
---|
200 | <xsl:when test="contains(string(),'strip ')">
|
---|
201 | <xsl:apply-templates/>
|
---|
202 | <xsl:text> || true
</xsl:text>
|
---|
203 | </xsl:when>
|
---|
204 | <!-- The rest of commands -->
|
---|
205 | <xsl:otherwise>
|
---|
206 | <xsl:apply-templates/>
|
---|
207 | <xsl:text>
</xsl:text>
|
---|
208 | </xsl:otherwise>
|
---|
209 | </xsl:choose>
|
---|
210 | </xsl:template>
|
---|
211 |
|
---|
212 | <xsl:template match="replaceable">
|
---|
213 | <xsl:choose>
|
---|
214 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
215 | <xsl:value-of select="$timezone"/>
|
---|
216 | </xsl:when>
|
---|
217 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
218 | <xsl:value-of select="$page"/>
|
---|
219 | </xsl:when>
|
---|
220 | <xsl:otherwise>
|
---|
221 | <xsl:text>**EDITME</xsl:text>
|
---|
222 | <xsl:apply-templates/>
|
---|
223 | <xsl:text>EDITME**</xsl:text>
|
---|
224 | </xsl:otherwise>
|
---|
225 | </xsl:choose>
|
---|
226 | </xsl:template>
|
---|
227 |
|
---|
228 | </xsl:stylesheet>
|
---|