[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 | <!-- Compile the keymap into the kernel? -->
|
---|
| 17 | <xsl:param name="keymap" select="none"/>
|
---|
| 18 |
|
---|
| 19 | <!-- Install vim-lang package? -->
|
---|
| 20 | <xsl:param name="vim-lang" select="1"/>
|
---|
| 21 |
|
---|
| 22 | <!-- Time zone -->
|
---|
| 23 | <xsl:param name="timezone" select="GMT"/>
|
---|
| 24 |
|
---|
| 25 | <!-- Page size -->
|
---|
| 26 | <xsl:param name="page" select="letter"/>
|
---|
| 27 |
|
---|
| 28 | <!-- Locale settings -->
|
---|
| 29 | <xsl:param name="lang" select="C"/>
|
---|
| 30 |
|
---|
| 31 | <xsl:template match="/">
|
---|
| 32 | <xsl:apply-templates select="//sect1"/>
|
---|
| 33 | </xsl:template>
|
---|
| 34 |
|
---|
| 35 | <xsl:template match="sect1">
|
---|
| 36 | <xsl:choose>
|
---|
| 37 | <xsl:when test="../@id='chapter-partitioning' or
|
---|
| 38 | ../@id='chapter-getting-materials' or
|
---|
| 39 | ../@id='chapter-final-preps'"/>
|
---|
| 40 | <xsl:otherwise>
|
---|
| 41 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
| 42 | count(descendant::screen/userinput) >
|
---|
| 43 | count(descendant::screen[@role='nodump'])">
|
---|
| 44 | <!-- The dirs names -->
|
---|
| 45 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 46 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 47 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 48 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 49 | <!-- The file names -->
|
---|
| 50 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 51 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 52 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 53 | <!-- The build order -->
|
---|
| 54 | <xsl:variable name="position" select="position()"/>
|
---|
| 55 | <xsl:variable name="order">
|
---|
| 56 | <xsl:choose>
|
---|
| 57 | <xsl:when test="string-length($position) = 1">
|
---|
| 58 | <xsl:text>00</xsl:text>
|
---|
| 59 | <xsl:value-of select="$position"/>
|
---|
| 60 | </xsl:when>
|
---|
| 61 | <xsl:when test="string-length($position) = 2">
|
---|
| 62 | <xsl:text>0</xsl:text>
|
---|
| 63 | <xsl:value-of select="$position"/>
|
---|
| 64 | </xsl:when>
|
---|
| 65 | <xsl:otherwise>
|
---|
| 66 | <xsl:value-of select="$position"/>
|
---|
| 67 | </xsl:otherwise>
|
---|
| 68 | </xsl:choose>
|
---|
| 69 | </xsl:variable>
|
---|
| 70 | <!-- Creating dirs and files -->
|
---|
| 71 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
[206c894] | 72 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
| 73 | <xsl:if test="not(@id='ch-system-stripping')">
|
---|
| 74 | <xsl:text>set -e

</xsl:text>
|
---|
| 75 | </xsl:if>
|
---|
[3b63c8c] | 76 | <xsl:if test="sect2[@role='installation']">
|
---|
| 77 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
| 78 | <xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
|
---|
| 79 | <xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1
</xsl:text>
|
---|
| 80 | </xsl:if>
|
---|
| 81 | </xsl:if>
|
---|
| 82 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
| 83 | <xsl:text>exit</xsl:text>
|
---|
| 84 | </exsl:document>
|
---|
| 85 | </xsl:if>
|
---|
| 86 | </xsl:otherwise>
|
---|
| 87 | </xsl:choose>
|
---|
| 88 | </xsl:template>
|
---|
| 89 |
|
---|
| 90 | <xsl:template match="screen">
|
---|
| 91 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
| 92 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
| 93 | </xsl:if>
|
---|
| 94 | </xsl:template>
|
---|
| 95 |
|
---|
[206c894] | 96 | <xsl:template match="para/userinput"/>
|
---|
[3b63c8c] | 97 |
|
---|
| 98 | <xsl:template match="userinput" mode="screen">
|
---|
| 99 | <xsl:choose>
|
---|
| 100 | <!-- Estandarized package formats -->
|
---|
| 101 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 102 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 103 | <xsl:text>tar.*</xsl:text>
|
---|
| 104 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 105 | <xsl:text>
</xsl:text>
|
---|
| 106 | </xsl:when>
|
---|
| 107 | <!-- Setting $LANG for /etc/profile -->
|
---|
| 108 | <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
|
---|
| 109 | contains(string(),'export LANG=')">
|
---|
| 110 | <xsl:value-of select="substring-before(string(),'export LANG=')"/>
|
---|
| 111 | <xsl:text>export LANG=</xsl:text>
|
---|
| 112 | <xsl:value-of select="$lang"/>
|
---|
| 113 | <xsl:value-of select="substring-after(string(),'charmap]')"/>
|
---|
| 114 | <xsl:text>
</xsl:text>
|
---|
| 115 | </xsl:when>
|
---|
| 116 | <!-- Compile the keymap into the kernel? -->
|
---|
| 117 | <xsl:when test="contains(string(),'defkeymap') and
|
---|
| 118 | $keymap = 'none'"/>
|
---|
| 119 | <!-- Copying the kernel config file -->
|
---|
| 120 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 121 | <xsl:text>make mrproper
</xsl:text>
|
---|
[206c894] | 122 | <xsl:text>cp -v ../kernel-config .config
</xsl:text>
|
---|
[3b63c8c] | 123 | </xsl:when>
|
---|
| 124 | <!-- No interactive commands are needed if the .config file is the proper one -->
|
---|
| 125 | <xsl:when test="contains(string(),'menuconfig')"/>
|
---|
| 126 | <!-- Don't stop on strip run -->
|
---|
| 127 | <xsl:when test="contains(string(),'strip ')">
|
---|
| 128 | <xsl:apply-templates/>
|
---|
| 129 | <xsl:text> || true
</xsl:text>
|
---|
| 130 | </xsl:when>
|
---|
| 131 | <!-- The rest of commands -->
|
---|
| 132 | <xsl:otherwise>
|
---|
| 133 | <xsl:apply-templates/>
|
---|
| 134 | <xsl:text>
</xsl:text>
|
---|
| 135 | </xsl:otherwise>
|
---|
| 136 | </xsl:choose>
|
---|
| 137 | </xsl:template>
|
---|
| 138 |
|
---|
| 139 | <xsl:template match="replaceable">
|
---|
| 140 | <xsl:choose>
|
---|
| 141 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
|
---|
| 142 | <xsl:value-of select="$timezone"/>
|
---|
| 143 | </xsl:when>
|
---|
| 144 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
| 145 | <xsl:value-of select="$page"/>
|
---|
| 146 | </xsl:when>
|
---|
[206c894] | 147 | <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
|
---|
[3b63c8c] | 148 | <xsl:value-of select="$keymap"/>
|
---|
| 149 | </xsl:when>
|
---|
| 150 | <xsl:otherwise>
|
---|
| 151 | <xsl:text>**EDITME</xsl:text>
|
---|
| 152 | <xsl:apply-templates/>
|
---|
| 153 | <xsl:text>EDITME**</xsl:text>
|
---|
| 154 | </xsl:otherwise>
|
---|
| 155 | </xsl:choose>
|
---|
| 156 | </xsl:template>
|
---|
| 157 |
|
---|
| 158 | </xsl:stylesheet>
|
---|