2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % general-entities SYSTEM
"FAKEDIR/general.ent">
9 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
10 xmlns:
exsl=
"http://exslt.org/common"
11 extension-element-prefixes=
"exsl"
14 <!-- XSLT stylesheet to create shell scripts from CLFS2 books. -->
17 <xsl:param name=
"endian" select=
"xbig"/>
20 <xsl:param name=
"timezone" select=
"GMT"/>
23 <xsl:param name=
"page" select=
"letter"/>
25 <!-- Locale settings -->
26 <xsl:param name=
"lang" select=
"C"/>
28 <xsl:template match=
"/">
29 <xsl:apply-templates select=
"//sect1"/>
32 <xsl:template match=
"sect1">
34 <xsl:when test=
"../@id='chapter-partitioning' or
35 ../@id='chapter-getting-materials' or
36 ../@id='chapter-final-preps'"/>
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">
54 <xsl:when test=
"string-length($position) = 1">
55 <xsl:text>00</xsl:text>
56 <xsl:value-of select=
"$position"/>
58 <xsl:when test=
"string-length($position) = 2">
59 <xsl:text>0</xsl:text>
60 <xsl:value-of select=
"$position"/>
63 <xsl:value-of select=
"$position"/>
67 <!-- Creating dirs and files -->
68 <exsl:document href=
"{$dirname}/{$order}-{$filename}" method=
"text">
69 <xsl:text>#!/bin/bash

set +h

set -e


</xsl:text>
70 <!-- Set envars needed by uClibc -->
71 <xsl:if test=
"@id='ch-cross-tools-uclibc'">
72 <xsl:copy-of select=
"//sect1[@id='ch-cross-tools-toolchain']/screen"/>
73 <xsl:text>

</xsl:text>
75 <xsl:if test=
"sect2[@role='installation']">
76 <xsl:text>cd $PKGDIR

</xsl:text>
78 <xsl:apply-templates select=
".//para/userinput | .//screen"/>
79 <xsl:text>exit
</xsl:text>
86 <xsl:template match=
"screen">
87 <xsl:if test=
"child::* = userinput and not(@role = 'nodump')">
88 <xsl:apply-templates select=
"userinput" mode=
"screen"/>
92 <xsl:template match=
"para/userinput"/>
94 <xsl:template match=
"userinput" mode=
"screen">
96 <!-- Estandarized package formats -->
97 <xsl:when test=
"contains(string(),'tar.gz')">
98 <xsl:value-of select=
"substring-before(string(),'tar.gz')"/>
99 <xsl:text>tar.*
</xsl:text>
100 <xsl:value-of select=
"substring-after(string(),'tar.gz')"/>
101 <xsl:text>
</xsl:text>
103 <!-- Select Endian level for uClibc -->
104 <xsl:when test=
"$endian='xbig' and contains(string(),'LITTLE_ENDIAN')"/>
105 <xsl:when test=
"$endian='xlittle' and contains(string(),'BIG_ENDIAN')"/>
106 <!-- Setting $LANG for /etc/profile -->
107 <xsl:when test=
"ancestor::sect1[@id='ch-scripts-profile'] and
108 contains(string(),'export LANG=')">
109 <xsl:value-of select=
"substring-before(string(),'export LANG=')"/>
110 <xsl:text>export LANG=
</xsl:text>
111 <xsl:value-of select=
"$lang"/>
112 <xsl:value-of select=
"substring-after(string(),'charmap]')"/>
113 <xsl:text>
</xsl:text>
115 <!-- Compile the keymap into the kernel has been disabled -->
116 <xsl:when test=
"contains(string(),'defkeymap')"/>
117 <!-- Copying the kernel config file -->
118 <xsl:when test=
"string() = 'make mrproper'">
119 <xsl:text>make mrproper

</xsl:text>
120 <xsl:text>cp -v ../kernel-config .config

</xsl:text>
122 <!-- No interactive commands are needed if the .config file is the proper one -->
123 <xsl:when test=
"contains(string(),'menuconfig')"/>
124 <!-- Don't stop on strip run -->
125 <xsl:when test=
"contains(string(),'strip ')">
126 <xsl:apply-templates/>
127 <xsl:text> || true

</xsl:text>
129 <!-- The rest of commands -->
131 <xsl:apply-templates/>
132 <xsl:text>
</xsl:text>
137 <xsl:template match=
"replaceable">
139 <xsl:when test=
"ancestor::sect1[@id='ch-cross-tools-glibc']">
140 <xsl:value-of select=
"$timezone"/>
142 <xsl:when test=
"ancestor::sect1[@id='ch-cross-tools-groff'] or
143 ancestor::sect1[@id='ch-system-groff']">
144 <xsl:value-of select=
"$page"/>
147 <xsl:text>**EDITME
</xsl:text>
148 <xsl:apply-templates/>
149 <xsl:text>EDITME**
</xsl:text>