source: dump-blfs-scripts.xsl@ 681f928

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

Replaced the xsl:param "unpackdir" by the shell envar "$UNPACKDIR"

  • Property mode set to 100644
File size: 6.7 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 <!-- Creating dirs and files -->
33 <exsl:document href="{$dirname}/{$filename}" method="text">
34 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
35 <xsl:apply-templates select="sect2 | screen">
36 <xsl:with-param name="package" select="$package"/>
37 <xsl:with-param name="ftpdir" select="$ftpdir"/>
38 </xsl:apply-templates>
39 <xsl:if test="sect2[@role='package']">
40 <xsl:text>cd ~/sources/</xsl:text>
41 <xsl:value-of select="$ftpdir"/>
42 <xsl:text>&#xA;rm -rf $UNPACKDIR&#xA;&#xA;</xsl:text>
43 </xsl:if>
44 <xsl:text>exit</xsl:text>
45 </exsl:document>
46 </xsl:if>
47 </xsl:template>
48
49 <xsl:template match="sect2">
50 <xsl:param name="package" select="foo"/>
51 <xsl:param name="ftpdir" select="foo"/>
52 <xsl:choose>
53 <xsl:when test="@role = 'package'">
54 <xsl:apply-templates select="para"/>
55 <xsl:text>&#xA;</xsl:text>
56 <xsl:text>mkdir -p ~/sources/</xsl:text>
57 <xsl:value-of select="$ftpdir"/>
58 <xsl:text>&#xA;cd ~/sources/</xsl:text>
59 <xsl:value-of select="$ftpdir"/>
60 <xsl:text>&#xA;</xsl:text>
61 <xsl:apply-templates select="itemizedlist/listitem/para">
62 <xsl:with-param name="package" select="$package"/>
63 <xsl:with-param name="ftpdir" select="$ftpdir"/>
64 </xsl:apply-templates>
65 <xsl:text>&#xA;</xsl:text>
66 </xsl:when>
67 <xsl:when test="@role = 'installation'">
68 <xsl:text>tar -xf </xsl:text>
69 <xsl:value-of select="$package"/>
70 <xsl:text>.* > /tmp/unpacked&#xA;</xsl:text>
71 <xsl:text>UNPACKDIR=`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'`&#xA;</xsl:text>
72 <xsl:text>cd $UNPACKDIR&#xA;</xsl:text>
73 <xsl:apply-templates select=".//screen | .//para/command"/>
74 <xsl:text>&#xA;</xsl:text>
75 </xsl:when>
76 <xsl:when test="@role = 'configuration'">
77 <xsl:apply-templates select=".//screen"/>
78 <xsl:text>&#xA;</xsl:text>
79 </xsl:when>
80 <xsl:otherwise/>
81 </xsl:choose>
82 </xsl:template>
83
84 <xsl:template match="para">
85 <xsl:choose>
86 <xsl:when test="@role = 'required'">
87 <xsl:text># REQUIRED: </xsl:text>
88 <xsl:apply-templates select="xref"/>
89 <xsl:text>&#xA;</xsl:text>
90 </xsl:when>
91 <xsl:when test="@role = 'recommended'">
92 <xsl:text># RECOMMENDED: </xsl:text>
93 <xsl:apply-templates select="xref"/>
94 <xsl:text>&#xA;</xsl:text>
95 </xsl:when>
96 <xsl:when test="@role = 'optional'">
97 <xsl:text># OPTIONAL: </xsl:text>
98 <xsl:apply-templates select="xref"/>
99 <xsl:text>&#xA;</xsl:text>
100 </xsl:when>
101 <xsl:otherwise/>
102 </xsl:choose>
103 </xsl:template>
104
105 <xsl:template match="xref">
106 <xsl:value-of select="@linkend"/>
107 <xsl:text>&#x20;&#x20;</xsl:text>
108 </xsl:template>
109
110 <xsl:template match="itemizedlist/listitem/para">
111 <xsl:param name="package" select="foo"/>
112 <xsl:param name="ftpdir" select="foo"/>
113 <xsl:choose>
114 <xsl:when test="contains(string(),'HTTP')">
115 <xsl:text>wget </xsl:text>
116 <xsl:value-of select="ulink/@url"/>
117 <xsl:text> || \&#xA;</xsl:text>
118 </xsl:when>
119 <xsl:when test="contains(string(),'FTP')">
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(),'MD5')">
125 <xsl:text>wget ftp://anduin.linuxfromscratch.org/BLFS/conglomeration/</xsl:text>
126 <xsl:value-of select="$ftpdir"/>
127 <xsl:text>/</xsl:text>
128 <xsl:value-of select="$package"/>
129 <xsl:text>.bz2&#xA;</xsl:text>
130 <!-- Commented out due that we don't know where the package
131 will be dowloaded from.
132 <xsl:text>echo "</xsl:text>
133 <xsl:value-of select="substring-after(string(),'sum: ')"/>
134 <xsl:text>&#x20;&#x20;</xsl:text>
135 <xsl:value-of select="$package"/>
136 <xsl:text>" | md5sum -c -&#xA;</xsl:text>-->
137 </xsl:when>
138 <xsl:when test="contains(string(),'patch')">
139 <xsl:text>wget </xsl:text>
140 <xsl:value-of select="ulink/@url"/>
141 <xsl:text>&#xA;</xsl:text>
142 </xsl:when>
143 <xsl:otherwise/>
144 </xsl:choose>
145 </xsl:template>
146
147 <xsl:template match="screen">
148 <xsl:if test="child::* = userinput">
149 <xsl:choose>
150 <xsl:when test="@role = 'nodump'"/>
151 <xsl:otherwise>
152 <xsl:if test="@role = 'root'">
153 <xsl:text>sudo </xsl:text>
154 </xsl:if>
155 <xsl:apply-templates select="userinput" mode="screen"/>
156 </xsl:otherwise>
157 </xsl:choose>
158 </xsl:if>
159 </xsl:template>
160
161 <xsl:template match="para/command">
162 <xsl:if test="$testsuite != '0' and
163 (contains(string(),'test') or
164 contains(string(),'check'))">
165 <xsl:value-of select="substring-before(string(),'make')"/>
166 <xsl:text>make -k</xsl:text>
167 <xsl:value-of select="substring-after(string(),'make')"/>
168 <xsl:text> || true&#xA;</xsl:text>
169 </xsl:if>
170 </xsl:template>
171
172 <xsl:template match="userinput" mode="screen">
173 <xsl:apply-templates/>
174 <xsl:text>&#xA;</xsl:text>
175 </xsl:template>
176
177 <xsl:template match="replaceable">
178 <xsl:text>**EDITME</xsl:text>
179 <xsl:apply-templates/>
180 <xsl:text>EDITME**</xsl:text>
181 </xsl:template>
182
183</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.