source: HLFS/hlfs.xsl@ 075115a

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

Added base files from George's jhalfs-experimental-2 POC.
WARNING: This code is broken due files renaming.

  • Property mode set to 100644
File size: 8.7 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
7<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 xmlns:exsl="http://exslt.org/common"
9 extension-element-prefixes="exsl"
10 version="1.0">
11
12<!-- XSLT stylesheet to create shell scripts from LFS books. -->
13
14 <!-- Run optional test suites? -->
15 <xsl:param name="testsuite" select="0"/>
16
17 <!-- Run toolchain test suites? -->
18 <xsl:param name="toolchaintest" select="1"/>
19
20 <!-- Install vim-lang package? -->
21 <xsl:param name="vim-lang" select="1"/>
22
23 <xsl:template match="/">
24 <xsl:apply-templates select="//sect1"/>
25 </xsl:template>
26
27 <xsl:template match="sect1">
28 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
29 count(descendant::screen/userinput) &gt; count(descendant::screen[@role='nodump'])">
30 <!-- The dirs names -->
31 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
32 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
33 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
34 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
35 <!-- The file names -->
36 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
37 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
38 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
39 <!-- The build order -->
40 <xsl:variable name="position" select="position()"/>
41 <xsl:variable name="order">
42 <xsl:choose>
43 <xsl:when test="string-length($position) = 1">
44 <xsl:text>00</xsl:text>
45 <xsl:value-of select="$position"/>
46 </xsl:when>
47 <xsl:when test="string-length($position) = 2">
48 <xsl:text>0</xsl:text>
49 <xsl:value-of select="$position"/>
50 </xsl:when>
51 <xsl:otherwise>
52 <xsl:value-of select="$position"/>
53 </xsl:otherwise>
54 </xsl:choose>
55 </xsl:variable>
56
57 <!-- Creating dirs and files -->
58 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
59 <!-- Add a header to each script -->
60 <xsl:choose>
61 <xsl:when test="@id='ch-system-changingowner' or
62 @id='ch-system-creatingdirs' or
63 @id='ch-system-createfiles'">
64 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
65 </xsl:when>
66
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
72 <xsl:otherwise>
73 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
74 </xsl:otherwise>
75 </xsl:choose>
76
77 <xsl:if test="sect2[@role='installation'] or
78 @id='ch-tools-adjusting' or
79 @id='ch-system-readjusting'">
80 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
81 <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
82 <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
83 </xsl:if>
84 <xsl:if test="@id='ch-tools-uclibc'">
85 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
86 </xsl:if>
87 <xsl:if test="@id='ch-system-uclibc'">
88 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
89 </xsl:if>
90 <xsl:if test="@id='ch-system-glibc'">
91 <xsl:text>tar -xvf ../glibc-libidn-&glibc-version;.*&#xA;</xsl:text>
92 </xsl:if>
93 <xsl:if test="@id='ch-tools-glibc'">
94 <xsl:text>tar -xvf ../glibc-libidn-&glibc-version;.*&#xA;</xsl:text>
95 </xsl:if>
96 <xsl:if test="@id='ch-system-gcc'">
97 <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
98 </xsl:if>
99 <xsl:if test="@id='ch-tools-gcc'">
100 <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
101 </xsl:if>
102 <xsl:if test="@id='bootable-bootscripts'">
103 <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; &#xA;</xsl:text>
104 </xsl:if>
105 </xsl:if>
106 <xsl:apply-templates select=".//para/userinput | .//screen"/>
107 <xsl:text>exit</xsl:text>
108 </exsl:document>
109 </xsl:if>
110 </xsl:template>
111
112 <xsl:template match="screen">
113 <xsl:if test="child::* = userinput">
114 <xsl:choose>
115 <xsl:when test="@role = 'nodump'"/>
116 <xsl:when test="@condition != $model"/>
117 <xsl:otherwise>
118 <xsl:apply-templates select="userinput" mode="screen"/>
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:if>
122 </xsl:template>
123
124 <xsl:template match="para/userinput">
125 <xsl:if test="$testsuite != '0' and
126 (contains(string(),'test') or contains(string(),'check'))">
127 <xsl:value-of select="substring-before(string(),'make')"/>
128 <xsl:text>make -k</xsl:text>
129 <xsl:value-of select="substring-after(string(),'make')"/>
130 <xsl:text> || true&#xA;</xsl:text>
131 </xsl:if>
132 </xsl:template>
133
134 <xsl:template match="userinput" mode="screen">
135 <xsl:choose>
136 <!-- Estandarized package formats -->
137 <xsl:when test="contains(string(),'tar.gz')">
138 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
139 <xsl:text>tar.*</xsl:text>
140 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
141 <xsl:text>&#xA;</xsl:text>
142 </xsl:when>
143 <!-- Avoiding a race condition in a patch -->
144 <xsl:when test="contains(string(),'debian_fixes')">
145 <xsl:value-of select="substring-before(string(),'patch')"/>
146 <xsl:text>patch -Z</xsl:text>
147 <xsl:value-of select="substring-after(string(),'patch')"/>
148 <xsl:text>&#xA;</xsl:text>
149 </xsl:when>
150
151 <!-- Copying the kernel config file -->
152 <xsl:when test="string() = 'make mrproper'">
153 <xsl:text>make mrproper&#xA;</xsl:text>
154 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
155 </xsl:when>
156
157 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
158 <xsl:when test="$testsuite = '0' and
159 (ancestor::sect1[@id='ch-system-coreutils'] or
160 ancestor::sect1[@id='ch-system-module-init-tools']) and
161 (contains(string(),'check') or
162 contains(string(),'dummy'))"/>
163
164 <!-- Fixing toolchain test suites run -->
165 <xsl:when test="string() = 'make check' or
166 string() = 'make -k check'">
167 <xsl:choose>
168 <xsl:when test="$toolchaintest = '0'"/>
169 <xsl:otherwise>
170 <xsl:text>make -k check || true</xsl:text>
171 <xsl:text>&#xA;</xsl:text>
172 </xsl:otherwise>
173 </xsl:choose>
174 </xsl:when>
175 <xsl:when test="contains(string(),'glibc-check-log')">
176 <xsl:choose>
177 <xsl:when test="$toolchaintest = '0'"/>
178 <xsl:otherwise>
179 <xsl:value-of select="substring-before(string(),'&#xA;')"/>
180 <xsl:text> || true&#xA;</xsl:text>
181 <xsl:value-of select="substring-after(string(),'&#xA;')"/>
182 <xsl:text>&#xA;</xsl:text>
183 </xsl:otherwise>
184 </xsl:choose>
185 </xsl:when>
186 <xsl:when test="contains(string(),'test_summary') or
187 contains(string(),'expect -c')">
188 <xsl:choose>
189 <xsl:when test="$toolchaintest = '0'"/>
190 <xsl:otherwise>
191 <xsl:apply-templates/>
192 <xsl:text>&#xA;</xsl:text>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:when>
196 <!-- Don't stop on strip run -->
197 <xsl:when test="contains(string(),'strip ')">
198 <xsl:apply-templates/>
199 <xsl:text> || true&#xA;</xsl:text>
200 </xsl:when>
201 <!-- The rest of commands -->
202 <xsl:otherwise>
203 <xsl:apply-templates/>
204 <xsl:text>&#xA;</xsl:text>
205 </xsl:otherwise>
206 </xsl:choose>
207 </xsl:template>
208
209<!-- Deal with definable values defined inside <replaceable> -->
210 <xsl:template match="replaceable">
211 <xsl:choose>
212 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
213 <xsl:text>$TIMEZONE</xsl:text>
214 </xsl:when>
215 <xsl:when test="ancestor::sect1[@id='ch-system-uclibc']">
216 <xsl:text>$TIMEZONE</xsl:text>
217 </xsl:when>
218 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
219 <xsl:text>$PAGE</xsl:text>
220 </xsl:when>
221 <xsl:otherwise>
222 <xsl:text>**EDITME</xsl:text>
223 <xsl:apply-templates/>
224 <xsl:text>EDITME**</xsl:text>
225 </xsl:otherwise>
226 </xsl:choose>
227 </xsl:template>
228
229</xsl:stylesheet>
230
Note: See TracBrowser for help on using the repository browser.