source: HLFS/hlfs.xsl@ 6d5844c

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 6d5844c was d035526, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

HLFS: Added support for additional build features.

  • Property mode set to 100644
File size: 14.4 KB
RevLine 
[877cc6a]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
[5c575e1]19 <!-- What kernel serie must be used? -->
20 <xsl:param name="kernel" select="2.6"/>
21
[877cc6a]22 <!-- Is the host kernel using grsecurity? -->
[401f81e]23 <xsl:param name="grsecurity_host" select="n"/>
[877cc6a]24
25 <!-- Run test suites?
26 0 = none
27 1 = only chapter06 Glibc, GCC and Binutils testsuites
28 2 = all chapter06 testsuites
[28f4756]29 3 = alias to 2
30 -->
[877cc6a]31 <xsl:param name="testsuite" select="1"/>
32
[28f4756]33 <!-- Bomb on test suites failures?
[401f81e]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
[28f4756]36 -->
[401f81e]37 <xsl:param name="bomb-testsuite" select="n"/>
[28f4756]38
[d035526]39 <!-- Additional features -->
40 <xsl:param name="features">,ssp,aslr,pax,hardened_tmp,warnings,misc,blowfish,</xsl:param>
41
[877cc6a]42 <!-- Time zone -->
[a229600]43 <xsl:param name="timezone" select="GMT"/>
[877cc6a]44
45 <!-- Page size -->
46 <xsl:param name="page" select="letter"/>
47
48 <!-- Locale settings -->
[a229600]49 <xsl:param name="lang" select="C"/>
[877cc6a]50
51 <xsl:template match="/">
52 <xsl:apply-templates select="//sect1"/>
53 </xsl:template>
54
55 <xsl:template match="sect1">
56 <xsl:if test="(../@id='chapter-temporary-tools' or
57 ../@id='chapter-building-system' or
58 ../@id='chapter-bootable') and
[c1f28d5]59 (count(descendant::screen/userinput) &gt; 0 and
[877cc6a]60 count(descendant::screen/userinput) &gt;
[c1f28d5]61 count(descendant::screen[@role='nodump'])) and
62 ((@condition=$model or not(@condition)) and
63 (@vendor=$kernel or not(@vendor)))">
[877cc6a]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">
[1330ebc]92 <xsl:choose>
93 <xsl:when test="@id='ch-system-creatingdirs' or
[7d6fe10]94 @id='ch-system-createfiles' or
[1a39790]95 @id='ch-system-changingowner' or
[7d6fe10]96 @id='ch-system-strippingagain'">
[1330ebc]97 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
98 </xsl:when>
99 <xsl:otherwise>
100 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
101 </xsl:otherwise>
102 </xsl:choose>
[5f4982d]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>
[a9d3a9a]108 <xsl:if test="(sect2[@role='installation'])">
[877cc6a]109 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
[5e83595]110 <xsl:if test="@id='ch-system-uclibc'">
[877cc6a]111 <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
112 </xsl:if>
[d81c640]113
[4d15d7f]114 <!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
[d81c640]115 <xsl:if test="@id='ch-tools-embryo-toolchain' or
116 @id='ch-tools-cocoon-toolchain' or
117 @id='ch-system-butterfly-toolchain'">
118 <xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
119 <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
[877cc6a]120 </xsl:if>
[30d1215]121 <xsl:if test="@id='ch-tools-cocoon-toolchain' or
122 @id='ch-system-butterfly-toolchain'">
123 <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
124 </xsl:if>
[d81c640]125 <!-- ONLY butterfly has a testsuite -->
[b2489fb]126 <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
[d81c640]127 <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
[877cc6a]128 </xsl:if>
[4d15d7f]129 <!-- END SVN toolchain format -->
130
131 <!-- 2.4-branch toolchain -->
132 <xsl:if test="@id='ch-tools-gcc-pass2' or @id='ch-system-gcc'">
133 <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
134 </xsl:if>
135 <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
136 <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
137 </xsl:if>
138 <!-- END 2.4-branch toolchain -->
[d81c640]139
[a9d3a9a]140<!-- temporary
[877cc6a]141 <xsl:if test="@id='bootable-bootscripts'">
142 <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; &#xA;</xsl:text>
143 </xsl:if>
[a9d3a9a]144-->
[877cc6a]145 </xsl:if>
146 <xsl:apply-templates select=".//para/userinput | .//screen"/>
147 <xsl:text>exit</xsl:text>
148 </exsl:document>
149 </xsl:if>
150 </xsl:template>
151
152 <xsl:template match="screen">
153 <xsl:if test="(@condition=$model or not(@condition)) and
[5c575e1]154 (@vendor=$kernel or not(@vendor)) and
[d035526]155 child::* = userinput and (not(@role) or
156 (@role and contains($features,concat(',',@role,','))))">
[877cc6a]157 <xsl:apply-templates select="userinput" mode="screen"/>
158 </xsl:if>
159 </xsl:template>
160
161 <xsl:template match="para/userinput">
162 <xsl:if test="(contains(string(),'test') or
[d81c640]163 contains(string(),'check')) and
164 ($testsuite = '2' or $testsuite = '3')">
[28f4756]165 <xsl:choose>
[401f81e]166 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]167 <xsl:value-of select="substring-before(string(),'make')"/>
168 <xsl:text>make -k</xsl:text>
169 <xsl:value-of select="substring-after(string(),'make')"/>
170 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
171 </xsl:when>
172 <xsl:otherwise>
173 <xsl:apply-templates/>
[a1f1969]174 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
175 <xsl:if test="contains(string(),' -k ')">
176 <xsl:text> || true</xsl:text>
177 </xsl:if>
178 <xsl:text>&#xA;</xsl:text>
[28f4756]179 </xsl:otherwise>
180 </xsl:choose>
[877cc6a]181 </xsl:if>
182 </xsl:template>
183
184 <xsl:template match="userinput" mode="screen">
185 <xsl:choose>
186 <!-- Estandarized package formats -->
187 <xsl:when test="contains(string(),'tar.gz')">
188 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
189 <xsl:text>tar.*</xsl:text>
190 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
191 <xsl:text>&#xA;</xsl:text>
192 </xsl:when>
193 <!-- grsecurity kernel in the host? -->
194 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
195 contains(string(),'sysctl')
[401f81e]196 and $grsecurity_host ='n'"/>
[37002ae]197 <!-- We need to have /dev/console and /dev/null availables before
198 entering to the chroot -->
199 <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
200 contains(string(),'600 /dev/console')"/>
[4d15d7f]201 <!-- Fix MAKEDEV installation in 2.4-branch -->
202 <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
203 contains(string(),'bzcat MAKEDEV')">
204 <xsl:text>bzcat /sources/</xsl:text>
205 <xsl:value-of select="substring-after(string(),'bzcat ')"/>
206 <xsl:text>&#xA;</xsl:text>
207 </xsl:when>
[05760bc]208 <!-- Setting $LANG for /etc/profile -->
[877cc6a]209 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
210 contains(string(),'export LANG=')">
[05760bc]211 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
212 <xsl:text>export LANG=</xsl:text>
[877cc6a]213 <xsl:value-of select="$lang"/>
[05760bc]214 <xsl:value-of select="substring-after(string(),'CC]')"/>
[877cc6a]215 <xsl:text>&#xA;</xsl:text>
216 </xsl:when>
217 <!-- Fixing bootscripts installation -->
[a9d3a9a]218
219<!-- temporary
[877cc6a]220 <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
221 string() = 'make install'">
222 <xsl:text>make install&#xA;</xsl:text>
223 <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;&#xA;</xsl:text>
224 </xsl:when>
[a9d3a9a]225-->
[f4caf9c]226 <!-- Compile the keymap into the kernel has been dissabled -->
227 <xsl:when test="contains(string(),'defkeymap')"/>
[877cc6a]228 <!-- Copying the kernel config file -->
229 <xsl:when test="string() = 'make mrproper'">
230 <xsl:text>make mrproper&#xA;</xsl:text>
231 <xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
232 </xsl:when>
233 <!-- No interactive commands are needed if the .config file is the proper one -->
234 <xsl:when test="string() = 'make menuconfig'"/>
235 <!-- For uClibc we need to cd to the Gettext package -->
236 <xsl:when test="contains(string(),'cd gettext-runtime/')">
237 <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
238 <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
239 <xsl:text>&#xA;</xsl:text>
240 </xsl:when>
241 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[a229600]242 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
[877cc6a]243 ancestor::sect1[@id='ch-system-module-init-tools']) and
244 (contains(string(),'check') or
245 contains(string(),'distclean') or
[a229600]246 contains(string(),'dummy'))">
247 <xsl:choose>
248 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
249 <xsl:otherwise>
[28f4756]250 <xsl:if test="not(contains(string(),'check'))">
251 <xsl:apply-templates/>
252 <xsl:text>&#xA;</xsl:text>
253 </xsl:if>
[a229600]254 <xsl:if test="contains(string(),'check')">
[28f4756]255 <xsl:choose>
[401f81e]256 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]257 <xsl:value-of select="substring-before(string(),'check')"/>
258 <xsl:text>-k check</xsl:text>
259 <xsl:value-of select="substring-after(string(),'check')"/>
260 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
261 </xsl:when>
262 <xsl:otherwise>
263 <xsl:apply-templates/>
[a1f1969]264 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
265 <xsl:if test="contains(string(),' -k ')">
266 <xsl:text> || true</xsl:text>
267 </xsl:if>
268 <xsl:text>&#xA;</xsl:text>
[28f4756]269 </xsl:otherwise>
270 </xsl:choose>
[a229600]271 </xsl:if>
272 </xsl:otherwise>
273 </xsl:choose>
274 </xsl:when>
[4d15d7f]275 <!-- Fixing butterfly and 2.4-branch toolchain plus other packages test suites run -->
[ff43bb8]276 <xsl:when test="string() = 'make -k check'
277 or string() = 'make check'
278 or string() = 'make tests'">
[877cc6a]279 <xsl:choose>
[4d15d7f]280 <xsl:when test="((ancestor::sect1[@id='ch-system-butterfly-toolchain']
281 or ancestor::sect1[@id='ch-system-gcc'] or
282 ancestor::sect1[@id='ch-system-binutils'])
[ff43bb8]283 and $testsuite != '0') or
284 $testsuite = '2' or $testsuite = '3'">
[28f4756]285 <xsl:choose>
[401f81e]286 <xsl:when test="$bomb-testsuite = 'n'">
[ff43bb8]287 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[28f4756]288 </xsl:when>
289 <xsl:otherwise>
[ff43bb8]290 <xsl:apply-templates/>
[f98695c]291 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
[a1f1969]292 <xsl:if test="contains(string(),' -k ')">
293 <xsl:text> || true</xsl:text>
294 </xsl:if>
[f98695c]295 <xsl:text>&#xA;</xsl:text>
[28f4756]296 </xsl:otherwise>
297 </xsl:choose>
[877cc6a]298 </xsl:when>
299 </xsl:choose>
300 </xsl:when>
[d81c640]301 <!-- Fixing Glbc test suite -->
302 <xsl:when test="contains(string(),'glibc-check-log')">
[877cc6a]303 <xsl:choose>
304 <xsl:when test="$testsuite != '0'">
[ff43bb8]305 <xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
306 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[877cc6a]307 </xsl:when>
308 </xsl:choose>
309 </xsl:when>
[39f5f3e]310 <!-- Fixing Butterfly sanity checks -->
311 <xsl:when test="contains(string(),'./fortify-test')
312 or contains(string(),'./ssp-test')">
[b6f6212]313 <xsl:text>! </xsl:text>
[39f5f3e]314 <xsl:apply-templates/>
315 <xsl:text>&#xA;</xsl:text>
316 </xsl:when>
[ff43bb8]317 <!-- Don't stop on strip run -->
[85077e7]318 <xsl:when test="contains(string(),'strip ')">
[877cc6a]319 <xsl:apply-templates/>
320 <xsl:text> || true&#xA;</xsl:text>
321 </xsl:when>
322 <!-- The rest of commands -->
323 <xsl:otherwise>
324 <xsl:apply-templates/>
325 <xsl:text>&#xA;</xsl:text>
326 </xsl:otherwise>
327 </xsl:choose>
328 </xsl:template>
329
[d81c640]330 <xsl:template match="literal">
[5c575e1]331 <xsl:if test="(@condition=$model or not(@condition)) and
332 (@vendor=$kernel or not(@vendor))">
[d81c640]333 <xsl:apply-templates/>
334 </xsl:if>
335 </xsl:template>
336
[877cc6a]337 <xsl:template match="replaceable">
338 <xsl:choose>
339 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
340 ancestor::sect1[@id='ch-system-uclibc']">
341 <xsl:value-of select="$timezone"/>
342 </xsl:when>
343 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
344 <xsl:value-of select="$page"/>
345 </xsl:when>
346 <xsl:otherwise>
347 <xsl:text>**EDITME</xsl:text>
348 <xsl:apply-templates/>
349 <xsl:text>EDITME**</xsl:text>
350 </xsl:otherwise>
351 </xsl:choose>
352 </xsl:template>
353
354</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.