source: LFS/lfs.xsl@ 694351a

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

Test

  • Property mode set to 100644
File size: 7.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$Id$
9
10<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11 xmlns:exsl="http://exslt.org/common"
12 extension-element-prefixes="exsl"
13 version="1.0">
14
15<!-- XSLT stylesheet to create shell scripts from LFS books. -->
16
17 <!-- Run optional test suites? -->
18 <xsl:param name="testsuite" select="0"/>
19
20 <!-- Run toolchain test suites? -->
21 <xsl:param name="toolchaintest" 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) &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>
75 <xsl:if test="sect2[@role='installation']">
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"/>
82 <xsl:text>exit</xsl:text>
83 </exsl:document>
84 </xsl:if>
85 </xsl:template>
86
87 <xsl:template match="screen">
88 <xsl:if test="child::* = userinput">
89 <xsl:choose>
90 <xsl:when test="@role = 'nodump'"/>
91 <xsl:otherwise>
92 <xsl:apply-templates select="userinput" mode="screen"/>
93 </xsl:otherwise>
94 </xsl:choose>
95 </xsl:if>
96 </xsl:template>
97
98 <xsl:template match="para/userinput">
99 <xsl:if test="$testsuite != '0' and
100 (contains(string(),'test') or
101 contains(string(),'check'))">
102 <xsl:value-of select="substring-before(string(),'make')"/>
103 <xsl:text>make -k</xsl:text>
104 <xsl:value-of select="substring-after(string(),'make')"/>
105 <xsl:text> || true&#xA;</xsl:text>
106 </xsl:if>
107 </xsl:template>
108
109 <xsl:template match="userinput" mode="screen">
110 <xsl:choose>
111 <!-- Estandarized package formats -->
112 <xsl:when test="contains(string(),'tar.gz')">
113 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
114 <xsl:text>tar.*</xsl:text>
115 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
116 <xsl:text>&#xA;</xsl:text>
117 </xsl:when>
118 <!-- Avoiding a race condition in a patch -->
119 <xsl:when test="contains(string(),'debian_fixes')">
120 <xsl:value-of select="substring-before(string(),'patch')"/>
121 <xsl:text>patch -Z</xsl:text>
122 <xsl:value-of select="substring-after(string(),'patch')"/>
123 <xsl:text>&#xA;</xsl:text>
124 </xsl:when>
125 <!-- Copying the kernel config file -->
126 <xsl:when test="string() = 'make mrproper'">
127 <xsl:text>make mrproper&#xA;</xsl:text>
128 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
129 </xsl:when>
130 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
131 <xsl:when test="$testsuite = '0' and
132 (ancestor::sect1[@id='ch-system-coreutils'] or
133 ancestor::sect1[@id='ch-system-module-init-tools']) and
134 (contains(string(),'check') or
135 contains(string(),'dummy'))"/>
136 <!-- Fixing toolchain test suites run -->
137 <xsl:when test="string() = 'make check' or
138 string() = 'make -k check'">
139 <xsl:choose>
140 <xsl:when test="$toolchaintest = '0'"/>
141 <xsl:otherwise>
142 <xsl:text>make -k check || true</xsl:text>
143 <xsl:text>&#xA;</xsl:text>
144 </xsl:otherwise>
145 </xsl:choose>
146 </xsl:when>
147 <xsl:when test="contains(string(),'glibc-check-log')">
148 <xsl:choose>
149 <xsl:when test="$toolchaintest = '0'"/>
150 <xsl:otherwise>
151 <xsl:value-of select="substring-before(string(),'&#xA;')"/>
152 <xsl:text> || true&#xA;</xsl:text>
153 <xsl:value-of select="substring-after(string(),'&#xA;')"/>
154 <xsl:text>&#xA;</xsl:text>
155 </xsl:otherwise>
156 </xsl:choose>
157 </xsl:when>
158 <xsl:when test="contains(string(),'test_summary') or
159 contains(string(),'expect -c')">
160 <xsl:choose>
161 <xsl:when test="$toolchaintest = '0'"/>
162 <xsl:otherwise>
163 <xsl:apply-templates/>
164 <xsl:text>&#xA;</xsl:text>
165 </xsl:otherwise>
166 </xsl:choose>
167 </xsl:when>
168 <!-- Don't stop on strip run -->
169 <xsl:when test="contains(string(),'strip ')">
170 <xsl:apply-templates/>
171 <xsl:text> || true&#xA;</xsl:text>
172 </xsl:when>
173 <!-- The rest of commands -->
174 <xsl:otherwise>
175 <xsl:apply-templates/>
176 <xsl:text>&#xA;</xsl:text>
177 </xsl:otherwise>
178 </xsl:choose>
179 </xsl:template>
180
181 <xsl:template match="replaceable">
182 <xsl:choose>
183 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
184 <xsl:text>$TIMEZONE</xsl:text>
185 </xsl:when>
186 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
187 <xsl:text>$PAGE</xsl:text>
188 </xsl:when>
189 <xsl:otherwise>
190 <xsl:text>**EDITME</xsl:text>
191 <xsl:apply-templates/>
192 <xsl:text>EDITME**</xsl:text>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:template>
196
197</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.