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 LFS books. -->
|
---|
15 |
|
---|
16 | <!-- Run test suites?
|
---|
17 | 0 = none
|
---|
18 | 1 = only chapter06 Glibc, GCC and Binutils testsuites
|
---|
19 | 2 = all chapter06 testsuites
|
---|
20 | 3 = all chapter05 and chapter06 testsuites-->
|
---|
21 | <xsl:param name="testsuite" select="1"/>
|
---|
22 |
|
---|
23 | <!-- Install vim-lang package? -->
|
---|
24 | <xsl:param name="vim-lang" select="1"/>
|
---|
25 |
|
---|
26 | <xsl:template match="/">
|
---|
27 | <xsl:apply-templates select="//sect1"/>
|
---|
28 | </xsl:template>
|
---|
29 |
|
---|
30 | <xsl:template match="sect1">
|
---|
31 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
32 | count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
---|
33 | <!-- The dirs names -->
|
---|
34 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
35 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
36 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
37 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
38 | <!-- The file names -->
|
---|
39 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
40 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
41 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
42 | <!-- The build order -->
|
---|
43 | <xsl:variable name="position" select="position()"/>
|
---|
44 | <xsl:variable name="order">
|
---|
45 | <xsl:choose>
|
---|
46 | <xsl:when test="string-length($position) = 1">
|
---|
47 | <xsl:text>00</xsl:text>
|
---|
48 | <xsl:value-of select="$position"/>
|
---|
49 | </xsl:when>
|
---|
50 | <xsl:when test="string-length($position) = 2">
|
---|
51 | <xsl:text>0</xsl:text>
|
---|
52 | <xsl:value-of select="$position"/>
|
---|
53 | </xsl:when>
|
---|
54 | <xsl:otherwise>
|
---|
55 | <xsl:value-of select="$position"/>
|
---|
56 | </xsl:otherwise>
|
---|
57 | </xsl:choose>
|
---|
58 | </xsl:variable>
|
---|
59 | <!-- Creating dirs and files -->
|
---|
60 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
61 | <xsl:choose>
|
---|
62 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
63 | @id='ch-system-creatingdirs' or
|
---|
64 | @id='ch-system-createfiles'">
|
---|
65 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
66 | </xsl:when>
|
---|
67 | <xsl:when test="@id='ch-tools-stripping' or
|
---|
68 | @id='ch-system-strippingagain'">
|
---|
69 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
70 | </xsl:when>
|
---|
71 | <xsl:otherwise>
|
---|
72 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
73 | </xsl:otherwise>
|
---|
74 | </xsl:choose>
|
---|
75 | <xsl:if test="sect2[@role='installation']">
|
---|
76 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
77 | <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
|
---|
78 | <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
---|
79 | </xsl:if>
|
---|
80 | </xsl:if>
|
---|
81 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
82 | <xsl:if test="$testsuite='3' and @id='ch-tools-glibc'">
|
---|
83 | <xsl:copy-of select="//sect1[@id='ch-system-glibc']/sect2[2]/screen[@role='nodump']"/>
|
---|
84 | <xsl:text>
</xsl:text>
|
---|
85 | </xsl:if>
|
---|
86 | <xsl:text>exit</xsl:text>
|
---|
87 | </exsl:document>
|
---|
88 | </xsl:if>
|
---|
89 | </xsl:template>
|
---|
90 |
|
---|
91 | <xsl:template match="screen">
|
---|
92 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
93 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
94 | </xsl:if>
|
---|
95 | </xsl:template>
|
---|
96 |
|
---|
97 | <xsl:template match="para/userinput">
|
---|
98 | <xsl:if test="(contains(string(),'test') or
|
---|
99 | contains(string(),'check')) and
|
---|
100 | (($testsuite = '2' and
|
---|
101 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
102 | $testsuite = '3')">
|
---|
103 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
104 | <xsl:text>make -k</xsl:text>
|
---|
105 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
106 | <xsl:text> || true
</xsl:text>
|
---|
107 | </xsl:if>
|
---|
108 | </xsl:template>
|
---|
109 |
|
---|
110 | <xsl:template match="userinput" mode="screen">
|
---|
111 | <xsl:choose>
|
---|
112 | <!-- Estandarized package formats -->
|
---|
113 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
114 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
115 | <xsl:text>tar.*</xsl:text>
|
---|
116 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
117 | <xsl:text>
</xsl:text>
|
---|
118 | </xsl:when>
|
---|
119 | <!-- Avoiding a race condition in a patch -->
|
---|
120 | <xsl:when test="contains(string(),'debian_fixes')">
|
---|
121 | <xsl:value-of select="substring-before(string(),'patch')"/>
|
---|
122 | <xsl:text>patch -Z</xsl:text>
|
---|
123 | <xsl:value-of select="substring-after(string(),'patch')"/>
|
---|
124 | <xsl:text>
</xsl:text>
|
---|
125 | </xsl:when>
|
---|
126 | <!-- Setting $LANG for /etc/profile -->
|
---|
127 | <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
|
---|
128 | contains(string(),'export LANG=')">
|
---|
129 | <xsl:value-of select="substring-before(string(),'export LANG=')"/>
|
---|
130 | <xsl:text>export LANG=$LANG</xsl:text>
|
---|
131 | <xsl:value-of select="substring-after(string(),'modifiers]')"/>
|
---|
132 | <xsl:text>
</xsl:text>
|
---|
133 | </xsl:when>
|
---|
134 | <!-- Copying the kernel config file -->
|
---|
135 | <xsl:when test="string() = 'make mrproper'">
|
---|
136 | <xsl:text>make mrproper
</xsl:text>
|
---|
137 | <xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
---|
138 | </xsl:when>
|
---|
139 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
140 | <xsl:when test="($testsuite = '0' or $testsuite = '1') and
|
---|
141 | (ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
142 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
143 | (contains(string(),'check') or
|
---|
144 | contains(string(),'dummy'))"/>
|
---|
145 | <!-- Fixing toolchain test suites run -->
|
---|
146 | <xsl:when test="string() = 'make check' or
|
---|
147 | string() = 'make -k check'">
|
---|
148 | <xsl:choose>
|
---|
149 | <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
|
---|
150 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
151 | $testsuite = '3'">
|
---|
152 | <xsl:text>make -k check || true</xsl:text>
|
---|
153 | <xsl:text>
</xsl:text>
|
---|
154 | </xsl:when>
|
---|
155 | </xsl:choose>
|
---|
156 | </xsl:when>
|
---|
157 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
158 | <xsl:choose>
|
---|
159 | <xsl:when test="$testsuite != '0'">
|
---|
160 | <xsl:value-of select="substring-before(string(),'
')"/>
|
---|
161 | <xsl:text> || true
</xsl:text>
|
---|
162 | <xsl:value-of select="substring-after(string(),'
')"/>
|
---|
163 | <xsl:text>
</xsl:text>
|
---|
164 | </xsl:when>
|
---|
165 | </xsl:choose>
|
---|
166 | </xsl:when>
|
---|
167 | <xsl:when test="contains(string(),'test_summary') or
|
---|
168 | contains(string(),'expect -c')">
|
---|
169 | <xsl:choose>
|
---|
170 | <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
|
---|
171 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
172 | $testsuite = '3'">
|
---|
173 | <xsl:apply-templates/>
|
---|
174 | <xsl:text>
</xsl:text>
|
---|
175 | </xsl:when>
|
---|
176 | </xsl:choose>
|
---|
177 | </xsl:when>
|
---|
178 | <!-- Don't stop on strip run -->
|
---|
179 | <xsl:when test="contains(string(),'strip ')">
|
---|
180 | <xsl:apply-templates/>
|
---|
181 | <xsl:text> || true
</xsl:text>
|
---|
182 | </xsl:when>
|
---|
183 | <!-- The rest of commands -->
|
---|
184 | <xsl:otherwise>
|
---|
185 | <xsl:apply-templates/>
|
---|
186 | <xsl:text>
</xsl:text>
|
---|
187 | </xsl:otherwise>
|
---|
188 | </xsl:choose>
|
---|
189 | </xsl:template>
|
---|
190 |
|
---|
191 | <xsl:template match="replaceable">
|
---|
192 | <xsl:choose>
|
---|
193 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
194 | <xsl:text>$TIMEZONE</xsl:text>
|
---|
195 | </xsl:when>
|
---|
196 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
197 | <xsl:text>$PAGE</xsl:text>
|
---|
198 | </xsl:when>
|
---|
199 | <xsl:otherwise>
|
---|
200 | <xsl:text>**EDITME</xsl:text>
|
---|
201 | <xsl:apply-templates/>
|
---|
202 | <xsl:text>EDITME**</xsl:text>
|
---|
203 | </xsl:otherwise>
|
---|
204 | </xsl:choose>
|
---|
205 | </xsl:template>
|
---|
206 |
|
---|
207 | </xsl:stylesheet>
|
---|