[0170229] | 1 | <?xml version="1.0"?>
|
---|
| 2 | <!DOCTYPE xsl:stylesheet [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 |
|
---|
[3a5c9cc] | 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 |
|
---|
| 14 | <!-- XSLT stylesheet to create shell scripts from LFS books. -->
|
---|
| 15 |
|
---|
[6db1464] | 16 | <!-- Run test suites?
|
---|
| 17 | 0 = none
|
---|
| 18 | 1 = only chapter06 Glibc, GCC and Binutils testsuites
|
---|
| 19 | 2 = all chapter06 testsuites
|
---|
| 20 | 3 = all chapter05 and chapter06 testsuites-->
|
---|
| 21 | <xsl:param name="testsuite" select="1"/>
|
---|
[0170229] | 22 |
|
---|
| 23 | <!-- Install vim-lang package? -->
|
---|
| 24 | <xsl:param name="vim-lang" select="1"/>
|
---|
| 25 |
|
---|
[ad71d98] | 26 | <!-- Time zone -->
|
---|
[e35e794] | 27 | <xsl:param name="timezone" select="GMT"/>
|
---|
[ad71d98] | 28 |
|
---|
| 29 | <!-- Page size -->
|
---|
| 30 | <xsl:param name="page" select="letter"/>
|
---|
| 31 |
|
---|
[d87b293] | 32 | <!-- Locale settings -->
|
---|
[e35e794] | 33 | <xsl:param name="lang" select="C"/>
|
---|
[d87b293] | 34 |
|
---|
[0170229] | 35 | <xsl:template match="/">
|
---|
| 36 | <xsl:apply-templates select="//sect1"/>
|
---|
| 37 | </xsl:template>
|
---|
| 38 |
|
---|
| 39 | <xsl:template match="sect1">
|
---|
| 40 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 41 | count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
---|
| 42 | <!-- The dirs names -->
|
---|
| 43 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 44 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 45 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 46 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 47 | <!-- The file names -->
|
---|
| 48 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 49 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 50 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 51 | <!-- The build order -->
|
---|
| 52 | <xsl:variable name="position" select="position()"/>
|
---|
| 53 | <xsl:variable name="order">
|
---|
| 54 | <xsl:choose>
|
---|
| 55 | <xsl:when test="string-length($position) = 1">
|
---|
| 56 | <xsl:text>00</xsl:text>
|
---|
| 57 | <xsl:value-of select="$position"/>
|
---|
| 58 | </xsl:when>
|
---|
| 59 | <xsl:when test="string-length($position) = 2">
|
---|
| 60 | <xsl:text>0</xsl:text>
|
---|
| 61 | <xsl:value-of select="$position"/>
|
---|
| 62 | </xsl:when>
|
---|
| 63 | <xsl:otherwise>
|
---|
| 64 | <xsl:value-of select="$position"/>
|
---|
| 65 | </xsl:otherwise>
|
---|
| 66 | </xsl:choose>
|
---|
| 67 | </xsl:variable>
|
---|
| 68 | <!-- Creating dirs and files -->
|
---|
| 69 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
| 70 | <xsl:choose>
|
---|
| 71 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
| 72 | @id='ch-system-creatingdirs' or
|
---|
| 73 | @id='ch-system-createfiles'">
|
---|
| 74 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
| 75 | </xsl:when>
|
---|
| 76 | <xsl:when test="@id='ch-tools-stripping' or
|
---|
| 77 | @id='ch-system-strippingagain'">
|
---|
| 78 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
| 79 | </xsl:when>
|
---|
| 80 | <xsl:otherwise>
|
---|
| 81 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
| 82 | </xsl:otherwise>
|
---|
| 83 | </xsl:choose>
|
---|
[3a5c9cc] | 84 | <xsl:if test="sect2[@role='installation']">
|
---|
[0170229] | 85 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
| 86 | <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
|
---|
| 87 | <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
---|
| 88 | </xsl:if>
|
---|
| 89 | </xsl:if>
|
---|
| 90 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
[6db1464] | 91 | <xsl:if test="$testsuite='3' and @id='ch-tools-glibc'">
|
---|
| 92 | <xsl:copy-of select="//sect1[@id='ch-system-glibc']/sect2[2]/screen[@role='nodump']"/>
|
---|
| 93 | <xsl:text>
</xsl:text>
|
---|
| 94 | </xsl:if>
|
---|
[0170229] | 95 | <xsl:text>exit</xsl:text>
|
---|
| 96 | </exsl:document>
|
---|
| 97 | </xsl:if>
|
---|
| 98 | </xsl:template>
|
---|
| 99 |
|
---|
| 100 | <xsl:template match="screen">
|
---|
[6db1464] | 101 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
| 102 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
[0170229] | 103 | </xsl:if>
|
---|
| 104 | </xsl:template>
|
---|
| 105 |
|
---|
| 106 | <xsl:template match="para/userinput">
|
---|
[6db1464] | 107 | <xsl:if test="(contains(string(),'test') or
|
---|
| 108 | contains(string(),'check')) and
|
---|
| 109 | (($testsuite = '2' and
|
---|
| 110 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
| 111 | $testsuite = '3')">
|
---|
[0170229] | 112 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 113 | <xsl:text>make -k</xsl:text>
|
---|
| 114 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
[e35e794] | 115 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[0170229] | 116 | </xsl:if>
|
---|
| 117 | </xsl:template>
|
---|
| 118 |
|
---|
| 119 | <xsl:template match="userinput" mode="screen">
|
---|
| 120 | <xsl:choose>
|
---|
| 121 | <!-- Estandarized package formats -->
|
---|
| 122 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 123 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 124 | <xsl:text>tar.*</xsl:text>
|
---|
| 125 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 126 | <xsl:text>
</xsl:text>
|
---|
| 127 | </xsl:when>
|
---|
| 128 | <!-- Avoiding a race condition in a patch -->
|
---|
| 129 | <xsl:when test="contains(string(),'debian_fixes')">
|
---|
| 130 | <xsl:value-of select="substring-before(string(),'patch')"/>
|
---|
| 131 | <xsl:text>patch -Z</xsl:text>
|
---|
| 132 | <xsl:value-of select="substring-after(string(),'patch')"/>
|
---|
| 133 | <xsl:text>
</xsl:text>
|
---|
| 134 | </xsl:when>
|
---|
[aab51df] | 135 | <!-- Setting $LANG for /etc/profile -->
|
---|
[dd810ea] | 136 | <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
|
---|
| 137 | contains(string(),'export LANG=')">
|
---|
| 138 | <xsl:value-of select="substring-before(string(),'export LANG=')"/>
|
---|
[d87b293] | 139 | <xsl:text>export LANG=</xsl:text>
|
---|
| 140 | <xsl:value-of select="$lang"/>
|
---|
[7636ee4] | 141 | <xsl:value-of select="substring-after(string(),'modifiers>')"/>
|
---|
[dd810ea] | 142 | <xsl:text>
</xsl:text>
|
---|
| 143 | </xsl:when>
|
---|
[0170229] | 144 | <!-- Copying the kernel config file -->
|
---|
| 145 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 146 | <xsl:text>make mrproper
</xsl:text>
|
---|
| 147 | <xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
---|
| 148 | </xsl:when>
|
---|
| 149 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
[e35e794] | 150 | <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
[0170229] | 151 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
| 152 | (contains(string(),'check') or
|
---|
[e35e794] | 153 | contains(string(),'dummy'))">
|
---|
| 154 | <xsl:choose>
|
---|
| 155 | <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
|
---|
| 156 | <xsl:otherwise>
|
---|
| 157 | <xsl:apply-templates/>
|
---|
| 158 | <xsl:if test="contains(string(),'check')">
|
---|
| 159 | <xsl:text> >> $TEST_LOG 2>&1 || true</xsl:text>
|
---|
| 160 | </xsl:if>
|
---|
| 161 | <xsl:text>
</xsl:text>
|
---|
| 162 | </xsl:otherwise>
|
---|
| 163 | </xsl:choose>
|
---|
| 164 | </xsl:when>
|
---|
[0170229] | 165 | <!-- Fixing toolchain test suites run -->
|
---|
| 166 | <xsl:when test="string() = 'make check' or
|
---|
| 167 | string() = 'make -k check'">
|
---|
| 168 | <xsl:choose>
|
---|
[6db1464] | 169 | <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
|
---|
| 170 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
| 171 | $testsuite = '3'">
|
---|
[e35e794] | 172 | <xsl:text>make -k check >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[6db1464] | 173 | </xsl:when>
|
---|
[0170229] | 174 | </xsl:choose>
|
---|
| 175 | </xsl:when>
|
---|
| 176 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
| 177 | <xsl:choose>
|
---|
[6db1464] | 178 | <xsl:when test="$testsuite != '0'">
|
---|
[e35e794] | 179 | <xsl:value-of select="substring-before(string(),'2>&1')"/>
|
---|
| 180 | <xsl:text>>> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[6db1464] | 181 | </xsl:when>
|
---|
[0170229] | 182 | </xsl:choose>
|
---|
| 183 | </xsl:when>
|
---|
| 184 | <xsl:when test="contains(string(),'test_summary') or
|
---|
| 185 | contains(string(),'expect -c')">
|
---|
| 186 | <xsl:choose>
|
---|
[6db1464] | 187 | <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
|
---|
| 188 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
| 189 | $testsuite = '3'">
|
---|
[0170229] | 190 | <xsl:apply-templates/>
|
---|
[e35e794] | 191 | <xsl:if test="contains(string(),'test_summary')">
|
---|
| 192 | <xsl:text> >> $TEST_LOG</xsl:text>
|
---|
| 193 | </xsl:if>
|
---|
[0170229] | 194 | <xsl:text>
</xsl:text>
|
---|
[6db1464] | 195 | </xsl:when>
|
---|
[0170229] | 196 | </xsl:choose>
|
---|
| 197 | </xsl:when>
|
---|
| 198 | <!-- Don't stop on strip run -->
|
---|
| 199 | <xsl:when test="contains(string(),'strip ')">
|
---|
| 200 | <xsl:apply-templates/>
|
---|
| 201 | <xsl:text> || true
</xsl:text>
|
---|
| 202 | </xsl:when>
|
---|
| 203 | <!-- The rest of commands -->
|
---|
| 204 | <xsl:otherwise>
|
---|
| 205 | <xsl:apply-templates/>
|
---|
| 206 | <xsl:text>
</xsl:text>
|
---|
| 207 | </xsl:otherwise>
|
---|
| 208 | </xsl:choose>
|
---|
| 209 | </xsl:template>
|
---|
| 210 |
|
---|
| 211 | <xsl:template match="replaceable">
|
---|
| 212 | <xsl:choose>
|
---|
| 213 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
[ad71d98] | 214 | <xsl:value-of select="$timezone"/>
|
---|
[0170229] | 215 | </xsl:when>
|
---|
| 216 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
[ad71d98] | 217 | <xsl:value-of select="$page"/>
|
---|
[0170229] | 218 | </xsl:when>
|
---|
| 219 | <xsl:otherwise>
|
---|
| 220 | <xsl:text>**EDITME</xsl:text>
|
---|
| 221 | <xsl:apply-templates/>
|
---|
| 222 | <xsl:text>EDITME**</xsl:text>
|
---|
| 223 | </xsl:otherwise>
|
---|
| 224 | </xsl:choose>
|
---|
| 225 | </xsl:template>
|
---|
| 226 |
|
---|
| 227 | </xsl:stylesheet>
|
---|