[557fe91] | 1 | <?xml version="1.0"?>
|
---|
[db181c47] | 2 | <!DOCTYPE xsl:stylesheet [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 |
|
---|
[877cc6a] | 7 | <!-- $Id$ -->
|
---|
| 8 |
|
---|
[557fe91] | 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 |
|
---|
[63b2859] | 14 | <!-- XSLT stylesheet to create shell scripts from LFS books. -->
|
---|
[557fe91] | 15 |
|
---|
[31d6944] | 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"/>
|
---|
[01e51a1] | 22 |
|
---|
[db181c47] | 23 | <!-- Install vim-lang package? -->
|
---|
| 24 | <xsl:param name="vim-lang" select="1"/>
|
---|
| 25 |
|
---|
[877cc6a] | 26 | <!-- Time zone -->
|
---|
[a229600] | 27 | <xsl:param name="timezone" select="GMT"/>
|
---|
[877cc6a] | 28 |
|
---|
| 29 | <!-- Page size -->
|
---|
| 30 | <xsl:param name="page" select="letter"/>
|
---|
| 31 |
|
---|
| 32 | <!-- Locale settings -->
|
---|
[a229600] | 33 | <xsl:param name="lang" select="C"/>
|
---|
[877cc6a] | 34 |
|
---|
[557fe91] | 35 | <xsl:template match="/">
|
---|
| 36 | <xsl:apply-templates select="//sect1"/>
|
---|
| 37 | </xsl:template>
|
---|
| 38 |
|
---|
| 39 | <xsl:template match="sect1">
|
---|
[c4cf6de] | 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">
|
---|
[76fad58] | 70 | <xsl:choose>
|
---|
| 71 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
| 72 | @id='ch-system-creatingdirs' or
|
---|
| 73 | @id='ch-system-createfiles'">
|
---|
[fd691b4] | 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>
|
---|
[76fad58] | 79 | </xsl:when>
|
---|
| 80 | <xsl:otherwise>
|
---|
[fd691b4] | 81 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
[76fad58] | 82 | </xsl:otherwise>
|
---|
| 83 | </xsl:choose>
|
---|
[0d52034] | 84 | <xsl:if test="sect2[@role='installation']">
|
---|
[fd691b4] | 85 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
[db181c47] | 86 | <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
|
---|
[f0eb956] | 87 | <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
---|
[db181c47] | 88 | </xsl:if>
|
---|
[44f88e3] | 89 | </xsl:if>
|
---|
[db9cec6] | 90 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
[31d6944] | 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>
|
---|
[816f3f43] | 95 | <xsl:text>exit</xsl:text>
|
---|
[c4cf6de] | 96 | </exsl:document>
|
---|
| 97 | </xsl:if>
|
---|
[557fe91] | 98 | </xsl:template>
|
---|
| 99 |
|
---|
| 100 | <xsl:template match="screen">
|
---|
[31d6944] | 101 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
| 102 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
[557fe91] | 103 | </xsl:if>
|
---|
| 104 | </xsl:template>
|
---|
| 105 |
|
---|
[db9cec6] | 106 | <xsl:template match="para/userinput">
|
---|
[31d6944] | 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')">
|
---|
[3eb60fa] | 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')"/>
|
---|
[a229600] | 115 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[db9cec6] | 116 | </xsl:if>
|
---|
| 117 | </xsl:template>
|
---|
| 118 |
|
---|
| 119 | <xsl:template match="userinput" mode="screen">
|
---|
[3eb60fa] | 120 | <xsl:choose>
|
---|
[fd691b4] | 121 | <!-- Estandarized package formats -->
|
---|
[92568bf] | 122 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 123 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
[be9970b] | 124 | <xsl:text>tar.*</xsl:text>
|
---|
[92568bf] | 125 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
[fd691b4] | 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>
|
---|
[83d73fb] | 135 | <!-- Fix Udev reinstallation after a build failure -->
|
---|
| 136 | <xsl:when test="contains(string(),'firmware,udev')">
|
---|
| 137 | <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then
</xsl:text>
|
---|
| 138 | <xsl:apply-templates/>
|
---|
| 139 | <xsl:text>
fi
</xsl:text>
|
---|
| 140 | </xsl:when>
|
---|
[877cc6a] | 141 | <!-- Setting $LANG for /etc/profile -->
|
---|
| 142 | <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
|
---|
| 143 | contains(string(),'export LANG=')">
|
---|
| 144 | <xsl:value-of select="substring-before(string(),'export LANG=')"/>
|
---|
| 145 | <xsl:text>export LANG=</xsl:text>
|
---|
| 146 | <xsl:value-of select="$lang"/>
|
---|
[71445e7] | 147 | <xsl:value-of select="substring-after(string(),'modifiers>')"/>
|
---|
[877cc6a] | 148 | <xsl:text>
</xsl:text>
|
---|
| 149 | </xsl:when>
|
---|
[fd691b4] | 150 | <!-- Copying the kernel config file -->
|
---|
| 151 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 152 | <xsl:text>make mrproper
</xsl:text>
|
---|
| 153 | <xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
---|
[92568bf] | 154 | </xsl:when>
|
---|
[4e9a3b3] | 155 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
[a229600] | 156 | <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
[4e9a3b3] | 157 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
[79f7cf9] | 158 | (contains(string(),'check') or
|
---|
[a229600] | 159 | contains(string(),'dummy'))">
|
---|
| 160 | <xsl:choose>
|
---|
| 161 | <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
|
---|
| 162 | <xsl:otherwise>
|
---|
| 163 | <xsl:apply-templates/>
|
---|
| 164 | <xsl:if test="contains(string(),'check')">
|
---|
| 165 | <xsl:text> >> $TEST_LOG 2>&1 || true</xsl:text>
|
---|
| 166 | </xsl:if>
|
---|
| 167 | <xsl:text>
</xsl:text>
|
---|
| 168 | </xsl:otherwise>
|
---|
| 169 | </xsl:choose>
|
---|
| 170 | </xsl:when>
|
---|
[fd691b4] | 171 | <!-- Fixing toolchain test suites run -->
|
---|
[01e51a1] | 172 | <xsl:when test="string() = 'make check' or
|
---|
| 173 | string() = 'make -k check'">
|
---|
| 174 | <xsl:choose>
|
---|
[31d6944] | 175 | <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
|
---|
| 176 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
| 177 | $testsuite = '3'">
|
---|
[a229600] | 178 | <xsl:text>make -k check >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[31d6944] | 179 | </xsl:when>
|
---|
[fd691b4] | 180 | </xsl:choose>
|
---|
| 181 | </xsl:when>
|
---|
| 182 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
| 183 | <xsl:choose>
|
---|
[31d6944] | 184 | <xsl:when test="$testsuite != '0'">
|
---|
[a229600] | 185 | <xsl:value-of select="substring-before(string(),'2>&1')"/>
|
---|
| 186 | <xsl:text>>> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[31d6944] | 187 | </xsl:when>
|
---|
[01e51a1] | 188 | </xsl:choose>
|
---|
| 189 | </xsl:when>
|
---|
[fd691b4] | 190 | <xsl:when test="contains(string(),'test_summary') or
|
---|
[92568bf] | 191 | contains(string(),'expect -c')">
|
---|
[01e51a1] | 192 | <xsl:choose>
|
---|
[31d6944] | 193 | <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
|
---|
| 194 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
| 195 | $testsuite = '3'">
|
---|
[01e51a1] | 196 | <xsl:apply-templates/>
|
---|
[a229600] | 197 | <xsl:if test="contains(string(),'test_summary')">
|
---|
| 198 | <xsl:text> >> $TEST_LOG</xsl:text>
|
---|
| 199 | </xsl:if>
|
---|
[fd691b4] | 200 | <xsl:text>
</xsl:text>
|
---|
[31d6944] | 201 | </xsl:when>
|
---|
[01e51a1] | 202 | </xsl:choose>
|
---|
[3eb60fa] | 203 | </xsl:when>
|
---|
[fd691b4] | 204 | <!-- Don't stop on strip run -->
|
---|
| 205 | <xsl:when test="contains(string(),'strip ')">
|
---|
[3eb60fa] | 206 | <xsl:apply-templates/>
|
---|
[fd691b4] | 207 | <xsl:text> || true
</xsl:text>
|
---|
[1f025ca] | 208 | </xsl:when>
|
---|
[fd691b4] | 209 | <!-- The rest of commands -->
|
---|
[1f025ca] | 210 | <xsl:otherwise>
|
---|
| 211 | <xsl:apply-templates/>
|
---|
[fd691b4] | 212 | <xsl:text>
</xsl:text>
|
---|
[1f025ca] | 213 | </xsl:otherwise>
|
---|
| 214 | </xsl:choose>
|
---|
| 215 | </xsl:template>
|
---|
| 216 |
|
---|
[557fe91] | 217 | <xsl:template match="replaceable">
|
---|
[a41ce58] | 218 | <xsl:choose>
|
---|
[2a54650] | 219 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
[877cc6a] | 220 | <xsl:value-of select="$timezone"/>
|
---|
[2a54650] | 221 | </xsl:when>
|
---|
[a41ce58] | 222 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
[877cc6a] | 223 | <xsl:value-of select="$page"/>
|
---|
[a41ce58] | 224 | </xsl:when>
|
---|
| 225 | <xsl:otherwise>
|
---|
| 226 | <xsl:text>**EDITME</xsl:text>
|
---|
| 227 | <xsl:apply-templates/>
|
---|
| 228 | <xsl:text>EDITME**</xsl:text>
|
---|
| 229 | </xsl:otherwise>
|
---|
| 230 | </xsl:choose>
|
---|
[557fe91] | 231 | </xsl:template>
|
---|
| 232 |
|
---|
| 233 | </xsl:stylesheet>
|
---|