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

</xsl:text>
|
---|
| 95 | </xsl:when>
|
---|
| 96 | <xsl:when test="@id='ch-system-stripping'">
|
---|
| 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']">
|
---|
| 104 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
| 105 | <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
|
---|
| 106 | <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
---|
| 107 | </xsl:if>
|
---|
| 108 | </xsl:if>
|
---|
| 109 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
| 110 | <xsl:text>exit</xsl:text>
|
---|
| 111 | </exsl:document>
|
---|
| 112 | </xsl:if>
|
---|
| 113 | </xsl:otherwise>
|
---|
| 114 | </xsl:choose>
|
---|
[a9490ab] | 115 | </xsl:template>
|
---|
| 116 |
|
---|
| 117 | <xsl:template match="screen">
|
---|
[e676ffa] | 118 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
| 119 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
[a9490ab] | 120 | </xsl:if>
|
---|
| 121 | </xsl:template>
|
---|
| 122 |
|
---|
[e676ffa] | 123 | <xsl:template match="para/userinput">
|
---|
| 124 | <xsl:if test="(contains(string(),'test') or
|
---|
| 125 | contains(string(),'check')) and
|
---|
| 126 | ($testsuite = '2' or $testsuite = '3')">
|
---|
[056486c] | 127 | <xsl:choose>
|
---|
| 128 | <xsl:when test="$bomb-testsuite = '0'">
|
---|
| 129 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 130 | <xsl:text>make -k</xsl:text>
|
---|
| 131 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
| 132 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 133 | </xsl:when>
|
---|
| 134 | <xsl:otherwise>
|
---|
| 135 | <xsl:apply-templates/>
|
---|
| 136 | <xsl:text> >> $TEST_LOG 2>&1
</xsl:text>
|
---|
| 137 | </xsl:otherwise>
|
---|
| 138 | </xsl:choose>
|
---|
[a9490ab] | 139 | </xsl:if>
|
---|
[e676ffa] | 140 | </xsl:template>
|
---|
| 141 |
|
---|
| 142 | <xsl:template match="userinput" mode="screen">
|
---|
| 143 | <xsl:choose>
|
---|
| 144 | <!-- Estandarized package formats -->
|
---|
| 145 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 146 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 147 | <xsl:text>tar.*</xsl:text>
|
---|
| 148 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 149 | <xsl:text>
</xsl:text>
|
---|
| 150 | </xsl:when>
|
---|
| 151 | <!-- Avoiding a race condition in a patch -->
|
---|
| 152 | <xsl:when test="contains(string(),'debian_fixes')">
|
---|
| 153 | <xsl:value-of select="substring-before(string(),'patch')"/>
|
---|
| 154 | <xsl:text>patch -Z</xsl:text>
|
---|
| 155 | <xsl:value-of select="substring-after(string(),'patch')"/>
|
---|
| 156 | <xsl:text>
</xsl:text>
|
---|
| 157 | </xsl:when>
|
---|
| 158 | <!-- Setting $LANG for /etc/profile -->
|
---|
| 159 | <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
|
---|
| 160 | contains(string(),'export LANG=')">
|
---|
| 161 | <xsl:value-of select="substring-before(string(),'export LANG=')"/>
|
---|
| 162 | <xsl:text>export LANG=</xsl:text>
|
---|
| 163 | <xsl:value-of select="$lang"/>
|
---|
[62033d2] | 164 | <xsl:value-of select="substring-after(string(),'charmap]')"/>
|
---|
[e676ffa] | 165 | <xsl:text>
</xsl:text>
|
---|
| 166 | </xsl:when>
|
---|
| 167 | <!-- Compile the keymap into the kernel? -->
|
---|
| 168 | <xsl:when test="contains(string(),'defkeymap') and
|
---|
| 169 | $keymap = 'none'"/>
|
---|
| 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>
|
---|
| 196 | <xsl:when test="$bomb-testsuite = '0'">
|
---|
| 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/>
|
---|
| 204 | <xsl:text> >> $TEST_LOG 2>&1
</xsl:text>
|
---|
| 205 | </xsl:otherwise>
|
---|
| 206 | </xsl:choose>
|
---|
[e35e794] | 207 | </xsl:if>
|
---|
| 208 | </xsl:otherwise>
|
---|
| 209 | </xsl:choose>
|
---|
| 210 | </xsl:when>
|
---|
[e676ffa] | 211 | <!-- Fixing toolchain test suites run -->
|
---|
| 212 | <xsl:when test="string() = 'make check' or
|
---|
| 213 | string() = 'make -k check'">
|
---|
| 214 | <xsl:choose>
|
---|
| 215 | <xsl:when test="$testsuite != '0'">
|
---|
[056486c] | 216 | <xsl:choose>
|
---|
| 217 | <xsl:when test="$bomb-testsuite = '0'">
|
---|
| 218 | <xsl:text>make -k check >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 219 | </xsl:when>
|
---|
| 220 | <xsl:otherwise>
|
---|
| 221 | <xsl:apply-templates/>
|
---|
| 222 | <xsl:text> >> $TEST_LOG 2>&1
</xsl:text>
|
---|
| 223 | </xsl:otherwise>
|
---|
| 224 | </xsl:choose>
|
---|
[e676ffa] | 225 | </xsl:when>
|
---|
| 226 | </xsl:choose>
|
---|
| 227 | </xsl:when>
|
---|
| 228 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
| 229 | <xsl:choose>
|
---|
| 230 | <xsl:when test="$testsuite != '0'">
|
---|
[e35e794] | 231 | <xsl:value-of select="substring-before(string(),'>g')"/>
|
---|
[056486c] | 232 | <xsl:choose>
|
---|
| 233 | <xsl:when test="$bomb-testsuite = '0'">
|
---|
| 234 | <xsl:text>>> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 235 | </xsl:when>
|
---|
| 236 | <xsl:otherwise>
|
---|
| 237 | <xsl:text>>> $TEST_LOG 2>&1
</xsl:text>
|
---|
| 238 | </xsl:otherwise>
|
---|
| 239 | </xsl:choose>
|
---|
[e676ffa] | 240 | </xsl:when>
|
---|
| 241 | </xsl:choose>
|
---|
| 242 | </xsl:when>
|
---|
| 243 | <xsl:when test="contains(string(),'test_summary') or
|
---|
| 244 | contains(string(),'expect -c')">
|
---|
| 245 | <xsl:choose>
|
---|
| 246 | <xsl:when test="$testsuite != '0'">
|
---|
| 247 | <xsl:apply-templates/>
|
---|
[056486c] | 248 | <xsl:text> >> $TEST_LOG
</xsl:text>
|
---|
[e676ffa] | 249 | </xsl:when>
|
---|
| 250 | </xsl:choose>
|
---|
| 251 | </xsl:when>
|
---|
| 252 | <!-- Don't stop on strip run -->
|
---|
| 253 | <xsl:when test="contains(string(),'strip ')">
|
---|
| 254 | <xsl:apply-templates/>
|
---|
| 255 | <xsl:text> || true
</xsl:text>
|
---|
| 256 | </xsl:when>
|
---|
| 257 | <!-- The rest of commands -->
|
---|
| 258 | <xsl:otherwise>
|
---|
| 259 | <xsl:apply-templates/>
|
---|
| 260 | <xsl:text>
</xsl:text>
|
---|
| 261 | </xsl:otherwise>
|
---|
| 262 | </xsl:choose>
|
---|
[a9490ab] | 263 | </xsl:template>
|
---|
| 264 |
|
---|
| 265 | <xsl:template match="replaceable">
|
---|
[e676ffa] | 266 | <xsl:choose>
|
---|
| 267 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
| 268 | <xsl:value-of select="$timezone"/>
|
---|
| 269 | </xsl:when>
|
---|
| 270 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
| 271 | <xsl:value-of select="$page"/>
|
---|
| 272 | </xsl:when>
|
---|
[3b63c8c] | 273 | <xsl:when test="ancestor::sect1[@id='ch-boot-kernel'] or
|
---|
| 274 | ancestor::sect1[@id='ch-bootable-kernel']">
|
---|
| 275 | <xsl:value-of select="$keymap"/>
|
---|
| 276 | </xsl:when>
|
---|
[e676ffa] | 277 | <xsl:otherwise>
|
---|
| 278 | <xsl:text>**EDITME</xsl:text>
|
---|
| 279 | <xsl:apply-templates/>
|
---|
| 280 | <xsl:text>EDITME**</xsl:text>
|
---|
| 281 | </xsl:otherwise>
|
---|
| 282 | </xsl:choose>
|
---|
[a9490ab] | 283 | </xsl:template>
|
---|
| 284 |
|
---|
| 285 | </xsl:stylesheet>
|
---|