[a9490ab] | 1 | <?xml version="1.0"?>
|
---|
[e676ffa] | 2 | <!DOCTYPE xsl:stylesheet [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 |
|
---|
| 7 | <!-- $Id$ -->
|
---|
| 8 |
|
---|
[a9490ab] | 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 |
|
---|
[e676ffa] | 14 | <!-- XSLT stylesheet to create shell scripts from CLFS books. -->
|
---|
| 15 |
|
---|
| 16 | <!-- Build method used -->
|
---|
| 17 | <xsl:param name="method" select="chroot"/>
|
---|
| 18 |
|
---|
| 19 | <!-- Run test suites?
|
---|
| 20 | 0 = none
|
---|
| 21 | 1 = only Glibc, GCC and Binutils testsuites
|
---|
| 22 | 2 = all testsuites
|
---|
[056486c] | 23 | 3 = alias to 2
|
---|
| 24 | -->
|
---|
[e676ffa] | 25 | <xsl:param name="testsuite" select="1"/>
|
---|
| 26 |
|
---|
[056486c] | 27 | <!-- Bomb on test suites failures?
|
---|
[47fddc8] | 28 | n = no, I want to build the full system and review the logs
|
---|
| 29 | y = yes, bomb at the first test suite failure to can review the build dir
|
---|
[056486c] | 30 | -->
|
---|
[47fddc8] | 31 | <xsl:param name="bomb-testsuite" select="n"/>
|
---|
[056486c] | 32 |
|
---|
[e676ffa] | 33 | <!-- Install vim-lang package? -->
|
---|
[47fddc8] | 34 | <xsl:param name="vim-lang" select="y"/>
|
---|
[e676ffa] | 35 |
|
---|
| 36 | <!-- Time zone -->
|
---|
[e35e794] | 37 | <xsl:param name="timezone" select="GMT"/>
|
---|
[e676ffa] | 38 |
|
---|
| 39 | <!-- Page size -->
|
---|
| 40 | <xsl:param name="page" select="letter"/>
|
---|
| 41 |
|
---|
| 42 | <!-- Locale settings -->
|
---|
[e35e794] | 43 | <xsl:param name="lang" select="C"/>
|
---|
[a9490ab] | 44 |
|
---|
| 45 | <xsl:template match="/">
|
---|
| 46 | <xsl:apply-templates select="//sect1"/>
|
---|
| 47 | </xsl:template>
|
---|
| 48 |
|
---|
| 49 | <xsl:template match="sect1">
|
---|
[e676ffa] | 50 | <xsl:choose>
|
---|
| 51 | <xsl:when test="../@id='chapter-partitioning' or
|
---|
| 52 | ../@id='chapter-getting-materials' or
|
---|
| 53 | ../@id='chapter-final-preps'"/>
|
---|
| 54 | <xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
|
---|
| 55 | <xsl:when test="../@id='chapter-boot' and $method='chroot'"/>
|
---|
| 56 | <xsl:when test="../@id='chapter-chroot' and $method='boot'"/>
|
---|
| 57 | <xsl:otherwise>
|
---|
| 58 | <xsl:if test="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='chapter-chroot'">
|
---|
| 91 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
| 92 | </xsl:when>
|
---|
| 93 | <xsl:when test="@id='ch-system-stripping'">
|
---|
| 94 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
| 95 | </xsl:when>
|
---|
| 96 | <xsl:otherwise>
|
---|
| 97 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
| 98 | </xsl:otherwise>
|
---|
| 99 | </xsl:choose>
|
---|
| 100 | <xsl:if test="sect2[@role='installation']">
|
---|
| 101 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
[47fddc8] | 102 | <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
|
---|
[e676ffa] | 103 | <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
---|
| 104 | </xsl:if>
|
---|
| 105 | </xsl:if>
|
---|
| 106 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
| 107 | <xsl:text>exit</xsl:text>
|
---|
| 108 | </exsl:document>
|
---|
| 109 | </xsl:if>
|
---|
| 110 | </xsl:otherwise>
|
---|
| 111 | </xsl:choose>
|
---|
[a9490ab] | 112 | </xsl:template>
|
---|
| 113 |
|
---|
| 114 | <xsl:template match="screen">
|
---|
[e676ffa] | 115 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
| 116 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
[a9490ab] | 117 | </xsl:if>
|
---|
| 118 | </xsl:template>
|
---|
| 119 |
|
---|
[e676ffa] | 120 | <xsl:template match="para/userinput">
|
---|
| 121 | <xsl:if test="(contains(string(),'test') or
|
---|
| 122 | contains(string(),'check')) and
|
---|
| 123 | ($testsuite = '2' or $testsuite = '3')">
|
---|
[056486c] | 124 | <xsl:choose>
|
---|
[47fddc8] | 125 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
[056486c] | 126 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 127 | <xsl:text>make -k</xsl:text>
|
---|
| 128 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
| 129 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 130 | </xsl:when>
|
---|
| 131 | <xsl:otherwise>
|
---|
| 132 | <xsl:apply-templates/>
|
---|
[8946876] | 133 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
| 134 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 135 | <xsl:text> || true</xsl:text>
|
---|
| 136 | </xsl:if>
|
---|
| 137 | <xsl:text>
</xsl:text>
|
---|
[056486c] | 138 | </xsl:otherwise>
|
---|
| 139 | </xsl:choose>
|
---|
[a9490ab] | 140 | </xsl:if>
|
---|
[e676ffa] | 141 | </xsl:template>
|
---|
| 142 |
|
---|
| 143 | <xsl:template match="userinput" mode="screen">
|
---|
| 144 | <xsl:choose>
|
---|
| 145 | <!-- Estandarized package formats -->
|
---|
| 146 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 147 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 148 | <xsl:text>tar.*</xsl:text>
|
---|
| 149 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 150 | <xsl:text>
</xsl:text>
|
---|
| 151 | </xsl:when>
|
---|
| 152 | <!-- Avoiding a race condition in a patch -->
|
---|
| 153 | <xsl:when test="contains(string(),'debian_fixes')">
|
---|
| 154 | <xsl:value-of select="substring-before(string(),'patch')"/>
|
---|
| 155 | <xsl:text>patch -Z</xsl:text>
|
---|
| 156 | <xsl:value-of select="substring-after(string(),'patch')"/>
|
---|
| 157 | <xsl:text>
</xsl:text>
|
---|
| 158 | </xsl:when>
|
---|
| 159 | <!-- Setting $LANG for /etc/profile -->
|
---|
| 160 | <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
|
---|
| 161 | contains(string(),'export LANG=')">
|
---|
| 162 | <xsl:value-of select="substring-before(string(),'export LANG=')"/>
|
---|
| 163 | <xsl:text>export LANG=</xsl:text>
|
---|
| 164 | <xsl:value-of select="$lang"/>
|
---|
[62033d2] | 165 | <xsl:value-of select="substring-after(string(),'charmap]')"/>
|
---|
[e676ffa] | 166 | <xsl:text>
</xsl:text>
|
---|
| 167 | </xsl:when>
|
---|
[ffd8c5a] | 168 | <!-- Compile the keymap into the kernel has been disabled for 1.0 -->
|
---|
| 169 | <xsl:when test="contains(string(),'defkeymap')"/>
|
---|
[e676ffa] | 170 | <!-- Copying the kernel config file -->
|
---|
| 171 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 172 | <xsl:text>make mrproper
</xsl:text>
|
---|
| 173 | <xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
|
---|
| 174 | <xsl:text>cp -v ../bootkernel-config .config
</xsl:text>
|
---|
| 175 | </xsl:if>
|
---|
| 176 | <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
|
---|
| 177 | <xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
---|
| 178 | </xsl:if>
|
---|
| 179 | </xsl:when>
|
---|
[9a4f673] | 180 | <!-- No interactive commands are needed if the .config file is the proper one -->
|
---|
| 181 | <xsl:when test="contains(string(),'menuconfig')"/>
|
---|
[e676ffa] | 182 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
[e35e794] | 183 | <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
[e676ffa] | 184 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
| 185 | (contains(string(),'check') or
|
---|
[e35e794] | 186 | contains(string(),'dummy'))">
|
---|
| 187 | <xsl:choose>
|
---|
| 188 | <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
|
---|
| 189 | <xsl:otherwise>
|
---|
[056486c] | 190 | <xsl:if test="not(contains(string(),'check'))">
|
---|
| 191 | <xsl:apply-templates/>
|
---|
| 192 | <xsl:text>
</xsl:text>
|
---|
| 193 | </xsl:if>
|
---|
[e35e794] | 194 | <xsl:if test="contains(string(),'check')">
|
---|
[056486c] | 195 | <xsl:choose>
|
---|
[47fddc8] | 196 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
[056486c] | 197 | <xsl:value-of select="substring-before(string(),'check')"/>
|
---|
| 198 | <xsl:text>-k check</xsl:text>
|
---|
| 199 | <xsl:value-of select="substring-after(string(),'check')"/>
|
---|
| 200 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 201 | </xsl:when>
|
---|
| 202 | <xsl:otherwise>
|
---|
| 203 | <xsl:apply-templates/>
|
---|
[0044289] | 204 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
[8946876] | 205 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 206 | <xsl:text> || true</xsl:text>
|
---|
| 207 | </xsl:if>
|
---|
[4aede02] | 208 | <xsl:text>
</xsl:text>
|
---|
[056486c] | 209 | </xsl:otherwise>
|
---|
| 210 | </xsl:choose>
|
---|
[e35e794] | 211 | </xsl:if>
|
---|
| 212 | </xsl:otherwise>
|
---|
| 213 | </xsl:choose>
|
---|
| 214 | </xsl:when>
|
---|
[e676ffa] | 215 | <!-- Fixing toolchain test suites run -->
|
---|
| 216 | <xsl:when test="string() = 'make check' or
|
---|
| 217 | string() = 'make -k check'">
|
---|
| 218 | <xsl:choose>
|
---|
| 219 | <xsl:when test="$testsuite != '0'">
|
---|
[056486c] | 220 | <xsl:choose>
|
---|
[47fddc8] | 221 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
[056486c] | 222 | <xsl:text>make -k check >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 223 | </xsl:when>
|
---|
| 224 | <xsl:otherwise>
|
---|
| 225 | <xsl:apply-templates/>
|
---|
[8946876] | 226 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
| 227 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 228 | <xsl:text> || true</xsl:text>
|
---|
| 229 | </xsl:if>
|
---|
| 230 | <xsl:text>
</xsl:text>
|
---|
[056486c] | 231 | </xsl:otherwise>
|
---|
| 232 | </xsl:choose>
|
---|
[e676ffa] | 233 | </xsl:when>
|
---|
| 234 | </xsl:choose>
|
---|
| 235 | </xsl:when>
|
---|
| 236 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
| 237 | <xsl:choose>
|
---|
| 238 | <xsl:when test="$testsuite != '0'">
|
---|
[e35e794] | 239 | <xsl:value-of select="substring-before(string(),'>g')"/>
|
---|
[056486c] | 240 | <xsl:choose>
|
---|
[47fddc8] | 241 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
[056486c] | 242 | <xsl:text>>> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 243 | </xsl:when>
|
---|
| 244 | <xsl:otherwise>
|
---|
[8946876] | 245 | <xsl:text>>> $TEST_LOG 2>&1</xsl:text>
|
---|
| 246 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 247 | <xsl:text> || true</xsl:text>
|
---|
| 248 | </xsl:if>
|
---|
| 249 | <xsl:text>
</xsl:text>
|
---|
[056486c] | 250 | </xsl:otherwise>
|
---|
| 251 | </xsl:choose>
|
---|
[e676ffa] | 252 | </xsl:when>
|
---|
| 253 | </xsl:choose>
|
---|
| 254 | </xsl:when>
|
---|
| 255 | <xsl:when test="contains(string(),'test_summary') or
|
---|
| 256 | contains(string(),'expect -c')">
|
---|
| 257 | <xsl:choose>
|
---|
| 258 | <xsl:when test="$testsuite != '0'">
|
---|
| 259 | <xsl:apply-templates/>
|
---|
[056486c] | 260 | <xsl:text> >> $TEST_LOG
</xsl:text>
|
---|
[e676ffa] | 261 | </xsl:when>
|
---|
| 262 | </xsl:choose>
|
---|
| 263 | </xsl:when>
|
---|
| 264 | <!-- Don't stop on strip run -->
|
---|
| 265 | <xsl:when test="contains(string(),'strip ')">
|
---|
| 266 | <xsl:apply-templates/>
|
---|
| 267 | <xsl:text> || true
</xsl:text>
|
---|
| 268 | </xsl:when>
|
---|
| 269 | <!-- The rest of commands -->
|
---|
| 270 | <xsl:otherwise>
|
---|
| 271 | <xsl:apply-templates/>
|
---|
| 272 | <xsl:text>
</xsl:text>
|
---|
| 273 | </xsl:otherwise>
|
---|
| 274 | </xsl:choose>
|
---|
[a9490ab] | 275 | </xsl:template>
|
---|
| 276 |
|
---|
| 277 | <xsl:template match="replaceable">
|
---|
[e676ffa] | 278 | <xsl:choose>
|
---|
| 279 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
| 280 | <xsl:value-of select="$timezone"/>
|
---|
| 281 | </xsl:when>
|
---|
| 282 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
| 283 | <xsl:value-of select="$page"/>
|
---|
| 284 | </xsl:when>
|
---|
| 285 | <xsl:otherwise>
|
---|
| 286 | <xsl:text>**EDITME</xsl:text>
|
---|
| 287 | <xsl:apply-templates/>
|
---|
| 288 | <xsl:text>EDITME**</xsl:text>
|
---|
| 289 | </xsl:otherwise>
|
---|
| 290 | </xsl:choose>
|
---|
[a9490ab] | 291 | </xsl:template>
|
---|
| 292 |
|
---|
| 293 | </xsl:stylesheet>
|
---|