source: dump-blfs-scripts.xsl@ d419098

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since d419098 was d419098, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Added the stylesheet for BLFS, first draft. Depend on a few tags additions to the book sources.

  • Property mode set to 100644
File size: 7.0 KB
Line 
1<?xml version="1.0"?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:exsl="http://exslt.org/common"
5 extension-element-prefixes="exsl"
6 version="1.0">
7
8<!-- XSLT stylesheet to create shell scripts from BLFS books. -->
9
10 <!-- Run optional test suites? -->
11 <xsl:param name="testsuite" select="0"/>
12
13 <xsl:template match="/">
14 <xsl:apply-templates select="//sect1"/>
15 </xsl:template>
16
17 <xsl:template match="sect1">
18 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
19 count(descendant::screen/userinput) &gt; count(descendant::screen[@role='nodump'])">
20 <!-- The dirs names -->
21 <xsl:variable name="pi-dir" select="../../processing-instruction('dbhtml')"/>
22 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
23 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
24 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
25 <!-- The file names -->
26 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
27 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
28 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
29 <!-- Package variables -->
30 <xsl:param name="package" select="sect1info/keywordset/keyword[@role='package']"/>
31 <xsl:param name="ftpdir" select="sect1info/keywordset/keyword[@role='ftpdir']"/>
32 <xsl:param name="unpackdir" select="sect1info/keywordset/keyword[@role='unpackdir']"/>
33 <!-- Creating dirs and files -->
34 <exsl:document href="{$dirname}/{$filename}" method="text">
35 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
36 <xsl:apply-templates select="sect2 | screen">
37 <xsl:with-param name="package" select="$package"/>
38 <xsl:with-param name="ftpdir" select="$ftpdir"/>
39 <xsl:with-param name="unpackdir" select="$unpackdir"/>
40 </xsl:apply-templates>
41 <xsl:if test="sect2[@role='package']">
42 <xsl:text>cd ~/sources/</xsl:text>
43 <xsl:value-of select="$ftpdir"/>
44 <xsl:text>&#xA;rm -rf </xsl:text>
45 <xsl:value-of select="$unpackdir"/>
46 <xsl:text>&#xA;&#xA;</xsl:text>
47 </xsl:if>
48 <xsl:text>exit</xsl:text>
49 </exsl:document>
50 </xsl:if>
51 </xsl:template>
52
53 <xsl:template match="sect2">
54 <xsl:param name="package" select="foo"/>
55 <xsl:param name="ftpdir" select="foo"/>
56 <xsl:param name="unpackdir" select="foo"/>
57 <xsl:choose>
58 <xsl:when test="@role = 'package'">
59 <xsl:apply-templates select="para"/>
60 <xsl:text>&#xA;</xsl:text>
61 <xsl:text>mkdir -p ~/sources/</xsl:text>
62 <xsl:value-of select="$ftpdir"/>
63 <xsl:text>&#xA;cd ~/sources/</xsl:text>
64 <xsl:value-of select="$ftpdir"/>
65 <xsl:text>&#xA;</xsl:text>
66 <xsl:apply-templates select="itemizedlist/listitem/para">
67 <xsl:with-param name="package" select="$package"/>
68 <xsl:with-param name="ftpdir" select="$ftpdir"/>
69 <xsl:with-param name="unpackdir" select="$unpackdir"/>
70 </xsl:apply-templates>
71 <xsl:text>&#xA;</xsl:text>
72 </xsl:when>
73 <xsl:when test="@role = 'installation'">
74 <xsl:text>tar -xf </xsl:text>
75 <xsl:value-of select="$package"/>
76 <xsl:text>.*&#xA;cd </xsl:text>
77 <xsl:value-of select="$unpackdir"/>
78 <xsl:text>&#xA;</xsl:text>
79 <xsl:apply-templates select=".//screen | .//para/command"/>
80 <xsl:text>&#xA;</xsl:text>
81 </xsl:when>
82 <xsl:when test="@role = 'configuration'">
83 <xsl:apply-templates select=".//screen"/>
84 <xsl:text>&#xA;</xsl:text>
85 </xsl:when>
86 <xsl:otherwise/>
87 </xsl:choose>
88 </xsl:template>
89
90 <xsl:template match="para">
91 <xsl:choose>
92 <xsl:when test="@role = 'required'">
93 <xsl:text># REQUIRED: </xsl:text>
94 <xsl:apply-templates select="xref"/>
95 <xsl:text>&#xA;</xsl:text>
96 </xsl:when>
97 <xsl:when test="@role = 'recommended'">
98 <xsl:text># RECOMMENDED: </xsl:text>
99 <xsl:apply-templates select="xref"/>
100 <xsl:text>&#xA;</xsl:text>
101 </xsl:when>
102 <xsl:when test="@role = 'optional'">
103 <xsl:text># OPTIONAL: </xsl:text>
104 <xsl:apply-templates select="xref"/>
105 <xsl:text>&#xA;</xsl:text>
106 </xsl:when>
107 <xsl:otherwise/>
108 </xsl:choose>
109 </xsl:template>
110
111 <xsl:template match="xref">
112 <xsl:value-of select="@linkend"/>
113 <xsl:text>&#x20;&#x20;</xsl:text>
114 </xsl:template>
115
116 <xsl:template match="itemizedlist/listitem/para">
117 <xsl:param name="package" select="foo"/>
118 <xsl:param name="ftpdir" select="foo"/>
119 <xsl:param name="unpackdir" select="foo"/>
120 <xsl:choose>
121 <xsl:when test="contains(string(),'HTTP')">
122 <xsl:text>wget </xsl:text>
123 <xsl:value-of select="ulink/@url"/>
124 <xsl:text> || \&#xA;</xsl:text>
125 </xsl:when>
126 <xsl:when test="contains(string(),'FTP')">
127 <xsl:text>wget </xsl:text>
128 <xsl:value-of select="ulink/@url"/>
129 <xsl:text> || \&#xA;</xsl:text>
130 </xsl:when>
131 <xsl:when test="contains(string(),'MD5')">
132 <xsl:text>wget ftp://anduin.linuxfromscratch.org/BLFS/conglomeration/</xsl:text>
133 <xsl:value-of select="$ftpdir"/>
134 <xsl:text>/</xsl:text>
135 <xsl:value-of select="$package"/>
136 <xsl:text>.bz2&#xA;</xsl:text>
137 <!-- Commented out due that we don't know where the package
138 will be dowloaded from.
139 <xsl:text>echo "</xsl:text>
140 <xsl:value-of select="substring-after(string(),'sum: ')"/>
141 <xsl:text>&#x20;&#x20;</xsl:text>
142 <xsl:value-of select="$package"/>
143 <xsl:text>" | md5sum -c -&#xA;</xsl:text>-->
144 </xsl:when>
145 <xsl:when test="contains(string(),'patch')">
146 <xsl:text>wget </xsl:text>
147 <xsl:value-of select="ulink/@url"/>
148 <xsl:text>&#xA;</xsl:text>
149 </xsl:when>
150 <xsl:otherwise/>
151 </xsl:choose>
152 </xsl:template>
153
154 <xsl:template match="screen">
155 <xsl:if test="child::* = userinput">
156 <xsl:choose>
157 <xsl:when test="@role = 'nodump'"/>
158 <xsl:otherwise>
159 <xsl:if test="@role = 'root'">
160 <xsl:text>sudo </xsl:text>
161 </xsl:if>
162 <xsl:apply-templates select="userinput" mode="screen"/>
163 </xsl:otherwise>
164 </xsl:choose>
165 </xsl:if>
166 </xsl:template>
167
168 <xsl:template match="para/command">
169 <xsl:if test="$testsuite != '0' and
170 (contains(string(),'test') or
171 contains(string(),'check'))">
172 <xsl:value-of select="substring-before(string(),'make')"/>
173 <xsl:text>make -k</xsl:text>
174 <xsl:value-of select="substring-after(string(),'make')"/>
175 <xsl:text> || true&#xA;</xsl:text>
176 </xsl:if>
177 </xsl:template>
178
179 <xsl:template match="userinput" mode="screen">
180 <xsl:apply-templates/>
181 <xsl:text>&#xA;</xsl:text>
182 </xsl:template>
183
184 <xsl:template match="replaceable">
185 <xsl:text>**EDITME</xsl:text>
186 <xsl:apply-templates/>
187 <xsl:text>EDITME**</xsl:text>
188 </xsl:template>
189
190</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.