[3b63c8c] | 1 | <?xml version="1.0"?>
|
---|
| 2 | <!DOCTYPE xsl:stylesheet [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 |
|
---|
| 7 | <!-- $Id$ -->
|
---|
| 8 |
|
---|
| 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 |
|
---|
[206c894] | 14 | <!-- XSLT stylesheet to create shell scripts from CLFS2 books. -->
|
---|
[3b63c8c] | 15 |
|
---|
| 16 | <!-- Install vim-lang package? -->
|
---|
[47fddc8] | 17 | <xsl:param name="vim-lang" select="y"/>
|
---|
[3b63c8c] | 18 |
|
---|
| 19 | <!-- Time zone -->
|
---|
| 20 | <xsl:param name="timezone" select="GMT"/>
|
---|
| 21 |
|
---|
| 22 | <!-- Page size -->
|
---|
| 23 | <xsl:param name="page" select="letter"/>
|
---|
| 24 |
|
---|
| 25 | <!-- Locale settings -->
|
---|
| 26 | <xsl:param name="lang" select="C"/>
|
---|
| 27 |
|
---|
| 28 | <xsl:template match="/">
|
---|
| 29 | <xsl:apply-templates select="//sect1"/>
|
---|
| 30 | </xsl:template>
|
---|
| 31 |
|
---|
| 32 | <xsl:template match="sect1">
|
---|
| 33 | <xsl:choose>
|
---|
| 34 | <xsl:when test="../@id='chapter-partitioning' or
|
---|
| 35 | ../@id='chapter-getting-materials' or
|
---|
| 36 | ../@id='chapter-final-preps'"/>
|
---|
| 37 | <xsl:otherwise>
|
---|
| 38 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 39 | count(descendant::screen/userinput) >
|
---|
| 40 | count(descendant::screen[@role='nodump'])">
|
---|
| 41 | <!-- The dirs names -->
|
---|
| 42 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 43 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 44 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 45 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 46 | <!-- The file names -->
|
---|
| 47 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 48 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 49 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 50 | <!-- The build order -->
|
---|
| 51 | <xsl:variable name="position" select="position()"/>
|
---|
| 52 | <xsl:variable name="order">
|
---|
| 53 | <xsl:choose>
|
---|
| 54 | <xsl:when test="string-length($position) = 1">
|
---|
| 55 | <xsl:text>00</xsl:text>
|
---|
| 56 | <xsl:value-of select="$position"/>
|
---|
| 57 | </xsl:when>
|
---|
| 58 | <xsl:when test="string-length($position) = 2">
|
---|
| 59 | <xsl:text>0</xsl:text>
|
---|
| 60 | <xsl:value-of select="$position"/>
|
---|
| 61 | </xsl:when>
|
---|
| 62 | <xsl:otherwise>
|
---|
| 63 | <xsl:value-of select="$position"/>
|
---|
| 64 | </xsl:otherwise>
|
---|
| 65 | </xsl:choose>
|
---|
| 66 | </xsl:variable>
|
---|
| 67 | <!-- Creating dirs and files -->
|
---|
| 68 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
[9c9775f] | 69 | <xsl:text>#!/bin/bash
set +h
</xsl:text>
|
---|
[206c894] | 70 | <xsl:if test="not(@id='ch-system-stripping')">
|
---|
[9c9775f] | 71 | <xsl:text>set -e
</xsl:text>
|
---|
[206c894] | 72 | </xsl:if>
|
---|
[9c9775f] | 73 | <xsl:text>
</xsl:text>
|
---|
[3b63c8c] | 74 | <xsl:if test="sect2[@role='installation']">
|
---|
| 75 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
[47fddc8] | 76 | <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
|
---|
[3b63c8c] | 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:otherwise>
|
---|
| 85 | </xsl:choose>
|
---|
| 86 | </xsl:template>
|
---|
| 87 |
|
---|
| 88 | <xsl:template match="screen">
|
---|
| 89 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
| 90 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
| 91 | </xsl:if>
|
---|
| 92 | </xsl:template>
|
---|
| 93 |
|
---|
[206c894] | 94 | <xsl:template match="para/userinput"/>
|
---|
[3b63c8c] | 95 |
|
---|
| 96 | <xsl:template match="userinput" mode="screen">
|
---|
| 97 | <xsl:choose>
|
---|
| 98 | <!-- Estandarized package formats -->
|
---|
| 99 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 100 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 101 | <xsl:text>tar.*</xsl:text>
|
---|
| 102 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 103 | <xsl:text>
</xsl:text>
|
---|
| 104 | </xsl:when>
|
---|
| 105 | <!-- Setting $LANG for /etc/profile -->
|
---|
| 106 | <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
|
---|
| 107 | contains(string(),'export LANG=')">
|
---|
| 108 | <xsl:value-of select="substring-before(string(),'export LANG=')"/>
|
---|
| 109 | <xsl:text>export LANG=</xsl:text>
|
---|
| 110 | <xsl:value-of select="$lang"/>
|
---|
| 111 | <xsl:value-of select="substring-after(string(),'charmap]')"/>
|
---|
| 112 | <xsl:text>
</xsl:text>
|
---|
| 113 | </xsl:when>
|
---|
[ffd8c5a] | 114 | <!-- Compile the keymap into the kernel has been disabled -->
|
---|
| 115 | <xsl:when test="contains(string(),'defkeymap')"/>
|
---|
[3b63c8c] | 116 | <!-- Copying the kernel config file -->
|
---|
| 117 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 118 | <xsl:text>make mrproper
</xsl:text>
|
---|
[206c894] | 119 | <xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
---|
[3b63c8c] | 120 | </xsl:when>
|
---|
| 121 | <!-- No interactive commands are needed if the .config file is the proper one -->
|
---|
| 122 | <xsl:when test="contains(string(),'menuconfig')"/>
|
---|
| 123 | <!-- Don't stop on strip run -->
|
---|
| 124 | <xsl:when test="contains(string(),'strip ')">
|
---|
| 125 | <xsl:apply-templates/>
|
---|
| 126 | <xsl:text> || true
</xsl:text>
|
---|
| 127 | </xsl:when>
|
---|
| 128 | <!-- The rest of commands -->
|
---|
| 129 | <xsl:otherwise>
|
---|
| 130 | <xsl:apply-templates/>
|
---|
| 131 | <xsl:text>
</xsl:text>
|
---|
| 132 | </xsl:otherwise>
|
---|
| 133 | </xsl:choose>
|
---|
| 134 | </xsl:template>
|
---|
| 135 |
|
---|
| 136 | <xsl:template match="replaceable">
|
---|
| 137 | <xsl:choose>
|
---|
[14c9622] | 138 | <xsl:when test="ancestor::sect1[@id='ch-cross-tools-glibc']">
|
---|
[3b63c8c] | 139 | <xsl:value-of select="$timezone"/>
|
---|
| 140 | </xsl:when>
|
---|
[b33a57b] | 141 | <xsl:when test="ancestor::sect1[@id='ch-cross-tools-groff'] or
|
---|
| 142 | ancestor::sect1[@id='ch-system-groff']">
|
---|
[3b63c8c] | 143 | <xsl:value-of select="$page"/>
|
---|
| 144 | </xsl:when>
|
---|
| 145 | <xsl:otherwise>
|
---|
| 146 | <xsl:text>**EDITME</xsl:text>
|
---|
| 147 | <xsl:apply-templates/>
|
---|
| 148 | <xsl:text>EDITME**</xsl:text>
|
---|
| 149 | </xsl:otherwise>
|
---|
| 150 | </xsl:choose>
|
---|
| 151 | </xsl:template>
|
---|
| 152 |
|
---|
| 153 | </xsl:stylesheet>
|
---|