source: LFS/lfs.xsl@ ad71d98

experimental
Last change on this file since ad71d98 was ad71d98, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Set the actual TIMEZONE and PAGE values inside the generated scripts instead of exported envars.

  • Property mode set to 100644
File size: 8.3 KB
Line 
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 <!-- Time zone -->
27 <xsl:param name="timezone" select="America/Toronto"/>
28
29 <!-- Page size -->
30 <xsl:param name="page" select="letter"/>
31
32 <xsl:template match="/">
33 <xsl:apply-templates select="//sect1"/>
34 </xsl:template>
35
36 <xsl:template match="sect1">
37 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
38 count(descendant::screen/userinput) &gt; count(descendant::screen[@role='nodump'])">
39 <!-- The dirs names -->
40 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
41 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
42 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
43 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
44 <!-- The file names -->
45 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
46 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
47 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
48 <!-- The build order -->
49 <xsl:variable name="position" select="position()"/>
50 <xsl:variable name="order">
51 <xsl:choose>
52 <xsl:when test="string-length($position) = 1">
53 <xsl:text>00</xsl:text>
54 <xsl:value-of select="$position"/>
55 </xsl:when>
56 <xsl:when test="string-length($position) = 2">
57 <xsl:text>0</xsl:text>
58 <xsl:value-of select="$position"/>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:value-of select="$position"/>
62 </xsl:otherwise>
63 </xsl:choose>
64 </xsl:variable>
65 <!-- Creating dirs and files -->
66 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
67 <xsl:choose>
68 <xsl:when test="@id='ch-system-changingowner' or
69 @id='ch-system-creatingdirs' or
70 @id='ch-system-createfiles'">
71 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
72 </xsl:when>
73 <xsl:when test="@id='ch-tools-stripping' or
74 @id='ch-system-strippingagain'">
75 <xsl:text>#!/bin/sh&#xA;</xsl:text>
76 </xsl:when>
77 <xsl:otherwise>
78 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
79 </xsl:otherwise>
80 </xsl:choose>
81 <xsl:if test="sect2[@role='installation']">
82 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
83 <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
84 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
85 </xsl:if>
86 </xsl:if>
87 <xsl:apply-templates select=".//para/userinput | .//screen"/>
88 <xsl:if test="$testsuite='3' and @id='ch-tools-glibc'">
89 <xsl:copy-of select="//sect1[@id='ch-system-glibc']/sect2[2]/screen[@role='nodump']"/>
90 <xsl:text>&#xA;</xsl:text>
91 </xsl:if>
92 <xsl:text>exit</xsl:text>
93 </exsl:document>
94 </xsl:if>
95 </xsl:template>
96
97 <xsl:template match="screen">
98 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
99 <xsl:apply-templates select="userinput" mode="screen"/>
100 </xsl:if>
101 </xsl:template>
102
103 <xsl:template match="para/userinput">
104 <xsl:if test="(contains(string(),'test') or
105 contains(string(),'check')) and
106 (($testsuite = '2' and
107 ancestor::chapter[@id='chapter-building-system']) or
108 $testsuite = '3')">
109 <xsl:value-of select="substring-before(string(),'make')"/>
110 <xsl:text>make -k</xsl:text>
111 <xsl:value-of select="substring-after(string(),'make')"/>
112 <xsl:text> || true&#xA;</xsl:text>
113 </xsl:if>
114 </xsl:template>
115
116 <xsl:template match="userinput" mode="screen">
117 <xsl:choose>
118 <!-- Estandarized package formats -->
119 <xsl:when test="contains(string(),'tar.gz')">
120 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
121 <xsl:text>tar.*</xsl:text>
122 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
123 <xsl:text>&#xA;</xsl:text>
124 </xsl:when>
125 <!-- Avoiding a race condition in a patch -->
126 <xsl:when test="contains(string(),'debian_fixes')">
127 <xsl:value-of select="substring-before(string(),'patch')"/>
128 <xsl:text>patch -Z</xsl:text>
129 <xsl:value-of select="substring-after(string(),'patch')"/>
130 <xsl:text>&#xA;</xsl:text>
131 </xsl:when>
132 <!-- Setting $LANG for /etc/profile -->
133 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
134 contains(string(),'export LANG=')">
135 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
136 <xsl:text>export LANG=$LANG</xsl:text>
137 <xsl:value-of select="substring-after(string(),'modifiers]')"/>
138 <xsl:text>&#xA;</xsl:text>
139 </xsl:when>
140 <!-- Copying the kernel config file -->
141 <xsl:when test="string() = 'make mrproper'">
142 <xsl:text>make mrproper&#xA;</xsl:text>
143 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
144 </xsl:when>
145 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
146 <xsl:when test="($testsuite = '0' or $testsuite = '1') and
147 (ancestor::sect1[@id='ch-system-coreutils'] or
148 ancestor::sect1[@id='ch-system-module-init-tools']) and
149 (contains(string(),'check') or
150 contains(string(),'dummy'))"/>
151 <!-- Fixing toolchain test suites run -->
152 <xsl:when test="string() = 'make check' or
153 string() = 'make -k check'">
154 <xsl:choose>
155 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
156 ancestor::chapter[@id='chapter-building-system']) or
157 $testsuite = '3'">
158 <xsl:text>make -k check || true</xsl:text>
159 <xsl:text>&#xA;</xsl:text>
160 </xsl:when>
161 </xsl:choose>
162 </xsl:when>
163 <xsl:when test="contains(string(),'glibc-check-log')">
164 <xsl:choose>
165 <xsl:when test="$testsuite != '0'">
166 <xsl:value-of select="substring-before(string(),'&#xA;')"/>
167 <xsl:text> || true&#xA;</xsl:text>
168 <xsl:value-of select="substring-after(string(),'&#xA;')"/>
169 <xsl:text>&#xA;</xsl:text>
170 </xsl:when>
171 </xsl:choose>
172 </xsl:when>
173 <xsl:when test="contains(string(),'test_summary') or
174 contains(string(),'expect -c')">
175 <xsl:choose>
176 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
177 ancestor::chapter[@id='chapter-building-system']) or
178 $testsuite = '3'">
179 <xsl:apply-templates/>
180 <xsl:text>&#xA;</xsl:text>
181 </xsl:when>
182 </xsl:choose>
183 </xsl:when>
184 <!-- Don't stop on strip run -->
185 <xsl:when test="contains(string(),'strip ')">
186 <xsl:apply-templates/>
187 <xsl:text> || true&#xA;</xsl:text>
188 </xsl:when>
189 <!-- The rest of commands -->
190 <xsl:otherwise>
191 <xsl:apply-templates/>
192 <xsl:text>&#xA;</xsl:text>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:template>
196
197 <xsl:template match="replaceable">
198 <xsl:choose>
199 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
200 <xsl:value-of select="$timezone"/>
201 </xsl:when>
202 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
203 <xsl:value-of select="$page"/>
204 </xsl:when>
205 <xsl:otherwise>
206 <xsl:text>**EDITME</xsl:text>
207 <xsl:apply-templates/>
208 <xsl:text>EDITME**</xsl:text>
209 </xsl:otherwise>
210 </xsl:choose>
211 </xsl:template>
212
213</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.