[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
|
---|
[056486c] | 20 | 3 = all chapter05 and chapter06 testsuites
|
---|
| 21 | -->
|
---|
[6db1464] | 22 | <xsl:param name="testsuite" select="1"/>
|
---|
[0170229] | 23 |
|
---|
[056486c] | 24 | <!-- Bomb on test suites failures?
|
---|
| 25 | 0 = no, I want to build the full system and review the logs
|
---|
| 26 | 1 = yes, bomb at the first test suite failure to can review the build dir
|
---|
| 27 | -->
|
---|
| 28 | <xsl:param name="bomb-testsuite" select="0"/>
|
---|
| 29 |
|
---|
[0170229] | 30 | <!-- Install vim-lang package? -->
|
---|
| 31 | <xsl:param name="vim-lang" select="1"/>
|
---|
| 32 |
|
---|
[ad71d98] | 33 | <!-- Time zone -->
|
---|
[e35e794] | 34 | <xsl:param name="timezone" select="GMT"/>
|
---|
[ad71d98] | 35 |
|
---|
| 36 | <!-- Page size -->
|
---|
| 37 | <xsl:param name="page" select="letter"/>
|
---|
| 38 |
|
---|
[d87b293] | 39 | <!-- Locale settings -->
|
---|
[e35e794] | 40 | <xsl:param name="lang" select="C"/>
|
---|
[d87b293] | 41 |
|
---|
[0170229] | 42 | <xsl:template match="/">
|
---|
| 43 | <xsl:apply-templates select="//sect1"/>
|
---|
| 44 | </xsl:template>
|
---|
| 45 |
|
---|
| 46 | <xsl:template match="sect1">
|
---|
| 47 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 48 | count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
---|
| 49 | <!-- The dirs names -->
|
---|
| 50 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 51 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 52 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 53 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 54 | <!-- The file names -->
|
---|
| 55 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 56 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 57 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 58 | <!-- The build order -->
|
---|
| 59 | <xsl:variable name="position" select="position()"/>
|
---|
| 60 | <xsl:variable name="order">
|
---|
| 61 | <xsl:choose>
|
---|
| 62 | <xsl:when test="string-length($position) = 1">
|
---|
| 63 | <xsl:text>00</xsl:text>
|
---|
| 64 | <xsl:value-of select="$position"/>
|
---|
| 65 | </xsl:when>
|
---|
| 66 | <xsl:when test="string-length($position) = 2">
|
---|
| 67 | <xsl:text>0</xsl:text>
|
---|
| 68 | <xsl:value-of select="$position"/>
|
---|
| 69 | </xsl:when>
|
---|
| 70 | <xsl:otherwise>
|
---|
| 71 | <xsl:value-of select="$position"/>
|
---|
| 72 | </xsl:otherwise>
|
---|
| 73 | </xsl:choose>
|
---|
| 74 | </xsl:variable>
|
---|
| 75 | <!-- Creating dirs and files -->
|
---|
| 76 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
| 77 | <xsl:choose>
|
---|
| 78 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
| 79 | @id='ch-system-creatingdirs' or
|
---|
| 80 | @id='ch-system-createfiles'">
|
---|
| 81 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
| 82 | </xsl:when>
|
---|
| 83 | <xsl:when test="@id='ch-tools-stripping' or
|
---|
| 84 | @id='ch-system-strippingagain'">
|
---|
| 85 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
| 86 | </xsl:when>
|
---|
| 87 | <xsl:otherwise>
|
---|
| 88 | <xsl:text>#!/bin/sh
set -e

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