source: CLFS2/clfs2.xsl@ 33c7b13

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

Begin coding against the CLFS-2.0 book

  • Property mode set to 100644
File size: 9.4 KB
RevLine 
[7432834]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="0"/>
28
29 <!-- Install vim-lang package? -->
30 <xsl:param name="vim-lang" select="1"/>
31
32 <!-- Time zone -->
33 <xsl:param name="timezone" select="GMT"/>
34
35 <!-- Page size -->
36 <xsl:param name="page" select="letter"/>
37
38 <!-- Locale settings -->
39 <xsl:param name="lang" select="C"/>
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:otherwise>
52 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
53 count(descendant::screen/userinput) &gt;
54 count(descendant::screen[@role='nodump'])">
55 <!-- The dirs names -->
56 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
57 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
58 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
59 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
60 <!-- The file names -->
61 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
62 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
63 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
64 <!-- The build order -->
65 <xsl:variable name="position" select="position()"/>
66 <xsl:variable name="order">
67 <xsl:choose>
68 <xsl:when test="string-length($position) = 1">
69 <xsl:text>00</xsl:text>
70 <xsl:value-of select="$position"/>
71 </xsl:when>
72 <xsl:when test="string-length($position) = 2">
73 <xsl:text>0</xsl:text>
74 <xsl:value-of select="$position"/>
75 </xsl:when>
76 <xsl:otherwise>
77 <xsl:value-of select="$position"/>
78 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:variable>
81 <!-- Creating dirs and files -->
82 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
83 <xsl:choose>
84 <xsl:when test="../@id='chapter-chroot'">
85 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
86 </xsl:when>
87 <xsl:when test="@id='ch-system-stripping'">
88 <xsl:text>#!/bin/sh&#xA;</xsl:text>
89 </xsl:when>
90 <xsl:otherwise>
91 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
92 </xsl:otherwise>
93 </xsl:choose>
94 <xsl:if test="sect2[@role='installation']">
95 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
96 <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
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')">
118 <xsl:value-of select="substring-before(string(),'make')"/>
119 <xsl:text>make -k</xsl:text>
120 <xsl:value-of select="substring-after(string(),'make')"/>
121 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
122 </xsl:if>
123 </xsl:template>
124
125 <xsl:template match="userinput" mode="screen">
126 <xsl:choose>
127 <!-- Estandarized package formats -->
128 <xsl:when test="contains(string(),'tar.gz')">
129 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
130 <xsl:text>tar.*</xsl:text>
131 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
132 <xsl:text>&#xA;</xsl:text>
133 </xsl:when>
134 <!-- Avoiding a race condition in a patch -->
135 <xsl:when test="contains(string(),'debian_fixes')">
136 <xsl:value-of select="substring-before(string(),'patch')"/>
137 <xsl:text>patch -Z</xsl:text>
138 <xsl:value-of select="substring-after(string(),'patch')"/>
139 <xsl:text>&#xA;</xsl:text>
140 </xsl:when>
141 <!-- Setting $LANG for /etc/profile -->
142 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
143 contains(string(),'export LANG=')">
144 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
145 <xsl:text>export LANG=</xsl:text>
146 <xsl:value-of select="$lang"/>
147 <xsl:value-of select="substring-after(string(),'charmap]')"/>
148 <xsl:text>&#xA;</xsl:text>
149 </xsl:when>
150 <!-- Compile the keymap into the kernel? -->
151 <xsl:when test="contains(string(),'defkeymap') and
152 $keymap = 'none'"/>
153 <!-- Copying the kernel config file -->
154 <xsl:when test="string() = 'make mrproper'">
155 <xsl:text>make mrproper&#xA;</xsl:text>
156 <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
157 <xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
158 </xsl:if>
159 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
160 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
161 </xsl:if>
162 </xsl:when>
163 <!-- No interactive commands are needed if the .config file is the proper one -->
164 <xsl:when test="contains(string(),'menuconfig')"/>
165 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
166 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
167 ancestor::sect1[@id='ch-system-module-init-tools']) and
168 (contains(string(),'check') or
169 contains(string(),'dummy'))">
170 <xsl:choose>
171 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
172 <xsl:otherwise>
173 <xsl:apply-templates/>
174 <xsl:if test="contains(string(),'check')">
175 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
176 </xsl:if>
177 <xsl:text>&#xA;</xsl:text>
178 </xsl:otherwise>
179 </xsl:choose>
180 </xsl:when>
181 <!-- Fixing toolchain test suites run -->
182 <xsl:when test="string() = 'make check' or
183 string() = 'make -k check'">
184 <xsl:choose>
185 <xsl:when test="$testsuite != '0'">
186 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
187 </xsl:when>
188 </xsl:choose>
189 </xsl:when>
190 <xsl:when test="contains(string(),'glibc-check-log')">
191 <xsl:choose>
192 <xsl:when test="$testsuite != '0'">
193 <xsl:value-of select="substring-before(string(),'&gt;g')"/>
194 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
195 </xsl:when>
196 </xsl:choose>
197 </xsl:when>
198 <xsl:when test="contains(string(),'test_summary') or
199 contains(string(),'expect -c')">
200 <xsl:choose>
201 <xsl:when test="$testsuite != '0'">
202 <xsl:apply-templates/>
203 <xsl:if test="contains(string(),'test_summary')">
204 <xsl:text> &gt;&gt; $TEST_LOG</xsl:text>
205 </xsl:if>
206 <xsl:text>&#xA;</xsl:text>
207 </xsl:when>
208 </xsl:choose>
209 </xsl:when>
210 <!-- Don't stop on strip run -->
211 <xsl:when test="contains(string(),'strip ')">
212 <xsl:apply-templates/>
213 <xsl:text> || true&#xA;</xsl:text>
214 </xsl:when>
215 <!-- The rest of commands -->
216 <xsl:otherwise>
217 <xsl:apply-templates/>
218 <xsl:text>&#xA;</xsl:text>
219 </xsl:otherwise>
220 </xsl:choose>
221 </xsl:template>
222
223 <xsl:template match="replaceable">
224 <xsl:choose>
225 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
226 <xsl:value-of select="$timezone"/>
227 </xsl:when>
228 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
229 <xsl:value-of select="$page"/>
230 </xsl:when>
231 <xsl:when test="ancestor::sect1[@id='ch-boot-kernel'] or
232 ancestor::sect1[@id='ch-bootable-kernel']">
233 <xsl:value-of select="$keymap"/>
234 </xsl:when>
235 <xsl:otherwise>
236 <xsl:text>**EDITME</xsl:text>
237 <xsl:apply-templates/>
238 <xsl:text>EDITME**</xsl:text>
239 </xsl:otherwise>
240 </xsl:choose>
241 </xsl:template>
242
243</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.