source: BLFS/blfs.xsl@ 796ecad

experimental
Last change on this file since 796ecad was a46ada0, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Added Id key to some file to see in what of them is expanded and in what not.

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