[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 |
|
---|
[db9cec6] | 9 | <xsl:param name="testsuite" select="0"/>
|
---|
| 10 |
|
---|
[557fe91] | 11 | <xsl:template match="/">
|
---|
| 12 | <xsl:apply-templates select="//sect1"/>
|
---|
| 13 | </xsl:template>
|
---|
| 14 |
|
---|
| 15 | <xsl:template match="sect1">
|
---|
[c4cf6de] | 16 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 17 | count(descendant::screen/userinput) > count(descendant::screen[@role='nodump'])">
|
---|
| 18 | <!-- The dirs names -->
|
---|
| 19 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 20 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 21 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 22 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 23 | <!-- The file names -->
|
---|
| 24 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 25 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 26 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 27 | <!-- The build order -->
|
---|
| 28 | <xsl:variable name="position" select="position()"/>
|
---|
| 29 | <xsl:variable name="order">
|
---|
| 30 | <xsl:choose>
|
---|
| 31 | <xsl:when test="string-length($position) = 1">
|
---|
| 32 | <xsl:text>00</xsl:text>
|
---|
| 33 | <xsl:value-of select="$position"/>
|
---|
| 34 | </xsl:when>
|
---|
| 35 | <xsl:when test="string-length($position) = 2">
|
---|
| 36 | <xsl:text>0</xsl:text>
|
---|
| 37 | <xsl:value-of select="$position"/>
|
---|
| 38 | </xsl:when>
|
---|
| 39 | <xsl:otherwise>
|
---|
| 40 | <xsl:value-of select="$position"/>
|
---|
| 41 | </xsl:otherwise>
|
---|
| 42 | </xsl:choose>
|
---|
| 43 | </xsl:variable>
|
---|
| 44 | <!-- Creating dirs and files -->
|
---|
| 45 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
[76fad58] | 46 | <xsl:choose>
|
---|
| 47 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
| 48 | @id='ch-system-creatingdirs' or
|
---|
| 49 | @id='ch-system-createfiles'">
|
---|
| 50 | <xsl:text>#!/tools/bin/bash

</xsl:text>
|
---|
| 51 | </xsl:when>
|
---|
| 52 | <xsl:otherwise>
|
---|
| 53 | <xsl:text>#!/bin/sh

</xsl:text>
|
---|
| 54 | </xsl:otherwise>
|
---|
| 55 | </xsl:choose>
|
---|
[56dd1e2] | 56 | <xsl:if test="sect2[@role='installation'] or
|
---|
| 57 | @id='ch-tools-adjusting' or
|
---|
| 58 | @id='ch-system-readjusting'">
|
---|
[44f88e3] | 59 | <xsl:text>cd $PKGDIR &&
</xsl:text>
|
---|
| 60 | </xsl:if>
|
---|
[db9cec6] | 61 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
[816f3f43] | 62 | <xsl:text>exit</xsl:text>
|
---|
[c4cf6de] | 63 | </exsl:document>
|
---|
| 64 | </xsl:if>
|
---|
[557fe91] | 65 | </xsl:template>
|
---|
| 66 |
|
---|
| 67 | <xsl:template match="screen">
|
---|
| 68 | <xsl:if test="child::* = userinput">
|
---|
| 69 | <xsl:choose>
|
---|
| 70 | <xsl:when test="@role = 'nodump'"/>
|
---|
| 71 | <xsl:otherwise>
|
---|
[db9cec6] | 72 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
[557fe91] | 73 | </xsl:otherwise>
|
---|
| 74 | </xsl:choose>
|
---|
| 75 | </xsl:if>
|
---|
| 76 | </xsl:template>
|
---|
| 77 |
|
---|
[db9cec6] | 78 | <xsl:template match="para/userinput">
|
---|
[56dd1e2] | 79 | <xsl:if test="$testsuite != '0' and
|
---|
| 80 | (contains(string(),'test') or
|
---|
| 81 | contains(string(),'check'))">
|
---|
[3eb60fa] | 82 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 83 | <xsl:text>make -k</xsl:text>
|
---|
| 84 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
[d310939] | 85 | <xsl:text> 
</xsl:text>
|
---|
[db9cec6] | 86 | </xsl:if>
|
---|
| 87 | </xsl:template>
|
---|
| 88 |
|
---|
| 89 | <xsl:template match="userinput" mode="screen">
|
---|
[3eb60fa] | 90 | <xsl:choose>
|
---|
| 91 | <xsl:when test="string() = 'make check'">
|
---|
| 92 | <xsl:text>make -k check</xsl:text>
|
---|
| 93 | </xsl:when>
|
---|
| 94 | <xsl:otherwise>
|
---|
| 95 | <xsl:apply-templates/>
|
---|
| 96 | </xsl:otherwise>
|
---|
| 97 | </xsl:choose>
|
---|
[816f3f43] | 98 | <xsl:if test="not(contains(string(),'EOF')) and
|
---|
[7450da3] | 99 | not(contains(string(),'check')) and
|
---|
| 100 | not(contains(string(),'strip '))">
|
---|
[816f3f43] | 101 | <xsl:text> &&</xsl:text>
|
---|
| 102 | </xsl:if>
|
---|
| 103 | <xsl:text>
</xsl:text>
|
---|
[557fe91] | 104 | </xsl:template>
|
---|
| 105 |
|
---|
| 106 | <xsl:template match="replaceable">
|
---|
| 107 | <xsl:text>**EDITME</xsl:text>
|
---|
| 108 | <xsl:apply-templates/>
|
---|
| 109 | <xsl:text>EDITME**</xsl:text>
|
---|
| 110 | </xsl:template>
|
---|
| 111 |
|
---|
| 112 | </xsl:stylesheet>
|
---|