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

</xsl:text>
|
---|
| 55 | </xsl:when>
|
---|
| 56 | <xsl:otherwise>
|
---|
| 57 | <xsl:text>#!/bin/sh

</xsl:text>
|
---|
| 58 | </xsl:otherwise>
|
---|
| 59 | </xsl:choose>
|
---|
[56dd1e2] | 60 | <xsl:if test="sect2[@role='installation'] or
|
---|
| 61 | @id='ch-tools-adjusting' or
|
---|
| 62 | @id='ch-system-readjusting'">
|
---|
[44f88e3] | 63 | <xsl:text>cd $PKGDIR &&
</xsl:text>
|
---|
| 64 | </xsl:if>
|
---|
[db9cec6] | 65 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
[816f3f43] | 66 | <xsl:text>exit</xsl:text>
|
---|
[c4cf6de] | 67 | </exsl:document>
|
---|
| 68 | </xsl:if>
|
---|
[557fe91] | 69 | </xsl:template>
|
---|
| 70 |
|
---|
| 71 | <xsl:template match="screen">
|
---|
| 72 | <xsl:if test="child::* = userinput">
|
---|
| 73 | <xsl:choose>
|
---|
| 74 | <xsl:when test="@role = 'nodump'"/>
|
---|
| 75 | <xsl:otherwise>
|
---|
[db9cec6] | 76 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
[557fe91] | 77 | </xsl:otherwise>
|
---|
| 78 | </xsl:choose>
|
---|
| 79 | </xsl:if>
|
---|
| 80 | </xsl:template>
|
---|
| 81 |
|
---|
[db9cec6] | 82 | <xsl:template match="para/userinput">
|
---|
[56dd1e2] | 83 | <xsl:if test="$testsuite != '0' and
|
---|
| 84 | (contains(string(),'test') or
|
---|
| 85 | contains(string(),'check'))">
|
---|
[3eb60fa] | 86 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 87 | <xsl:text>make -k</xsl:text>
|
---|
| 88 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
[d310939] | 89 | <xsl:text> 
</xsl:text>
|
---|
[db9cec6] | 90 | </xsl:if>
|
---|
| 91 | </xsl:template>
|
---|
| 92 |
|
---|
| 93 | <xsl:template match="userinput" mode="screen">
|
---|
[3eb60fa] | 94 | <xsl:choose>
|
---|
[92568bf] | 95 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 96 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 97 | <xsl:text>tar.bz2</xsl:text>
|
---|
| 98 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 99 | <xsl:text> &&
</xsl:text>
|
---|
| 100 | </xsl:when>
|
---|
[79f7cf9] | 101 | <xsl:when test="$testsuite = '0' and
|
---|
| 102 | ancestor::sect1[@id='ch-system-coreutils'] and
|
---|
| 103 | (contains(string(),'check') or
|
---|
| 104 | contains(string(),'dummy'))"/>
|
---|
[01e51a1] | 105 | <xsl:when test="string() = 'make check' or
|
---|
| 106 | string() = 'make -k check'">
|
---|
| 107 | <xsl:choose>
|
---|
| 108 | <xsl:when test="$toolchaintest = '0'"/>
|
---|
| 109 | <xsl:otherwise>
|
---|
| 110 | <xsl:text>make -k check</xsl:text>
|
---|
| 111 | <xsl:text>
</xsl:text>
|
---|
| 112 | </xsl:otherwise>
|
---|
| 113 | </xsl:choose>
|
---|
| 114 | </xsl:when>
|
---|
| 115 | <xsl:when test="contains(string(),'glibc-check-log') or
|
---|
[92568bf] | 116 | contains(string(),'test_summary') or
|
---|
| 117 | contains(string(),'expect -c')">
|
---|
[01e51a1] | 118 | <xsl:choose>
|
---|
| 119 | <xsl:when test="$toolchaintest = '0'"/>
|
---|
| 120 | <xsl:otherwise>
|
---|
| 121 | <xsl:apply-templates/>
|
---|
| 122 | <xsl:text> &&
</xsl:text>
|
---|
| 123 | </xsl:otherwise>
|
---|
| 124 | </xsl:choose>
|
---|
[3eb60fa] | 125 | </xsl:when>
|
---|
[6ec43e3] | 126 | <xsl:when test="contains(string(),'EOF')">
|
---|
| 127 | <xsl:variable name="content">
|
---|
| 128 | <xsl:apply-templates/>
|
---|
| 129 | </xsl:variable>
|
---|
| 130 | <xsl:value-of select="substring-before(string($content), 'cat >')"/>
|
---|
| 131 | <xsl:text>
(
cat << EOF</xsl:text>
|
---|
| 132 | <xsl:value-of select="substring-after(string($content), '"EOF"')"/>
|
---|
| 133 | <xsl:text>
) ></xsl:text>
|
---|
| 134 | <xsl:value-of select="substring-after((substring-before(string($content), '<<')), 'cat >')"/>
|
---|
[01e51a1] | 135 | <xsl:text> &&
</xsl:text>
|
---|
[6ec43e3] | 136 | </xsl:when>
|
---|
[3eb60fa] | 137 | <xsl:otherwise>
|
---|
| 138 | <xsl:apply-templates/>
|
---|
[01e51a1] | 139 | <xsl:if test="not(contains(string(),'check')) and
|
---|
| 140 | not(contains(string(),'strip '))">
|
---|
| 141 | <xsl:text> &&</xsl:text>
|
---|
| 142 | </xsl:if>
|
---|
| 143 | <xsl:text>
</xsl:text>
|
---|
[3eb60fa] | 144 | </xsl:otherwise>
|
---|
| 145 | </xsl:choose>
|
---|
[557fe91] | 146 | </xsl:template>
|
---|
| 147 |
|
---|
| 148 | <xsl:template match="replaceable">
|
---|
[a41ce58] | 149 | <xsl:choose>
|
---|
| 150 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
| 151 | <xsl:text>$PAGE</xsl:text>
|
---|
| 152 | </xsl:when>
|
---|
| 153 | <xsl:otherwise>
|
---|
| 154 | <xsl:text>**EDITME</xsl:text>
|
---|
| 155 | <xsl:apply-templates/>
|
---|
| 156 | <xsl:text>EDITME**</xsl:text>
|
---|
| 157 | </xsl:otherwise>
|
---|
| 158 | </xsl:choose>
|
---|
[557fe91] | 159 | </xsl:template>
|
---|
| 160 |
|
---|
| 161 | </xsl:stylesheet>
|
---|