source: HLFS/hlfs.xsl@ 1870b56

ablfs-more legacy trunk
Last change on this file since 1870b56 was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

  • Property mode set to 100644
File size: 13.3 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<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 xmlns:exsl="http://exslt.org/common"
9 extension-element-prefixes="exsl"
10 version="1.0">
11
12<!-- XSLT stylesheet to create shell scripts from HLFS books. -->
13
14 <!-- What libc implentation must be used? -->
15 <xsl:param name="model" select="glibc"/>
16
[5c575e1]17 <!-- What kernel serie must be used? -->
18 <xsl:param name="kernel" select="2.6"/>
19
[877cc6a]20 <!-- Is the host kernel using grsecurity? -->
[401f81e]21 <xsl:param name="grsecurity_host" select="n"/>
[877cc6a]22
23 <!-- Run test suites?
24 0 = none
25 1 = only chapter06 Glibc, GCC and Binutils testsuites
26 2 = all chapter06 testsuites
[28f4756]27 3 = alias to 2
28 -->
[877cc6a]29 <xsl:param name="testsuite" select="1"/>
30
[28f4756]31 <!-- Bomb on test suites failures?
[401f81e]32 n = no, I want to build the full system and review the logs
33 y = yes, bomb at the first test suite failure to can review the build dir
[28f4756]34 -->
[401f81e]35 <xsl:param name="bomb-testsuite" select="n"/>
[28f4756]36
[d035526]37 <!-- Additional features -->
38 <xsl:param name="features">,ssp,aslr,pax,hardened_tmp,warnings,misc,blowfish,</xsl:param>
39
[877cc6a]40 <!-- Time zone -->
[a229600]41 <xsl:param name="timezone" select="GMT"/>
[877cc6a]42
43 <!-- Page size -->
44 <xsl:param name="page" select="letter"/>
45
46 <!-- Locale settings -->
[a229600]47 <xsl:param name="lang" select="C"/>
[877cc6a]48
49 <xsl:template match="/">
50 <xsl:apply-templates select="//sect1"/>
51 </xsl:template>
52
53 <xsl:template match="sect1">
54 <xsl:if test="(../@id='chapter-temporary-tools' or
55 ../@id='chapter-building-system' or
56 ../@id='chapter-bootable') and
[c1f28d5]57 (count(descendant::screen/userinput) &gt; 0 and
[877cc6a]58 count(descendant::screen/userinput) &gt;
[c1f28d5]59 count(descendant::screen[@role='nodump'])) and
60 ((@condition=$model or not(@condition)) and
61 (@vendor=$kernel or not(@vendor)))">
[877cc6a]62 <!-- The dirs names -->
63 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
64 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
65 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
66 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
67 <!-- The file names -->
68 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
69 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
70 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
71 <!-- The build order -->
72 <xsl:variable name="position" select="position()"/>
73 <xsl:variable name="order">
74 <xsl:choose>
75 <xsl:when test="string-length($position) = 1">
76 <xsl:text>00</xsl:text>
77 <xsl:value-of select="$position"/>
78 </xsl:when>
79 <xsl:when test="string-length($position) = 2">
80 <xsl:text>0</xsl:text>
81 <xsl:value-of select="$position"/>
82 </xsl:when>
83 <xsl:otherwise>
84 <xsl:value-of select="$position"/>
85 </xsl:otherwise>
86 </xsl:choose>
87 </xsl:variable>
88 <!-- Creating dirs and files -->
89 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
[1330ebc]90 <xsl:choose>
91 <xsl:when test="@id='ch-system-creatingdirs' or
[7d6fe10]92 @id='ch-system-createfiles' or
[1a39790]93 @id='ch-system-changingowner' or
[33a4e41]94 @id='ch-system-strippingagain' or
[df5553b]95 @id='ch-system-stripping'">
[1330ebc]96 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
97 </xsl:when>
98 <xsl:otherwise>
99 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
100 </xsl:otherwise>
101 </xsl:choose>
[5f4982d]102 <xsl:if test="not(@id='ch-tools-stripping') and
[33a4e41]103 not(@id='ch-system-strippingagain') and
[df5553b]104 not(@id='ch-system-stripping')">
[5f4982d]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>
[4d15d7f]113 <!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
[68713c9]114 <xsl:if test="@id='ch-tools-embryo-toolchain' or
[d81c640]115 @id='ch-tools-cocoon-toolchain' or
116 @id='ch-system-butterfly-toolchain'">
117 <xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
118 <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
[877cc6a]119 </xsl:if>
[68713c9]120 <xsl:if test="@id='ch-tools-cocoon-toolchain' or
[30d1215]121 @id='ch-system-butterfly-toolchain'">
122 <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
123 </xsl:if>
[d81c640]124 <!-- ONLY butterfly has a testsuite -->
[b2489fb]125 <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
[d81c640]126 <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
[877cc6a]127 </xsl:if>
[4d15d7f]128 <!-- END SVN toolchain format -->
[877cc6a]129 </xsl:if>
130 <xsl:apply-templates select=".//para/userinput | .//screen"/>
[68713c9]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>
[877cc6a]135 <xsl:text>exit</xsl:text>
136 </exsl:document>
137 </xsl:if>
138 </xsl:template>
139
140 <xsl:template match="screen">
141 <xsl:if test="(@condition=$model or not(@condition)) and
[5c575e1]142 (@vendor=$kernel or not(@vendor)) and
[d035526]143 child::* = userinput and (not(@role) or
144 (@role and contains($features,concat(',',@role,','))))">
[877cc6a]145 <xsl:apply-templates select="userinput" mode="screen"/>
146 </xsl:if>
147 </xsl:template>
148
149 <xsl:template match="para/userinput">
150 <xsl:if test="(contains(string(),'test') or
[d81c640]151 contains(string(),'check')) and
152 ($testsuite = '2' or $testsuite = '3')">
[28f4756]153 <xsl:choose>
[401f81e]154 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]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/>
[a1f1969]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>
[28f4756]167 </xsl:otherwise>
168 </xsl:choose>
[877cc6a]169 </xsl:if>
170 </xsl:template>
171
172 <xsl:template match="userinput" mode="screen">
173 <xsl:choose>
174 <!-- grsecurity kernel in the host? -->
175 <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
176 contains(string(),'sysctl')
[401f81e]177 and $grsecurity_host ='n'"/>
[05760bc]178 <!-- Setting $LANG for /etc/profile -->
[877cc6a]179 <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
180 contains(string(),'export LANG=')">
[05760bc]181 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
182 <xsl:text>export LANG=</xsl:text>
[877cc6a]183 <xsl:value-of select="$lang"/>
[05760bc]184 <xsl:value-of select="substring-after(string(),'CC]')"/>
[877cc6a]185 <xsl:text>&#xA;</xsl:text>
186 </xsl:when>
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 needed if the .config file is the proper one -->
193 <xsl:when test="string() = 'make menuconfig'"/>
[3d75bc2]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>
[877cc6a]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>
207 <!-- The Coreutils and Module-Init-Tools test suites are optional -->
[a229600]208 <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
[877cc6a]209 ancestor::sect1[@id='ch-system-module-init-tools']) and
210 (contains(string(),'check') or
211 contains(string(),'distclean') or
[a229600]212 contains(string(),'dummy'))">
213 <xsl:choose>
214 <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
215 <xsl:otherwise>
[28f4756]216 <xsl:if test="not(contains(string(),'check'))">
217 <xsl:apply-templates/>
218 <xsl:text>&#xA;</xsl:text>
219 </xsl:if>
[a229600]220 <xsl:if test="contains(string(),'check')">
[28f4756]221 <xsl:choose>
[401f81e]222 <xsl:when test="$bomb-testsuite = 'n'">
[28f4756]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/>
[a1f1969]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>
[28f4756]235 </xsl:otherwise>
236 </xsl:choose>
[a229600]237 </xsl:if>
238 </xsl:otherwise>
239 </xsl:choose>
240 </xsl:when>
[3d75bc2]241 <!-- Fixing butterfly toolchain test suite run -->
242 <xsl:when test="ancestor::sect1[@id='ch-system-butterfly-toolchain']
243 and string() = 'make -k check'">
[877cc6a]244 <xsl:choose>
[3d75bc2]245 <xsl:when test="$testsuite != '0'">
[28f4756]246 <xsl:choose>
[401f81e]247 <xsl:when test="$bomb-testsuite = 'n'">
[ff43bb8]248 <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
[28f4756]249 </xsl:when>
250 <xsl:otherwise>
[ff43bb8]251 <xsl:apply-templates/>
[f98695c]252 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
[a1f1969]253 <xsl:if test="contains(string(),' -k ')">
254 <xsl:text> || true</xsl:text>
255 </xsl:if>
[f98695c]256 <xsl:text>&#xA;</xsl:text>
[28f4756]257 </xsl:otherwise>
258 </xsl:choose>
[877cc6a]259 </xsl:when>
260 </xsl:choose>
261 </xsl:when>
[d81c640]262 <!-- Fixing Glbc test suite -->
[3d75bc2]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>
[d81c640]272 <xsl:when test="contains(string(),'glibc-check-log')">
[877cc6a]273 <xsl:choose>
274 <xsl:when test="$testsuite != '0'">
[ff43bb8]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>
[877cc6a]277 </xsl:when>
278 </xsl:choose>
279 </xsl:when>
[ecfa220]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>
[39f5f3e]286 <!-- Fixing Butterfly sanity checks -->
287 <xsl:when test="contains(string(),'./fortify-test')
288 or contains(string(),'./ssp-test')">
[b6f6212]289 <xsl:text>! </xsl:text>
[39f5f3e]290 <xsl:apply-templates/>
291 <xsl:text>&#xA;</xsl:text>
292 </xsl:when>
[ff43bb8]293 <!-- Don't stop on strip run -->
[85077e7]294 <xsl:when test="contains(string(),'strip ')">
[877cc6a]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
[d81c640]306 <xsl:template match="literal">
[5c575e1]307 <xsl:if test="(@condition=$model or not(@condition)) and
308 (@vendor=$kernel or not(@vendor))">
[d81c640]309 <xsl:apply-templates/>
310 </xsl:if>
311 </xsl:template>
312
[877cc6a]313 <xsl:template match="replaceable">
314 <xsl:choose>
315 <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
316 ancestor::sect1[@id='ch-system-uclibc']">
317 <xsl:value-of select="$timezone"/>
318 </xsl:when>
319 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
320 <xsl:value-of select="$page"/>
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.