source: HLFS/hlfs.xsl@ d540567

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

Handled and via XSL.
Fixed the chapter05 GCC installation test run.
Fixed blfs-bootscripts installation.
The build_Makefile code need be adapted to that new XSL code.

  • Property mode set to 100644
File size: 10.6 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 HLFS books. -->
15
16 <!-- What libc implentation must be used? -->
17 <xsl:param name="model" select="glibc"/>
18
19 <!-- Is the host kernel using grsecurity? -->
20 <xsl:param name="grsecurity_host" select="0"/>
21
22 <!-- Compile the keymap into the kernel? -->
23 <xsl:param name="keymap" select="none"/>
24
25 <!-- Run test suites?
26 0 = none
27 1 = only chapter06 Glibc, GCC and Binutils testsuites
28 2 = all chapter06 testsuites
29 3 = all chapter05 and chapter06 testsuites-->
30 <xsl:param name="testsuite" select="1"/>
31
32 <xsl:template match="/">
33 <xsl:apply-templates select="//sect1"/>
34 </xsl:template>
35
36 <xsl:template match="sect1">
37 <xsl:if test="(../@id='chapter-temporary-tools' or
38 ../@id='chapter-building-system' or
39 ../@id='chapter-bootable') and
40 ((@condition=$model or not(@condition)) and
41 count(descendant::screen/userinput) &gt; 0 and
42 count(descendant::screen/userinput) &gt;
43 count(descendant::screen[@role='nodump']))">
44 <!-- The dirs names -->
45 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
46 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
47 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
48 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
49 <!-- The file names -->
50 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
51 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
52 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
53 <!-- The build order -->
54 <xsl:variable name="position" select="position()"/>
55 <xsl:variable name="order">
56 <xsl:choose>
57 <xsl:when test="string-length($position) = 1">
58 <xsl:text>00</xsl:text>
59 <xsl:value-of select="$position"/>
60 </xsl:when>
61 <xsl:when test="string-length($position) = 2">
62 <xsl:text>0</xsl:text>
63 <xsl:value-of select="$position"/>
64 </xsl:when>
65 <xsl:otherwise>
66 <xsl:value-of select="$position"/>
67 </xsl:otherwise>
68 </xsl:choose>
69 </xsl:variable>
70 <!-- Creating dirs and files -->
71 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
72 <xsl:choose>
73 <xsl:when test="@id='ch-system-changingowner' or
74 @id='ch-system-creatingdirs' or
75 @id='ch-system-createfiles'">
76 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
77 </xsl:when>
78 <xsl:when test="@id='ch-tools-stripping' or
79 @id='ch-system-strippingagain'">
80 <xsl:text>#!/bin/sh&#xA;</xsl:text>
81 </xsl:when>
82 <xsl:otherwise>
83 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
84 </xsl:otherwise>
85 </xsl:choose>
86 <xsl:if test="(sect2[@role='installation'] and
87 not(@id='bootable-kernel')) or
88 @id='ch-tools-adjusting' or
89 @id='ch-system-readjusting'">
90 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
91 <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
92 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
93 </xsl:if>
94 <xsl:if test="@id='ch-tools-glibc' or @id='ch-system-glibc'">
95 <xsl:text>tar -xvf ../glibc-libidn-&glibc-version;.*&#xA;</xsl:text>
96 </xsl:if>
97 <xsl:if test="@id='ch-tools-gcc' or @id='ch-system-gcc'">
98 <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
99 </xsl:if>
100 <xsl:if test="@id='ch-tools-gcc' and $testsuite = '3'">
101 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
102 </xsl:if>
103 <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
104 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
105 </xsl:if>
106 <xsl:if test="@id='bootable-bootscripts'">
107 <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; &#xA;</xsl:text>
108 </xsl:if>
109 </xsl:if>
110 <xsl:apply-templates select=".//para/userinput | .//screen"/>
111 <xsl:text>exit</xsl:text>
112 </exsl:document>
113 </xsl:if>
114 </xsl:template>
115
116 <xsl:template match="screen">
117 <xsl:if test="(@condition=$model or not(@condition)) and
118 child::* = userinput and not(@role = 'nodump')">
119 <xsl:apply-templates select="userinput" mode="screen"/>
120 </xsl:if>
121 </xsl:template>
122
123 <xsl:template match="para/userinput">
124 <xsl:if test="(contains(string(),'test') or
125 contains(string(),'check')) and
126 (($testsuite = '1' and
127 (ancestor::sect1[@id='ch-system-gcc'] or
128 ancestor::sect1[@id='ch-system-glibc'])) or
129 ($testsuite = '2' and
130 ancestor::chapter[@id='chapter-building-system']) or
131 $testsuite = '3')">
132 <xsl:choose>
133 <xsl:when test="ancestor::sect1[@id='ch-system-gcc']">
134 <xsl:text>make -k check || true&#xA;</xsl:text>
135 </xsl:when>
136 <xsl:otherwise>
137 <xsl:value-of select="substring-before(string(),'make')"/>
138 <xsl:text>make -k</xsl:text>
139 <xsl:value-of select="substring-after(string(),'make')"/>
140 <xsl:text> || true&#xA;</xsl:text>
141 </xsl:otherwise>
142 </xsl:choose>
143 </xsl:if>
144 </xsl:template>
145
146 <xsl:template match="userinput" mode="screen">
147 <xsl:choose>
148 <!-- Estandarized package formats -->
149 <xsl:when test="contains(string(),'tar.gz')">
150 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
151 <xsl:text>tar.*</xsl:text>
152 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
153 <xsl:text>&#xA;</xsl:text>
154 </xsl:when>
155 <!-- Avoiding a race condition in a patch -->
156 <xsl:when test="contains(string(),'debian_fixes')">
157 <xsl:value-of select="substring-before(string(),'patch')"/>
158 <xsl:text>patch -Z</xsl:text>
159 <xsl:value-of select="substring-after(string(),'patch')"/>
160 <xsl:text>&#xA;</xsl:text>
161 </xsl:when>
162 <!-- grsecurity kernel in the host? -->
163 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
164 contains(string(),'sysctl')
165 and $grsecurity_host ='0'"/>
166 <!-- Setting $LC_ALL and $LANG for /etc/profile -->
167 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
168 contains(string(),'export LANG=')">
169 <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
170 <xsl:text>export LC_ALL=$LC_ALL&#xA;export LANG=$LANG&#xA;</xsl:text>
171 <xsl:text>export INPUTRC</xsl:text>
172 <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
173 <xsl:text>&#xA;</xsl:text>
174 </xsl:when>
175 <!-- Fixing bootscripts installation -->
176 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
177 string() = 'make install'">
178 <xsl:text>make install&#xA;</xsl:text>
179 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
180 </xsl:when>
181 <!-- Compile the keymap into the kernel? -->
182 <xsl:when test="contains(string(),'defkeymap') and
183 $keymap = 'none'"/>
184 <!-- Copying the kernel config file -->
185 <xsl:when test="string() = 'make mrproper'">
186 <xsl:text>make mrproper&#xA;</xsl:text>
187 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
188 </xsl:when>
189 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
190 <xsl:when test="($testsuite = '0' or $testsuite = '1') and
191 (ancestor::sect1[@id='ch-system-coreutils'] or
192 ancestor::sect1[@id='ch-system-module-init-tools']) and
193 (contains(string(),'check') or
194 contains(string(),'distclean') or
195 contains(string(),'dummy'))"/>
196 <!-- Fixing toolchain test suites run -->
197 <xsl:when test="string() = 'make check' or
198 string() = 'make -k check'">
199 <xsl:choose>
200 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
201 ancestor::chapter[@id='chapter-building-system']) or
202 $testsuite = '3'">
203 <xsl:text>make -k check || true</xsl:text>
204 <xsl:text>&#xA;</xsl:text>
205 </xsl:when>
206 </xsl:choose>
207 </xsl:when>
208 <xsl:when test="contains(string(),'make check') and
209 ancestor::sect1[@id='ch-system-binutils']">
210 <xsl:choose>
211 <xsl:when test="$testsuite != '0'">
212 <xsl:value-of select="substring-before(string(),'make check')"/>
213 <xsl:text>make -k check || true&#xA;</xsl:text>
214 </xsl:when>
215 </xsl:choose>
216 </xsl:when>
217 <xsl:when test="contains(string(),'hardened-specs') and
218 ancestor::sect1[@id='ch-system-binutils']
219 and $testsuite = '0'"/>
220 <!-- Don't stop on strip run and chapter05 GCC installation test-->
221 <xsl:when test="contains(string(),'strip ') or
222 ancestor::sect2[@id='testing-gcc']">
223 <xsl:apply-templates/>
224 <xsl:text> || true&#xA;</xsl:text>
225 </xsl:when>
226 <!-- The rest of commands -->
227 <xsl:otherwise>
228 <xsl:apply-templates/>
229 <xsl:text>&#xA;</xsl:text>
230 </xsl:otherwise>
231 </xsl:choose>
232 </xsl:template>
233
234 <xsl:template match="replaceable">
235 <xsl:choose>
236 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
237 ancestor::sect1[@id='ch-system-uclibc']">
238 <xsl:text>$TIMEZONE</xsl:text>
239 </xsl:when>
240 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
241 <xsl:text>$PAGE</xsl:text>
242 </xsl:when>
243 <xsl:when test="ancestor::sect1[@id='bootable-kernel']">
244 <xsl:value-of select="$keymap"/>
245 </xsl:when>
246 <xsl:otherwise>
247 <xsl:text>**EDITME</xsl:text>
248 <xsl:apply-templates/>
249 <xsl:text>EDITME**</xsl:text>
250 </xsl:otherwise>
251 </xsl:choose>
252 </xsl:template>
253
254</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.