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 |
|
---|
14 | <!-- XSLT stylesheet to create shell scripts from CLFS2 books. -->
|
---|
15 |
|
---|
16 | <!-- Time zone -->
|
---|
17 | <xsl:param name="timezone" select="GMT"/>
|
---|
18 |
|
---|
19 | <!-- Page size -->
|
---|
20 | <xsl:param name="page" select="letter"/>
|
---|
21 |
|
---|
22 | <!-- Locale settings -->
|
---|
23 | <xsl:param name="lang" select="C"/>
|
---|
24 |
|
---|
25 | <xsl:template match="/">
|
---|
26 | <xsl:apply-templates select="//sect1"/>
|
---|
27 | </xsl:template>
|
---|
28 |
|
---|
29 | <xsl:template match="sect1">
|
---|
30 | <xsl:choose>
|
---|
31 | <xsl:when test="../@id='chapter-partitioning' or
|
---|
32 | ../@id='chapter-getting-materials' or
|
---|
33 | ../@id='chapter-final-preps'"/>
|
---|
34 | <xsl:otherwise>
|
---|
35 | <xsl:if test="count(descendant::screen/userinput) > 0 and
|
---|
36 | count(descendant::screen/userinput) >
|
---|
37 | count(descendant::screen[@role='nodump'])">
|
---|
38 | <!-- The dirs names -->
|
---|
39 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
40 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
41 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
42 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
43 | <!-- The file names -->
|
---|
44 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
45 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
46 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
47 | <!-- The build order -->
|
---|
48 | <xsl:variable name="position" select="position()"/>
|
---|
49 | <xsl:variable name="order">
|
---|
50 | <xsl:choose>
|
---|
51 | <xsl:when test="string-length($position) = 1">
|
---|
52 | <xsl:text>00</xsl:text>
|
---|
53 | <xsl:value-of select="$position"/>
|
---|
54 | </xsl:when>
|
---|
55 | <xsl:when test="string-length($position) = 2">
|
---|
56 | <xsl:text>0</xsl:text>
|
---|
57 | <xsl:value-of select="$position"/>
|
---|
58 | </xsl:when>
|
---|
59 | <xsl:otherwise>
|
---|
60 | <xsl:value-of select="$position"/>
|
---|
61 | </xsl:otherwise>
|
---|
62 | </xsl:choose>
|
---|
63 | </xsl:variable>
|
---|
64 | <!-- Creating dirs and files -->
|
---|
65 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
66 | <xsl:text>#!/bin/bash
set +h
set -e

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

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