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 | <!-- No interactive commands are needed if the .config file is the proper one -->
|
---|
166 | <xsl:when test="contains(string(),'menuconfig')"/>
|
---|
167 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
168 | <xsl:when test="($testsuite = '0' or $testsuite = '1') and
|
---|
169 | (ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
170 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
171 | (contains(string(),'check') or
|
---|
172 | contains(string(),'dummy'))"/>
|
---|
173 | <!-- Fixing toolchain test suites run -->
|
---|
174 | <xsl:when test="string() = 'make check' or
|
---|
175 | string() = 'make -k check'">
|
---|
176 | <xsl:choose>
|
---|
177 | <xsl:when test="$testsuite != '0'">
|
---|
178 | <xsl:text>make -k check || true
</xsl:text>
|
---|
179 | </xsl:when>
|
---|
180 | </xsl:choose>
|
---|
181 | </xsl:when>
|
---|
182 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
183 | <xsl:choose>
|
---|
184 | <xsl:when test="$testsuite != '0'">
|
---|
185 | <xsl:value-of select="substring-before(string(),';')"/>
|
---|
186 | <xsl:text> || true
</xsl:text>
|
---|
187 | <xsl:value-of select="substring-after(string(),';')"/>
|
---|
188 | <xsl:text>
</xsl:text>
|
---|
189 | </xsl:when>
|
---|
190 | </xsl:choose>
|
---|
191 | </xsl:when>
|
---|
192 | <xsl:when test="contains(string(),'test_summary') or
|
---|
193 | contains(string(),'expect -c')">
|
---|
194 | <xsl:choose>
|
---|
195 | <xsl:when test="$testsuite != '0'">
|
---|
196 | <xsl:apply-templates/>
|
---|
197 | <xsl:text>
</xsl:text>
|
---|
198 | </xsl:when>
|
---|
199 | </xsl:choose>
|
---|
200 | </xsl:when>
|
---|
201 | <!-- Don't stop on strip run -->
|
---|
202 | <xsl:when test="contains(string(),'strip ')">
|
---|
203 | <xsl:apply-templates/>
|
---|
204 | <xsl:text> || true
</xsl:text>
|
---|
205 | </xsl:when>
|
---|
206 | <!-- The rest of commands -->
|
---|
207 | <xsl:otherwise>
|
---|
208 | <xsl:apply-templates/>
|
---|
209 | <xsl:text>
</xsl:text>
|
---|
210 | </xsl:otherwise>
|
---|
211 | </xsl:choose>
|
---|
212 | </xsl:template>
|
---|
213 |
|
---|
214 | <xsl:template match="replaceable">
|
---|
215 | <xsl:choose>
|
---|
216 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
217 | <xsl:value-of select="$timezone"/>
|
---|
218 | </xsl:when>
|
---|
219 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
220 | <xsl:value-of select="$page"/>
|
---|
221 | </xsl:when>
|
---|
222 | <xsl:otherwise>
|
---|
223 | <xsl:text>**EDITME</xsl:text>
|
---|
224 | <xsl:apply-templates/>
|
---|
225 | <xsl:text>EDITME**</xsl:text>
|
---|
226 | </xsl:otherwise>
|
---|
227 | </xsl:choose>
|
---|
228 | </xsl:template>
|
---|
229 |
|
---|
230 | </xsl:stylesheet>
|
---|