source: HLFS/hlfs.xsl@ 0ac273e

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

Fixed remainig issues in uClibc script generation.
Fixed the chapter6_Makefile code.

  • Property mode set to 100644
File size: 11.5 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:if test="@id='ch-system-kernfs'">
111 <xsl:text>export HLFS=$LFS&#xA;</xsl:text>
112 </xsl:if>
113 <xsl:apply-templates select=".//para/userinput | .//screen"/>
114 <xsl:text>exit</xsl:text>
115 </exsl:document>
116 </xsl:if>
117 </xsl:template>
118
119 <xsl:template match="screen">
120 <xsl:if test="(@condition=$model or not(@condition)) and
121 child::* = userinput and not(@role = 'nodump')">
122 <xsl:apply-templates select="userinput" mode="screen"/>
123 </xsl:if>
124 </xsl:template>
125
126 <xsl:template match="para/userinput">
127 <xsl:if test="(contains(string(),'test') or
128 contains(string(),'check')) and
129 (($testsuite = '1' and
130 (ancestor::sect1[@id='ch-system-gcc'] or
131 ancestor::sect1[@id='ch-system-glibc'])) or
132 ($testsuite = '2' and
133 ancestor::chapter[@id='chapter-building-system']) or
134 $testsuite = '3')">
135 <xsl:choose>
136 <xsl:when test="ancestor::sect1[@id='ch-system-gcc']">
137 <xsl:text>make -k check || true&#xA;</xsl:text>
138 </xsl:when>
139 <xsl:otherwise>
140 <xsl:value-of select="substring-before(string(),'make')"/>
141 <xsl:text>make -k</xsl:text>
142 <xsl:value-of select="substring-after(string(),'make')"/>
143 <xsl:text> || true&#xA;</xsl:text>
144 </xsl:otherwise>
145 </xsl:choose>
146 </xsl:if>
147 </xsl:template>
148
149 <xsl:template match="userinput" mode="screen">
150 <xsl:choose>
151 <!-- Estandarized package formats -->
152 <xsl:when test="contains(string(),'tar.gz')">
153 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
154 <xsl:text>tar.*</xsl:text>
155 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
156 <xsl:text>&#xA;</xsl:text>
157 </xsl:when>
158 <!-- Avoiding a race condition in a patch -->
159 <xsl:when test="contains(string(),'debian_fixes')">
160 <xsl:value-of select="substring-before(string(),'patch')"/>
161 <xsl:text>patch -Z</xsl:text>
162 <xsl:value-of select="substring-after(string(),'patch')"/>
163 <xsl:text>&#xA;</xsl:text>
164 </xsl:when>
165 <!-- grsecurity kernel in the host? -->
166 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
167 contains(string(),'sysctl')
168 and $grsecurity_host ='0'"/>
169 <!-- Setting $LC_ALL and $LANG for /etc/profile -->
170 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
171 contains(string(),'export LANG=')">
172 <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
173 <xsl:text>export LC_ALL=$LC_ALL&#xA;export LANG=$LANG&#xA;</xsl:text>
174 <xsl:text>export INPUTRC</xsl:text>
175 <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
176 <xsl:text>&#xA;</xsl:text>
177 </xsl:when>
178 <!-- Fixing bootscripts installation -->
179 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
180 string() = 'make install'">
181 <xsl:text>make install&#xA;</xsl:text>
182 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
183 </xsl:when>
184 <!-- Compile the keymap into the kernel? -->
185 <xsl:when test="contains(string(),'defkeymap') and
186 $keymap = 'none'"/>
187 <!-- Copying the kernel config file -->
188 <xsl:when test="string() = 'make mrproper'">
189 <xsl:text>make mrproper&#xA;</xsl:text>
190 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
191 </xsl:when>
192 <!-- No interactive commands are allowed -->
193 <xsl:when test="string() = 'make menuconfig'">
194 <xsl:text>make oldconfig&#xA;</xsl:text>
195 </xsl:when>
196 <!-- For uClibc we need to cd to the Gettext package -->
197 <xsl:when test="contains(string(),'cd gettext-runtime/')">
198 <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
199 <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
200 <xsl:text>&#xA;</xsl:text>
201 </xsl:when>
202 <!-- For uClibc we need to set TIMEZONE envar -->
203 <xsl:when test="contains(string(),'EST5EDT')">
204 <xsl:value-of select="substring-before(string(),'EST5EDT')"/>
205 <xsl:text>${TIMEZONE}</xsl:text>
206 <xsl:value-of select="substring-after(string(),'EST5EDT')"/>
207 <xsl:text>&#xA;</xsl:text>
208 </xsl:when>
209 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
210 <xsl:when test="($testsuite = '0' or $testsuite = '1') and
211 (ancestor::sect1[@id='ch-system-coreutils'] or
212 ancestor::sect1[@id='ch-system-module-init-tools']) and
213 (contains(string(),'check') or
214 contains(string(),'distclean') or
215 contains(string(),'dummy'))"/>
216 <!-- Fixing toolchain test suites run -->
217 <xsl:when test="string() = 'make check' or
218 string() = 'make -k check'">
219 <xsl:choose>
220 <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
221 ancestor::chapter[@id='chapter-building-system']) or
222 $testsuite = '3'">
223 <xsl:text>make -k check || true</xsl:text>
224 <xsl:text>&#xA;</xsl:text>
225 </xsl:when>
226 </xsl:choose>
227 </xsl:when>
228 <xsl:when test="contains(string(),'make check') and
229 ancestor::sect1[@id='ch-system-binutils']">
230 <xsl:choose>
231 <xsl:when test="$testsuite != '0'">
232 <xsl:value-of select="substring-before(string(),'make check')"/>
233 <xsl:text>make -k check || true&#xA;</xsl:text>
234 </xsl:when>
235 </xsl:choose>
236 </xsl:when>
237 <xsl:when test="contains(string(),'hardened-specs') and
238 ancestor::sect1[@id='ch-system-binutils']
239 and $testsuite = '0'"/>
240 <!-- Don't stop on strip run and chapter05 GCC installation test-->
241 <xsl:when test="contains(string(),'strip ') or
242 ancestor::sect2[@id='testing-gcc']">
243 <xsl:apply-templates/>
244 <xsl:text> || true&#xA;</xsl:text>
245 </xsl:when>
246 <!-- The rest of commands -->
247 <xsl:otherwise>
248 <xsl:apply-templates/>
249 <xsl:text>&#xA;</xsl:text>
250 </xsl:otherwise>
251 </xsl:choose>
252 </xsl:template>
253
254 <xsl:template match="replaceable">
255 <xsl:choose>
256 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
257 ancestor::sect1[@id='ch-system-uclibc']">
258 <xsl:text>$TIMEZONE</xsl:text>
259 </xsl:when>
260 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
261 <xsl:text>$PAGE</xsl:text>
262 </xsl:when>
263 <xsl:when test="ancestor::sect1[@id='bootable-kernel']">
264 <xsl:value-of select="$keymap"/>
265 </xsl:when>
266 <xsl:otherwise>
267 <xsl:text>**EDITME</xsl:text>
268 <xsl:apply-templates/>
269 <xsl:text>EDITME**</xsl:text>
270 </xsl:otherwise>
271 </xsl:choose>
272 </xsl:template>
273
274</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.