source: HLFS/hlfs.xsl@ 6eef5ef

experimental
Last change on this file since 6eef5ef was d87b293, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Set the actual LANG and LC_ALL values inside the generated scripts instead of exported envars.

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