source: HLFS/hlfs.xsl@ 570c9f3

experimental
Last change on this file since 570c9f3 was 9c9775f, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Updated experimental branch to current trunk code.

  • Property mode set to 100644
File size: 13.2 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
[9c9775f]19 <!-- What kernel serie must be used? -->
20 <xsl:param name="kernel" select="2.6"/>
21
[d540567]22 <!-- Is the host kernel using grsecurity? -->
[47fddc8]23 <xsl:param name="grsecurity_host" select="n"/>
[d540567]24
[174a8e9]25 <!-- Run test suites?
26 0 = none
27 1 = only chapter06 Glibc, GCC and Binutils testsuites
28 2 = all chapter06 testsuites
[056486c]29 3 = alias to 2
30 -->
[174a8e9]31 <xsl:param name="testsuite" select="1"/>
[0170229]32
[056486c]33 <!-- Bomb on test suites failures?
[47fddc8]34 n = no, I want to build the full system and review the logs
35 y = yes, bomb at the first test suite failure to can review the build dir
[056486c]36 -->
[47fddc8]37 <xsl:param name="bomb-testsuite" select="n"/>
[056486c]38
[9c9775f]39 <!-- Additional features -->
40 <xsl:param name="features">,ssp,aslr,pax,hardened_tmp,warnings,misc,blowfish,</xsl:param>
41
[ad71d98]42 <!-- Time zone -->
[e35e794]43 <xsl:param name="timezone" select="GMT"/>
[ad71d98]44
45 <!-- Page size -->
46 <xsl:param name="page" select="letter"/>
47
[d87b293]48 <!-- Locale settings -->
[e35e794]49 <xsl:param name="lang" select="C"/>
[d87b293]50
[0170229]51 <xsl:template match="/">
52 <xsl:apply-templates select="//sect1"/>
53 </xsl:template>
54
55 <xsl:template match="sect1">
[174a8e9]56 <xsl:if test="(../@id='chapter-temporary-tools' or
57 ../@id='chapter-building-system' or
58 ../@id='chapter-bootable') and
[9c9775f]59 (count(descendant::screen/userinput) &gt; 0 and
[174a8e9]60 count(descendant::screen/userinput) &gt;
[9c9775f]61 count(descendant::screen[@role='nodump'])) and
62 ((@condition=$model or not(@condition)) and
63 (@vendor=$kernel or not(@vendor)))">
[0170229]64 <!-- The dirs names -->
65 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
66 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
67 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
68 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
69 <!-- The file names -->
70 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
71 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
72 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
73 <!-- The build order -->
74 <xsl:variable name="position" select="position()"/>
75 <xsl:variable name="order">
76 <xsl:choose>
77 <xsl:when test="string-length($position) = 1">
78 <xsl:text>00</xsl:text>
79 <xsl:value-of select="$position"/>
80 </xsl:when>
81 <xsl:when test="string-length($position) = 2">
82 <xsl:text>0</xsl:text>
83 <xsl:value-of select="$position"/>
84 </xsl:when>
85 <xsl:otherwise>
86 <xsl:value-of select="$position"/>
87 </xsl:otherwise>
88 </xsl:choose>
89 </xsl:variable>
90 <!-- Creating dirs and files -->
91 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
92 <xsl:choose>
[9c9775f]93 <xsl:when test="@id='ch-system-creatingdirs' or
94 @id='ch-system-createfiles' or
95 @id='ch-system-changingowner' or
[174a8e9]96 @id='ch-system-strippingagain'">
[9c9775f]97 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
[0170229]98 </xsl:when>
99 <xsl:otherwise>
[9c9775f]100 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
[0170229]101 </xsl:otherwise>
102 </xsl:choose>
[9c9775f]103 <xsl:if test="not(@id='ch-tools-stripping') and
104 not(@id='ch-system-strippingagain')">
105 <xsl:text>set -e&#xA;</xsl:text>
106 </xsl:if>
107 <xsl:text>&#xA;</xsl:text>
108 <xsl:if test="(sect2[@role='installation'])">
[0170229]109 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
[9c9775f]110 <xsl:if test="@id='ch-system-uclibc'">
[0170229]111 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
112 </xsl:if>
[9c9775f]113 <!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
114 <xsl:if test="@id='ch-tools-embryo-toolchain' or
[f83bcee]115 @id='ch-tools-cocoon-toolchain' or
116 @id='ch-system-butterfly-toolchain'">
[a82bbc0]117 <xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
118 <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
[174a8e9]119 </xsl:if>
[9c9775f]120 <xsl:if test="@id='ch-tools-cocoon-toolchain' or
121 @id='ch-system-butterfly-toolchain'">
122 <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
123 </xsl:if>
[a82bbc0]124 <!-- ONLY butterfly has a testsuite -->
[00818a6]125 <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
[7c4730c]126 <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
[0170229]127 </xsl:if>
[9c9775f]128 <!-- END SVN toolchain format -->
[0170229]129 </xsl:if>
130 <xsl:apply-templates select=".//para/userinput | .//screen"/>
[9c9775f]131 <xsl:if test="not(@id='ch-system-chroot') and
132 not(@id='ch-system-revisedchroot')">
133 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
134 </xsl:if>
[0170229]135 <xsl:text>exit</xsl:text>
136 </exsl:document>
137 </xsl:if>
138 </xsl:template>
139
140 <xsl:template match="screen">
[174a8e9]141 <xsl:if test="(@condition=$model or not(@condition)) and
[9c9775f]142 (@vendor=$kernel or not(@vendor)) and
143 child::* = userinput and (not(@role) or
144 (@role and contains($features,concat(',',@role,','))))">
[174a8e9]145 <xsl:apply-templates select="userinput" mode="screen"/>
[0170229]146 </xsl:if>
147 </xsl:template>
148
149 <xsl:template match="para/userinput">
[174a8e9]150 <xsl:if test="(contains(string(),'test') or
[f83bcee]151 contains(string(),'check')) and
152 ($testsuite = '2' or $testsuite = '3')">
[056486c]153 <xsl:choose>
[47fddc8]154 <xsl:when test="$bomb-testsuite = 'n'">
[056486c]155 <xsl:value-of select="substring-before(string(),'make')"/>
156 <xsl:text>make -k</xsl:text>
157 <xsl:value-of select="substring-after(string(),'make')"/>
158 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
159 </xsl:when>
160 <xsl:otherwise>
161 <xsl:apply-templates/>
[8946876]162 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
163 <xsl:if test="contains(string(),' -k ')">
164 <xsl:text> || true</xsl:text>
165 </xsl:if>
166 <xsl:text>&#xA;</xsl:text>
[056486c]167 </xsl:otherwise>
168 </xsl:choose>
[0170229]169 </xsl:if>
170 </xsl:template>
171
172 <xsl:template match="userinput" mode="screen">
173 <xsl:choose>
[d540567]174 <!-- grsecurity kernel in the host? -->
175 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
176 contains(string(),'sysctl')
[47fddc8]177 and $grsecurity_host ='n'"/>
[9c9775f]178 <!-- Setting $LANG for /etc/profile -->
[174a8e9]179 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
180 contains(string(),'export LANG=')">
[9c9775f]181 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
182 <xsl:text>export LANG=</xsl:text>
[d87b293]183 <xsl:value-of select="$lang"/>
[9c9775f]184 <xsl:value-of select="substring-after(string(),'CC]')"/>
[174a8e9]185 <xsl:text>&#xA;</xsl:text>
186 </xsl:when>
[0170229]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>
[9a4f673]192 <!-- No interactive commands are needed if the .config file is the proper one -->
193 <xsl:when test="string() = 'make menuconfig'"/>
[9c9775f]194 <!-- For uClibc we need to set CONFIG_SITE -->
195 <xsl:when test="contains(string(),'CONFIG_SITE')">
196 <xsl:value-of select="substring-before(string(),'export')"/>
197 <xsl:text>echo "export</xsl:text>
198 <xsl:value-of select="substring-after(string(),'export')"/>
199 <xsl:text>" &gt;&gt; ~/.bashrc&#xA;</xsl:text>
200 </xsl:when>
[582feec]201 <!-- For uClibc we need to cd to the Gettext package -->
202 <xsl:when test="contains(string(),'cd gettext-runtime/')">
203 <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
204 <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
205 <xsl:text>&#xA;</xsl:text>
206 </xsl:when>
[0170229]207 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[e35e794]208 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
[174a8e9]209 ancestor::sect1[@id='ch-system-module-init-tools']) and
[0170229]210 (contains(string(),'check') or
[174a8e9]211 contains(string(),'distclean') or
[e35e794]212 contains(string(),'dummy'))">
213 <xsl:choose>
214 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
215 <xsl:otherwise>
[056486c]216 <xsl:if test="not(contains(string(),'check'))">
217 <xsl:apply-templates/>
218 <xsl:text>&#xA;</xsl:text>
219 </xsl:if>
[e35e794]220 <xsl:if test="contains(string(),'check')">
[056486c]221 <xsl:choose>
[47fddc8]222 <xsl:when test="$bomb-testsuite = 'n'">
[056486c]223 <xsl:value-of select="substring-before(string(),'check')"/>
224 <xsl:text>-k check</xsl:text>
225 <xsl:value-of select="substring-after(string(),'check')"/>
226 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
227 </xsl:when>
228 <xsl:otherwise>
229 <xsl:apply-templates/>
[8946876]230 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
231 <xsl:if test="contains(string(),' -k ')">
232 <xsl:text> || true</xsl:text>
233 </xsl:if>
234 <xsl:text>&#xA;</xsl:text>
[056486c]235 </xsl:otherwise>
236 </xsl:choose>
[e35e794]237 </xsl:if>
238 </xsl:otherwise>
239 </xsl:choose>
240 </xsl:when>
[9c9775f]241 <!-- Fixing butterfly toolchain test suite run -->
242 <xsl:when test="ancestor::sect1[@id='ch-system-butterfly-toolchain']
243 and string() = 'make -k check'">
[0170229]244 <xsl:choose>
[f83bcee]245 <xsl:when test="$testsuite != '0'">
[056486c]246 <xsl:choose>
[47fddc8]247 <xsl:when test="$bomb-testsuite = 'n'">
[9c9775f]248 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[056486c]249 </xsl:when>
250 <xsl:otherwise>
[9c9775f]251 <xsl:apply-templates/>
[d0fa46b]252 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
[8946876]253 <xsl:if test="contains(string(),' -k ')">
254 <xsl:text> || true</xsl:text>
255 </xsl:if>
[d0fa46b]256 <xsl:text>&#xA;</xsl:text>
[056486c]257 </xsl:otherwise>
258 </xsl:choose>
[174a8e9]259 </xsl:when>
[0170229]260 </xsl:choose>
261 </xsl:when>
[f83bcee]262 <!-- Fixing Glbc test suite -->
[9c9775f]263 <xsl:when test="contains(string(),'rm -v configparms') and
264 contains(string(),'-fno-stack-protector')">
265 <xsl:choose>
266 <xsl:when test="$testsuite != '0'">
267 <xsl:apply-templates/>
268 <xsl:text>&#xA;</xsl:text>
269 </xsl:when>
270 </xsl:choose>
271 </xsl:when>
[f83bcee]272 <xsl:when test="contains(string(),'glibc-check-log')">
273 <xsl:choose>
274 <xsl:when test="$testsuite != '0'">
[9c9775f]275 <xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
276 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[f83bcee]277 </xsl:when>
278 </xsl:choose>
279 </xsl:when>
[9c9775f]280 <!-- Fixing Cocoon sanity checks -->
281 <xsl:when test="contains(string(),'./strcat-overflow')">
282 <xsl:text>set +e&#xA;</xsl:text>
283 <xsl:apply-templates/>
284 <xsl:text>&#xA;set -e&#xA;</xsl:text>
285 </xsl:when>
286 <!-- Fixing Butterfly sanity checks -->
287 <xsl:when test="contains(string(),'./fortify-test')
288 or contains(string(),'./ssp-test')">
289 <xsl:text>! </xsl:text>
290 <xsl:apply-templates/>
291 <xsl:text>&#xA;</xsl:text>
292 </xsl:when>
293 <!-- Don't stop on strip run -->
294 <xsl:when test="contains(string(),'strip ')">
[0170229]295 <xsl:apply-templates/>
296 <xsl:text> || true&#xA;</xsl:text>
297 </xsl:when>
298 <!-- The rest of commands -->
299 <xsl:otherwise>
300 <xsl:apply-templates/>
301 <xsl:text>&#xA;</xsl:text>
302 </xsl:otherwise>
303 </xsl:choose>
304 </xsl:template>
305
[f83bcee]306 <xsl:template match="literal">
[9c9775f]307 <xsl:if test="(@condition=$model or not(@condition)) and
308 (@vendor=$kernel or not(@vendor))">
[f83bcee]309 <xsl:apply-templates/>
310 </xsl:if>
311 </xsl:template>
312
[0170229]313 <xsl:template match="replaceable">
314 <xsl:choose>
[174a8e9]315 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
316 ancestor::sect1[@id='ch-system-uclibc']">
[ad71d98]317 <xsl:value-of select="$timezone"/>
[0170229]318 </xsl:when>
319 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
[ad71d98]320 <xsl:value-of select="$page"/>
[0170229]321 </xsl:when>
322 <xsl:otherwise>
323 <xsl:text>**EDITME</xsl:text>
324 <xsl:apply-templates/>
325 <xsl:text>EDITME**</xsl:text>
326 </xsl:otherwise>
327 </xsl:choose>
328 </xsl:template>
329
330</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.