[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 |
|
---|
| 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 |
|
---|
| 25 | <!-- Run test suites?
|
---|
| 26 | 0 = none
|
---|
| 27 | 1 = only chapter06 Glibc, GCC and Binutils testsuites
|
---|
| 28 | 2 = all chapter06 testsuites
|
---|
[05ccaa9] | 29 | 3 = alias to 2
|
---|
| 30 | -->
|
---|
[877cc6a] | 31 | <xsl:param name="testsuite" select="1"/>
|
---|
| 32 |
|
---|
[05ccaa9] | 33 | <!-- Bomb on test suites failures?
|
---|
| 34 | 0 = no, I want to build the full system and review the logs
|
---|
| 35 | 1 = yes, bomb at the first test suite failure to can review the build dir
|
---|
| 36 | -->
|
---|
| 37 | <xsl:param name="bomb-testsuite" select="0"/>
|
---|
| 38 |
|
---|
[877cc6a] | 39 | <!-- Time zone -->
|
---|
[a229600] | 40 | <xsl:param name="timezone" select="GMT"/>
|
---|
[877cc6a] | 41 |
|
---|
| 42 | <!-- Page size -->
|
---|
| 43 | <xsl:param name="page" select="letter"/>
|
---|
| 44 |
|
---|
| 45 | <!-- Locale settings -->
|
---|
[a229600] | 46 | <xsl:param name="lang" select="C"/>
|
---|
| 47 | <xsl:param name="lc_all" 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
|
---|
| 57 | ((@condition=$model or not(@condition)) and
|
---|
| 58 | count(descendant::screen/userinput) > 0 and
|
---|
| 59 | count(descendant::screen/userinput) >
|
---|
| 60 | count(descendant::screen[@role='nodump']))">
|
---|
| 61 | <!-- The dirs names -->
|
---|
| 62 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 63 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 64 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 65 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 66 | <!-- The file names -->
|
---|
| 67 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 68 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 69 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 70 | <!-- The build order -->
|
---|
| 71 | <xsl:variable name="position" select="position()"/>
|
---|
| 72 | <xsl:variable name="order">
|
---|
| 73 | <xsl:choose>
|
---|
| 74 | <xsl:when test="string-length($position) = 1">
|
---|
| 75 | <xsl:text>00</xsl:text>
|
---|
| 76 | <xsl:value-of select="$position"/>
|
---|
| 77 | </xsl:when>
|
---|
| 78 | <xsl:when test="string-length($position) = 2">
|
---|
| 79 | <xsl:text>0</xsl:text>
|
---|
| 80 | <xsl:value-of select="$position"/>
|
---|
| 81 | </xsl:when>
|
---|
| 82 | <xsl:otherwise>
|
---|
| 83 | <xsl:value-of select="$position"/>
|
---|
| 84 | </xsl:otherwise>
|
---|
| 85 | </xsl:choose>
|
---|
| 86 | </xsl:variable>
|
---|
| 87 | <!-- Creating dirs and files -->
|
---|
| 88 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
| 89 | <xsl:choose>
|
---|
| 90 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
| 91 | @id='ch-system-creatingdirs' or
|
---|
| 92 | @id='ch-system-createfiles'">
|
---|
| 93 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
| 94 | </xsl:when>
|
---|
| 95 | <xsl:when test="@id='ch-tools-stripping' or
|
---|
| 96 | @id='ch-system-strippingagain'">
|
---|
| 97 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
| 98 | </xsl:when>
|
---|
| 99 | <xsl:otherwise>
|
---|
| 100 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
| 101 | </xsl:otherwise>
|
---|
| 102 | </xsl:choose>
|
---|
| 103 | <xsl:if test="(sect2[@role='installation'] and
|
---|
[83d73fb] | 104 | not(@id='bootable-kernel'))">
|
---|
[877cc6a] | 105 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
| 106 | <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
|
---|
| 107 | <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; 
</xsl:text>
|
---|
| 108 | </xsl:if>
|
---|
[83d73fb] | 109 |
|
---|
| 110 | <!-- NEW toolchain format, from inside ./sources dir unpack binutils and gcc -->
|
---|
| 111 | <xsl:if test="@id='ch-tools-embryo-toolchain' or
|
---|
| 112 | @id='ch-tools-cocoon-toolchain' or
|
---|
| 113 | @id='ch-system-butterfly-toolchain'">
|
---|
| 114 | <xsl:text>tar -xvf gcc-core-&gcc-version;.*; 
</xsl:text>
|
---|
| 115 | <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; 
</xsl:text>
|
---|
| 116 | <xsl:text>tar -xvf binutils-&binutils-version;.*; 
</xsl:text>
|
---|
[877cc6a] | 117 | </xsl:if>
|
---|
[83d73fb] | 118 | <!-- ONLY butterfly has a testsuite -->
|
---|
[b8020ac] | 119 | <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
|
---|
[83d73fb] | 120 | <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; 
</xsl:text>
|
---|
[877cc6a] | 121 | </xsl:if>
|
---|
[83d73fb] | 122 | <!-- END new toolchain format -->
|
---|
| 123 |
|
---|
[877cc6a] | 124 | <xsl:if test="@id='bootable-bootscripts'">
|
---|
| 125 | <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; 
</xsl:text>
|
---|
| 126 | </xsl:if>
|
---|
| 127 | </xsl:if>
|
---|
| 128 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
| 129 | <xsl:text>exit</xsl:text>
|
---|
| 130 | </exsl:document>
|
---|
| 131 | </xsl:if>
|
---|
| 132 | </xsl:template>
|
---|
| 133 |
|
---|
| 134 | <xsl:template match="screen">
|
---|
| 135 | <xsl:if test="(@condition=$model or not(@condition)) and
|
---|
| 136 | child::* = userinput and not(@role = 'nodump')">
|
---|
| 137 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
| 138 | </xsl:if>
|
---|
| 139 | </xsl:template>
|
---|
| 140 |
|
---|
| 141 | <xsl:template match="para/userinput">
|
---|
| 142 | <xsl:if test="(contains(string(),'test') or
|
---|
[83d73fb] | 143 | contains(string(),'check')) and
|
---|
| 144 | ($testsuite = '2' or $testsuite = '3')">
|
---|
[05ccaa9] | 145 | <xsl:choose>
|
---|
| 146 | <xsl:when test="$bomb-testsuite = '0'">
|
---|
| 147 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 148 | <xsl:text>make -k</xsl:text>
|
---|
| 149 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
| 150 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 151 | </xsl:when>
|
---|
| 152 | <xsl:otherwise>
|
---|
| 153 | <xsl:apply-templates/>
|
---|
[ae0172b] | 154 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
| 155 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 156 | <xsl:text> || true</xsl:text>
|
---|
| 157 | </xsl:if>
|
---|
| 158 | <xsl:text>
</xsl:text>
|
---|
[05ccaa9] | 159 | </xsl:otherwise>
|
---|
| 160 | </xsl:choose>
|
---|
[877cc6a] | 161 | </xsl:if>
|
---|
| 162 | </xsl:template>
|
---|
| 163 |
|
---|
| 164 | <xsl:template match="userinput" mode="screen">
|
---|
| 165 | <xsl:choose>
|
---|
| 166 | <!-- Estandarized package formats -->
|
---|
| 167 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 168 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 169 | <xsl:text>tar.*</xsl:text>
|
---|
| 170 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 171 | <xsl:text>
</xsl:text>
|
---|
| 172 | </xsl:when>
|
---|
| 173 | <!-- Avoiding a race condition in a patch -->
|
---|
| 174 | <xsl:when test="contains(string(),'debian_fixes')">
|
---|
| 175 | <xsl:value-of select="substring-before(string(),'patch')"/>
|
---|
| 176 | <xsl:text>patch -Z</xsl:text>
|
---|
| 177 | <xsl:value-of select="substring-after(string(),'patch')"/>
|
---|
| 178 | <xsl:text>
</xsl:text>
|
---|
| 179 | </xsl:when>
|
---|
| 180 | <!-- grsecurity kernel in the host? -->
|
---|
| 181 | <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
|
---|
| 182 | contains(string(),'sysctl')
|
---|
| 183 | and $grsecurity_host ='0'"/>
|
---|
| 184 | <!-- Setting $LC_ALL and $LANG for /etc/profile -->
|
---|
| 185 | <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
|
---|
| 186 | contains(string(),'export LANG=')">
|
---|
| 187 | <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
|
---|
| 188 | <xsl:text>export LC_ALL=</xsl:text>
|
---|
| 189 | <xsl:value-of select="$lc_all"/>
|
---|
| 190 | <xsl:text>
export LANG=</xsl:text>
|
---|
| 191 | <xsl:value-of select="$lang"/>
|
---|
| 192 | <xsl:text>
export INPUTRC</xsl:text>
|
---|
| 193 | <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
|
---|
| 194 | <xsl:text>
</xsl:text>
|
---|
| 195 | </xsl:when>
|
---|
| 196 | <!-- Fixing bootscripts installation -->
|
---|
| 197 | <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
|
---|
| 198 | string() = 'make install'">
|
---|
| 199 | <xsl:text>make install
</xsl:text>
|
---|
| 200 | <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;
</xsl:text>
|
---|
| 201 | </xsl:when>
|
---|
| 202 | <!-- Compile the keymap into the kernel? -->
|
---|
| 203 | <xsl:when test="contains(string(),'defkeymap') and
|
---|
| 204 | $keymap = 'none'"/>
|
---|
| 205 | <!-- Copying the kernel config file -->
|
---|
| 206 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 207 | <xsl:text>make mrproper
</xsl:text>
|
---|
| 208 | <xsl:text>cp -v /sources/kernel-config .config
</xsl:text>
|
---|
| 209 | </xsl:when>
|
---|
| 210 | <!-- No interactive commands are needed if the .config file is the proper one -->
|
---|
| 211 | <xsl:when test="string() = 'make menuconfig'"/>
|
---|
| 212 | <!-- For uClibc we need to cd to the Gettext package -->
|
---|
| 213 | <xsl:when test="contains(string(),'cd gettext-runtime/')">
|
---|
| 214 | <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
|
---|
| 215 | <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
|
---|
| 216 | <xsl:text>
</xsl:text>
|
---|
| 217 | </xsl:when>
|
---|
| 218 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
[a229600] | 219 | <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
[877cc6a] | 220 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
| 221 | (contains(string(),'check') or
|
---|
| 222 | contains(string(),'distclean') or
|
---|
[a229600] | 223 | contains(string(),'dummy'))">
|
---|
| 224 | <xsl:choose>
|
---|
| 225 | <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
|
---|
| 226 | <xsl:otherwise>
|
---|
[05ccaa9] | 227 | <xsl:if test="not(contains(string(),'check'))">
|
---|
| 228 | <xsl:apply-templates/>
|
---|
| 229 | <xsl:text>
</xsl:text>
|
---|
| 230 | </xsl:if>
|
---|
[a229600] | 231 | <xsl:if test="contains(string(),'check')">
|
---|
[05ccaa9] | 232 | <xsl:choose>
|
---|
| 233 | <xsl:when test="$bomb-testsuite = '0'">
|
---|
| 234 | <xsl:value-of select="substring-before(string(),'check')"/>
|
---|
| 235 | <xsl:text>-k check</xsl:text>
|
---|
| 236 | <xsl:value-of select="substring-after(string(),'check')"/>
|
---|
| 237 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 238 | </xsl:when>
|
---|
| 239 | <xsl:otherwise>
|
---|
| 240 | <xsl:apply-templates/>
|
---|
[ae0172b] | 241 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
| 242 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 243 | <xsl:text> || true</xsl:text>
|
---|
| 244 | </xsl:if>
|
---|
| 245 | <xsl:text>
</xsl:text>
|
---|
[05ccaa9] | 246 | </xsl:otherwise>
|
---|
| 247 | </xsl:choose>
|
---|
[a229600] | 248 | </xsl:if>
|
---|
| 249 | </xsl:otherwise>
|
---|
| 250 | </xsl:choose>
|
---|
| 251 | </xsl:when>
|
---|
[83d73fb] | 252 | <!-- Fixing butterfly toolchain test suites run -->
|
---|
[ae0172b] | 253 | <xsl:when test="string() = 'make -k check' or string() = 'make check'">
|
---|
[877cc6a] | 254 | <xsl:choose>
|
---|
[83d73fb] | 255 | <xsl:when test="$testsuite != '0'">
|
---|
[05ccaa9] | 256 | <xsl:apply-templates/>
|
---|
| 257 | <xsl:choose>
|
---|
| 258 | <xsl:when test="$bomb-testsuite = '0'">
|
---|
| 259 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 260 | </xsl:when>
|
---|
| 261 | <xsl:otherwise>
|
---|
[5106d3e] | 262 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
[ae0172b] | 263 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 264 | <xsl:text> || true</xsl:text>
|
---|
| 265 | </xsl:if>
|
---|
[5106d3e] | 266 | <xsl:text>
</xsl:text>
|
---|
[05ccaa9] | 267 | </xsl:otherwise>
|
---|
| 268 | </xsl:choose>
|
---|
[877cc6a] | 269 | </xsl:when>
|
---|
| 270 | </xsl:choose>
|
---|
| 271 | </xsl:when>
|
---|
[83d73fb] | 272 | <!-- Fixing Glbc test suite -->
|
---|
| 273 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
[877cc6a] | 274 | <xsl:choose>
|
---|
| 275 | <xsl:when test="$testsuite != '0'">
|
---|
[83d73fb] | 276 | <xsl:value-of select="substring-before(string(),'> glibc-')"/>
|
---|
[05ccaa9] | 277 | <xsl:choose>
|
---|
| 278 | <xsl:when test="$bomb-testsuite = '0'">
|
---|
| 279 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 280 | </xsl:when>
|
---|
| 281 | <xsl:otherwise>
|
---|
[ae0172b] | 282 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
| 283 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 284 | <xsl:text> || true</xsl:text>
|
---|
| 285 | </xsl:if>
|
---|
| 286 | <xsl:text>
</xsl:text>
|
---|
[05ccaa9] | 287 | </xsl:otherwise>
|
---|
| 288 | </xsl:choose>
|
---|
[877cc6a] | 289 | </xsl:when>
|
---|
| 290 | </xsl:choose>
|
---|
| 291 | </xsl:when>
|
---|
| 292 | <!-- Don't stop on strip run and chapter05 GCC installation test-->
|
---|
| 293 | <xsl:when test="contains(string(),'strip ') or
|
---|
| 294 | ancestor::sect2[@id='testing-gcc'] and
|
---|
| 295 | not(contains(string(),'EOF'))">
|
---|
| 296 | <xsl:apply-templates/>
|
---|
| 297 | <xsl:text> || true
</xsl:text>
|
---|
| 298 | </xsl:when>
|
---|
| 299 | <!-- The rest of commands -->
|
---|
| 300 | <xsl:otherwise>
|
---|
| 301 | <xsl:apply-templates/>
|
---|
| 302 | <xsl:text>
</xsl:text>
|
---|
| 303 | </xsl:otherwise>
|
---|
| 304 | </xsl:choose>
|
---|
| 305 | </xsl:template>
|
---|
| 306 |
|
---|
[83d73fb] | 307 | <xsl:template match="literal">
|
---|
| 308 | <xsl:if test="@condition=$model or not(@condition)">
|
---|
| 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:when test="ancestor::sect1[@id='bootable-kernel']">
|
---|
| 323 | <xsl:value-of select="$keymap"/>
|
---|
| 324 | </xsl:when>
|
---|
| 325 | <xsl:otherwise>
|
---|
| 326 | <xsl:text>**EDITME</xsl:text>
|
---|
| 327 | <xsl:apply-templates/>
|
---|
| 328 | <xsl:text>EDITME**</xsl:text>
|
---|
| 329 | </xsl:otherwise>
|
---|
| 330 | </xsl:choose>
|
---|
| 331 | </xsl:template>
|
---|
| 332 |
|
---|
| 333 | </xsl:stylesheet>
|
---|