[557fe91] | 1 | <?xml version="1.0"?>
|
---|
[db181c47] | 2 | <!DOCTYPE xsl:stylesheet [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 |
|
---|
[557fe91] | 7 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 8 | xmlns:exsl="http://exslt.org/common"
|
---|
| 9 | extension-element-prefixes="exsl"
|
---|
| 10 | version="1.0">
|
---|
| 11 |
|
---|
[63b2859] | 12 | <!-- XSLT stylesheet to create shell scripts from LFS books. -->
|
---|
[557fe91] | 13 |
|
---|
[01e51a1] | 14 | <!-- Run optional test suites? -->
|
---|
[db9cec6] | 15 | <xsl:param name="testsuite" select="0"/>
|
---|
| 16 |
|
---|
[01e51a1] | 17 | <!-- Run toolchain test suites? -->
|
---|
| 18 | <xsl:param name="toolchaintest" select="1"/>
|
---|
| 19 |
|
---|
[db181c47] | 20 | <!-- Install vim-lang package? -->
|
---|
| 21 | <xsl:param name="vim-lang" select="1"/>
|
---|
| 22 |
|
---|
[557fe91] | 23 | <xsl:template match="/">
|
---|
| 24 | <xsl:apply-templates select="//sect1"/>
|
---|
| 25 | </xsl:template>
|
---|
| 26 |
|
---|
| 27 | <xsl:template match="sect1">
|
---|
[c4cf6de] | 28 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 29 | count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
---|
| 30 | <!-- The dirs names -->
|
---|
| 31 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 32 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 33 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 34 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 35 | <!-- The file names -->
|
---|
| 36 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 37 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 38 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 39 | <!-- The build order -->
|
---|
| 40 | <xsl:variable name="position" select="position()"/>
|
---|
| 41 | <xsl:variable name="order">
|
---|
| 42 | <xsl:choose>
|
---|
| 43 | <xsl:when test="string-length($position) = 1">
|
---|
| 44 | <xsl:text>00</xsl:text>
|
---|
| 45 | <xsl:value-of select="$position"/>
|
---|
| 46 | </xsl:when>
|
---|
| 47 | <xsl:when test="string-length($position) = 2">
|
---|
| 48 | <xsl:text>0</xsl:text>
|
---|
| 49 | <xsl:value-of select="$position"/>
|
---|
| 50 | </xsl:when>
|
---|
| 51 | <xsl:otherwise>
|
---|
| 52 | <xsl:value-of select="$position"/>
|
---|
| 53 | </xsl:otherwise>
|
---|
| 54 | </xsl:choose>
|
---|
| 55 | </xsl:variable>
|
---|
| 56 | <!-- Creating dirs and files -->
|
---|
| 57 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
[76fad58] | 58 | <xsl:choose>
|
---|
| 59 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
| 60 | @id='ch-system-creatingdirs' or
|
---|
| 61 | @id='ch-system-createfiles'">
|
---|
[fd691b4] | 62 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
| 63 | </xsl:when>
|
---|
| 64 | <xsl:when test="@id='ch-tools-stripping' or
|
---|
| 65 | @id='ch-system-strippingagain'">
|
---|
| 66 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
[76fad58] | 67 | </xsl:when>
|
---|
| 68 | <xsl:otherwise>
|
---|
[fd691b4] | 69 | <xsl:text>#!/bin/sh
set -e

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