[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 |
|
---|
| 16 | <!-- Run optional test suites? -->
|
---|
| 17 | <xsl:param name="testsuite" select="0"/>
|
---|
| 18 |
|
---|
| 19 | <!-- Run toolchain test suites? -->
|
---|
| 20 | <xsl:param name="toolchaintest" select="1"/>
|
---|
| 21 |
|
---|
| 22 | <!-- Install vim-lang package? -->
|
---|
| 23 | <xsl:param name="vim-lang" select="1"/>
|
---|
| 24 |
|
---|
| 25 | <xsl:template match="/">
|
---|
| 26 | <xsl:apply-templates select="//sect1"/>
|
---|
| 27 | </xsl:template>
|
---|
| 28 |
|
---|
| 29 | <xsl:template match="sect1">
|
---|
| 30 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 31 | count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
---|
| 32 | <!-- The dirs names -->
|
---|
| 33 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 34 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 35 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 36 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 37 | <!-- The file names -->
|
---|
| 38 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 39 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 40 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 41 | <!-- The build order -->
|
---|
| 42 | <xsl:variable name="position" select="position()"/>
|
---|
| 43 | <xsl:variable name="order">
|
---|
| 44 | <xsl:choose>
|
---|
| 45 | <xsl:when test="string-length($position) = 1">
|
---|
| 46 | <xsl:text>00</xsl:text>
|
---|
| 47 | <xsl:value-of select="$position"/>
|
---|
| 48 | </xsl:when>
|
---|
| 49 | <xsl:when test="string-length($position) = 2">
|
---|
| 50 | <xsl:text>0</xsl:text>
|
---|
| 51 | <xsl:value-of select="$position"/>
|
---|
| 52 | </xsl:when>
|
---|
| 53 | <xsl:otherwise>
|
---|
| 54 | <xsl:value-of select="$position"/>
|
---|
| 55 | </xsl:otherwise>
|
---|
| 56 | </xsl:choose>
|
---|
| 57 | </xsl:variable>
|
---|
| 58 | <!-- Creating dirs and files -->
|
---|
| 59 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
| 60 | <xsl:choose>
|
---|
| 61 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
| 62 | @id='ch-system-creatingdirs' or
|
---|
| 63 | @id='ch-system-createfiles'">
|
---|
| 64 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
| 65 | </xsl:when>
|
---|
| 66 | <xsl:when test="@id='ch-tools-stripping' or
|
---|
| 67 | @id='ch-system-strippingagain'">
|
---|
| 68 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
| 69 | </xsl:when>
|
---|
| 70 | <xsl:otherwise>
|
---|
| 71 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
| 72 | </xsl:otherwise>
|
---|
| 73 | </xsl:choose>
|
---|
[3a5c9cc] | 74 | <xsl:if test="sect2[@role='installation']">
|
---|
[0170229] | 75 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
| 76 | <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
|
---|
| 77 | <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
---|
| 78 | </xsl:if>
|
---|
| 79 | </xsl:if>
|
---|
| 80 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
| 81 | <xsl:text>exit</xsl:text>
|
---|
| 82 | </exsl:document>
|
---|
| 83 | </xsl:if>
|
---|
| 84 | </xsl:template>
|
---|
| 85 |
|
---|
| 86 | <xsl:template match="screen">
|
---|
| 87 | <xsl:if test="child::* = userinput">
|
---|
| 88 | <xsl:choose>
|
---|
| 89 | <xsl:when test="@role = 'nodump'"/>
|
---|
| 90 | <xsl:otherwise>
|
---|
| 91 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
| 92 | </xsl:otherwise>
|
---|
| 93 | </xsl:choose>
|
---|
| 94 | </xsl:if>
|
---|
| 95 | </xsl:template>
|
---|
| 96 |
|
---|
| 97 | <xsl:template match="para/userinput">
|
---|
| 98 | <xsl:if test="$testsuite != '0' and
|
---|
| 99 | (contains(string(),'test') or
|
---|
| 100 | contains(string(),'check'))">
|
---|
| 101 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 102 | <xsl:text>make -k</xsl:text>
|
---|
| 103 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
| 104 | <xsl:text> || true
</xsl:text>
|
---|
| 105 | </xsl:if>
|
---|
| 106 | </xsl:template>
|
---|
| 107 |
|
---|
| 108 | <xsl:template match="userinput" mode="screen">
|
---|
| 109 | <xsl:choose>
|
---|
| 110 | <!-- Estandarized package formats -->
|
---|
| 111 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 112 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 113 | <xsl:text>tar.*</xsl:text>
|
---|
| 114 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 115 | <xsl:text>
</xsl:text>
|
---|
| 116 | </xsl:when>
|
---|
| 117 | <!-- Avoiding a race condition in a patch -->
|
---|
| 118 | <xsl:when test="contains(string(),'debian_fixes')">
|
---|
| 119 | <xsl:value-of select="substring-before(string(),'patch')"/>
|
---|
| 120 | <xsl:text>patch -Z</xsl:text>
|
---|
| 121 | <xsl:value-of select="substring-after(string(),'patch')"/>
|
---|
| 122 | <xsl:text>
</xsl:text>
|
---|
| 123 | </xsl:when>
|
---|
| 124 | <!-- Copying the kernel config file -->
|
---|
| 125 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 126 | <xsl:text>make mrproper
</xsl:text>
|
---|
| 127 | <xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
---|
| 128 | </xsl:when>
|
---|
| 129 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
| 130 | <xsl:when test="$testsuite = '0' and
|
---|
| 131 | (ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
| 132 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
| 133 | (contains(string(),'check') or
|
---|
| 134 | contains(string(),'dummy'))"/>
|
---|
| 135 | <!-- Fixing toolchain test suites run -->
|
---|
| 136 | <xsl:when test="string() = 'make check' or
|
---|
| 137 | string() = 'make -k check'">
|
---|
| 138 | <xsl:choose>
|
---|
| 139 | <xsl:when test="$toolchaintest = '0'"/>
|
---|
| 140 | <xsl:otherwise>
|
---|
| 141 | <xsl:text>make -k check || true</xsl:text>
|
---|
| 142 | <xsl:text>
</xsl:text>
|
---|
| 143 | </xsl:otherwise>
|
---|
| 144 | </xsl:choose>
|
---|
| 145 | </xsl:when>
|
---|
| 146 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
| 147 | <xsl:choose>
|
---|
| 148 | <xsl:when test="$toolchaintest = '0'"/>
|
---|
| 149 | <xsl:otherwise>
|
---|
| 150 | <xsl:value-of select="substring-before(string(),'
')"/>
|
---|
| 151 | <xsl:text> || true
</xsl:text>
|
---|
| 152 | <xsl:value-of select="substring-after(string(),'
')"/>
|
---|
| 153 | <xsl:text>
</xsl:text>
|
---|
| 154 | </xsl:otherwise>
|
---|
| 155 | </xsl:choose>
|
---|
| 156 | </xsl:when>
|
---|
| 157 | <xsl:when test="contains(string(),'test_summary') or
|
---|
| 158 | contains(string(),'expect -c')">
|
---|
| 159 | <xsl:choose>
|
---|
| 160 | <xsl:when test="$toolchaintest = '0'"/>
|
---|
| 161 | <xsl:otherwise>
|
---|
| 162 | <xsl:apply-templates/>
|
---|
| 163 | <xsl:text>
</xsl:text>
|
---|
| 164 | </xsl:otherwise>
|
---|
| 165 | </xsl:choose>
|
---|
| 166 | </xsl:when>
|
---|
| 167 | <!-- Don't stop on strip run -->
|
---|
| 168 | <xsl:when test="contains(string(),'strip ')">
|
---|
| 169 | <xsl:apply-templates/>
|
---|
| 170 | <xsl:text> || true
</xsl:text>
|
---|
| 171 | </xsl:when>
|
---|
| 172 | <!-- The rest of commands -->
|
---|
| 173 | <xsl:otherwise>
|
---|
| 174 | <xsl:apply-templates/>
|
---|
| 175 | <xsl:text>
</xsl:text>
|
---|
| 176 | </xsl:otherwise>
|
---|
| 177 | </xsl:choose>
|
---|
| 178 | </xsl:template>
|
---|
| 179 |
|
---|
| 180 | <xsl:template match="replaceable">
|
---|
| 181 | <xsl:choose>
|
---|
| 182 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
| 183 | <xsl:text>$TIMEZONE</xsl:text>
|
---|
| 184 | </xsl:when>
|
---|
| 185 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
| 186 | <xsl:text>$PAGE</xsl:text>
|
---|
| 187 | </xsl:when>
|
---|
| 188 | <xsl:otherwise>
|
---|
| 189 | <xsl:text>**EDITME</xsl:text>
|
---|
| 190 | <xsl:apply-templates/>
|
---|
| 191 | <xsl:text>EDITME**</xsl:text>
|
---|
| 192 | </xsl:otherwise>
|
---|
| 193 | </xsl:choose>
|
---|
| 194 | </xsl:template>
|
---|
| 195 |
|
---|
| 196 | </xsl:stylesheet>
|
---|