source: LFS/lfs.xsl@ ca0ac30

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

Typo

  • Property mode set to 100644
File size: 8.1 KB
RevLine 
[0170229]1<?xml version="1.0"?>
2<!DOCTYPE xsl:stylesheet [
3 <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
4 %general-entities;
5]>
6
[3a5c9cc]7<!-- $Id$ -->
8
[0170229]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
[6db1464]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"/>
[0170229]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) &gt; 0 and
32 count(descendant::screen/userinput) &gt; 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&#xA;set -e&#xA;&#xA;</xsl:text>
66 </xsl:when>
67 <xsl:when test="@id='ch-tools-stripping' or
68 @id='ch-system-strippingagain'">
69 <xsl:text>#!/bin/sh&#xA;</xsl:text>
70 </xsl:when>
71 <xsl:otherwise>
72 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
73 </xsl:otherwise>
74 </xsl:choose>
[3a5c9cc]75 <xsl:if test="sect2[@role='installation']">
[0170229]76 <xsl:text>cd $PKGDIR&#xA;</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&#xA;</xsl:text>
79 </xsl:if>
80 </xsl:if>
81 <xsl:apply-templates select=".//para/userinput | .//screen"/>
[6db1464]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>&#xA;</xsl:text>
85 </xsl:if>
[0170229]86 <xsl:text>exit</xsl:text>
87 </exsl:document>
88 </xsl:if>
89 </xsl:template>
90
91 <xsl:template match="screen">
[6db1464]92 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
93 <xsl:apply-templates select="userinput" mode="screen"/>
[0170229]94 </xsl:if>
95 </xsl:template>
96
97 <xsl:template match="para/userinput">
[6db1464]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')">
[0170229]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&#xA;</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>&#xA;</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>&#xA;</xsl:text>
125 </xsl:when>
[aab51df]126 <!-- Setting $LANG for /etc/profile -->
[dd810ea]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>&#xA;</xsl:text>
133 </xsl:when>
[0170229]134 <!-- Copying the kernel config file -->
135 <xsl:when test="string() = 'make mrproper'">
136 <xsl:text>make mrproper&#xA;</xsl:text>
137 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
138 </xsl:when>
139 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[6db1464]140 <xsl:when test="($testsuite = '0' or $testsuite = '1') and
[0170229]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>
[6db1464]149 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
150 ancestor::chapter[@id='chapter-building-system']) or
151 $testsuite = '3'">
[0170229]152 <xsl:text>make -k check || true</xsl:text>
153 <xsl:text>&#xA;</xsl:text>
[6db1464]154 </xsl:when>
[0170229]155 </xsl:choose>
156 </xsl:when>
157 <xsl:when test="contains(string(),'glibc-check-log')">
158 <xsl:choose>
[6db1464]159 <xsl:when test="$testsuite != '0'">
[0170229]160 <xsl:value-of select="substring-before(string(),'&#xA;')"/>
161 <xsl:text> || true&#xA;</xsl:text>
162 <xsl:value-of select="substring-after(string(),'&#xA;')"/>
163 <xsl:text>&#xA;</xsl:text>
[6db1464]164 </xsl:when>
[0170229]165 </xsl:choose>
166 </xsl:when>
167 <xsl:when test="contains(string(),'test_summary') or
168 contains(string(),'expect -c')">
169 <xsl:choose>
[6db1464]170 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
171 ancestor::chapter[@id='chapter-building-system']) or
172 $testsuite = '3'">
[0170229]173 <xsl:apply-templates/>
174 <xsl:text>&#xA;</xsl:text>
[6db1464]175 </xsl:when>
[0170229]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&#xA;</xsl:text>
182 </xsl:when>
183 <!-- The rest of commands -->
184 <xsl:otherwise>
185 <xsl:apply-templates/>
186 <xsl:text>&#xA;</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>
Note: See TracBrowser for help on using the repository browser.