source: BLFS/dump-blfs-scripts.xsl@ b701a0f

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

Moved BLFS files to the new BLFS dir.

  • Property mode set to 100644
File size: 6.9 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 <!-- FTP/HTTP server -->
14 <xsl:param name="server">
15 ftp://anduin.linuxfromscratch.org/BLFS/conglomeration
16 </xsl:param>
17
18 <xsl:template match="/">
19 <xsl:apply-templates select="//sect1"/>
20 </xsl:template>
21
22 <xsl:template match="sect1">
23 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
24 count(descendant::screen/userinput) &gt; count(descendant::screen[@role='nodump'])">
25 <!-- The dirs names -->
26 <xsl:variable name="pi-dir" select="../../processing-instruction('dbhtml')"/>
27 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
28 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
29 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
30 <!-- The file names -->
31 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
32 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
33 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
34 <!-- Package variables -->
35 <xsl:param name="package" select="sect1info/keywordset/keyword[@role='package']"/>
36 <xsl:param name="ftpdir" select="sect1info/keywordset/keyword[@role='ftpdir']"/>
37 <!-- Creating dirs and files -->
38 <exsl:document href="{$dirname}/{$filename}" method="text">
39 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
40 <xsl:apply-templates select="sect2 | screen">
41 <xsl:with-param name="package" select="$package"/>
42 <xsl:with-param name="ftpdir" select="$ftpdir"/>
43 </xsl:apply-templates>
44 <xsl:if test="sect2[@role='package']">
45 <xsl:text>cd ~/sources/</xsl:text>
46 <xsl:value-of select="$ftpdir"/>
47 <xsl:text>&#xA;rm -rf $UNPACKDIR&#xA;&#xA;</xsl:text>
48 </xsl:if>
49 <xsl:text>exit</xsl:text>
50 </exsl:document>
51 </xsl:if>
52 </xsl:template>
53
54 <xsl:template match="sect2">
55 <xsl:param name="package" select="foo"/>
56 <xsl:param name="ftpdir" 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:apply-templates>
70 <xsl:text>&#xA;</xsl:text>
71 </xsl:when>
72 <xsl:when test="@role = 'installation'">
73 <xsl:text>tar -xvf </xsl:text>
74 <xsl:value-of select="$package"/>
75 <xsl:text>.* > /tmp/unpacked&#xA;</xsl:text>
76 <xsl:text>UNPACKDIR=`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'`&#xA;</xsl:text>
77 <xsl:text>cd $UNPACKDIR&#xA;</xsl:text>
78 <xsl:apply-templates select=".//screen | .//para/command"/>
79 <xsl:text>&#xA;</xsl:text>
80 </xsl:when>
81 <xsl:when test="@role = 'configuration'">
82 <xsl:apply-templates select=".//screen"/>
83 <xsl:text>&#xA;</xsl:text>
84 </xsl:when>
85 <xsl:otherwise/>
86 </xsl:choose>
87 </xsl:template>
88
89 <xsl:template match="para">
90 <xsl:choose>
91 <xsl:when test="@role = 'required'">
92 <xsl:text># REQUIRED: </xsl:text>
93 <xsl:apply-templates select="xref"/>
94 <xsl:text>&#xA;</xsl:text>
95 </xsl:when>
96 <xsl:when test="@role = 'recommended'">
97 <xsl:text># RECOMMENDED: </xsl:text>
98 <xsl:apply-templates select="xref"/>
99 <xsl:text>&#xA;</xsl:text>
100 </xsl:when>
101 <xsl:when test="@role = 'optional'">
102 <xsl:text># OPTIONAL: </xsl:text>
103 <xsl:apply-templates select="xref"/>
104 <xsl:text>&#xA;</xsl:text>
105 </xsl:when>
106 <xsl:otherwise/>
107 </xsl:choose>
108 </xsl:template>
109
110 <xsl:template match="xref">
111 <xsl:value-of select="@linkend"/>
112 <xsl:text>&#x20;&#x20;</xsl:text>
113 </xsl:template>
114
115 <xsl:template match="itemizedlist/listitem/para">
116 <xsl:param name="package" select="foo"/>
117 <xsl:param name="ftpdir" select="foo"/>
118 <xsl:choose>
119 <xsl:when test="contains(string(),'HTTP')">
120 <xsl:text>wget </xsl:text>
121 <xsl:value-of select="ulink/@url"/>
122 <xsl:text> || \&#xA;</xsl:text>
123 </xsl:when>
124 <xsl:when test="contains(string(),'FTP')">
125 <xsl:text>wget </xsl:text>
126 <xsl:value-of select="ulink/@url"/>
127 <xsl:text> || \&#xA;</xsl:text>
128 </xsl:when>
129 <xsl:when test="contains(string(),'MD5')">
130 <xsl:text>wget </xsl:text>
131 <xsl:value-of select="$server"/>
132 <xsl:text>/</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.