source: HLFS/hlfs.xsl@ 7cd9186

experimental
Last change on this file since 7cd9186 was 00818a6, checked in by George Boudreau <georgeb@…>, 18 years ago

Small typo is toolchain name. Added test to Config.in

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