source: BLFS/libs/scripts.xsl@ 37b4eab

experimental
Last change on this file since 37b4eab was 043bcbe, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Removed a now unneeded "if".

  • 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<!-- $Id$ -->
9
10<!-- XSLT stylesheet to create shell scripts from BLFS books. -->
11
12 <xsl:template match="/">
13 <xsl:apply-templates select="//sect1"/>
14 </xsl:template>
15
16<!--=================== Master chunks code ======================-->
17
18 <xsl:template match="sect1">
19 <xsl:if test="@id != 'locale-issues' and
20 (count(descendant::screen/userinput) &gt; 0 and
21 count(descendant::screen/userinput) &gt;
22 count(descendant::screen[@role='nodump']))">
23 <!-- The file names -->
24 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
25 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
26 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
27 <!-- Package variables BROKEN Need be fixed -->
28 <xsl:param name="package" select="sect1info/keywordset/keyword[@role='package']"/>
29 <xsl:param name="ftpdir" select="sect1info/keywordset/keyword[@role='ftpdir']"/>
30 <!-- The build order -->
31 <xsl:variable name="position" select="position()"/>
32 <xsl:variable name="order">
33 <xsl:choose>
34 <xsl:when test="string-length($position) = 1">
35 <xsl:text>00</xsl:text>
36 <xsl:value-of select="$position"/>
37 </xsl:when>
38 <xsl:when test="string-length($position) = 2">
39 <xsl:text>0</xsl:text>
40 <xsl:value-of select="$position"/>
41 </xsl:when>
42 <xsl:otherwise>
43 <xsl:value-of select="$position"/>
44 </xsl:otherwise>
45 </xsl:choose>
46 </xsl:variable>
47 <!-- Creating dirs and files -->
48 <exsl:document href="{$order}-{$filename}" method="text">
49 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
50 <xsl:choose>
51 <xsl:when test="sect2[@role='package']">
52 <xsl:apply-templates select="sect2">
53 <xsl:with-param name="package" select="$package"/>
54 <xsl:with-param name="ftpdir" select="$ftpdir"/>
55 </xsl:apply-templates>
56 <xsl:text>cd ~/sources/</xsl:text>
57 <xsl:value-of select="$ftpdir"/>
58 <xsl:text>&#xA;rm -rf $UNPACKDIR&#xA;&#xA;</xsl:text>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:apply-templates select=".//screen"/>
62 </xsl:otherwise>
63 </xsl:choose>
64 <xsl:text>exit</xsl:text>
65 </exsl:document>
66 </xsl:if>
67 </xsl:template>
68
69<!--======================= Sub-sections code =======================-->
70
71 <xsl:template match="sect2">
72 <xsl:param name="package" select="foo"/>
73 <xsl:param name="ftpdir" select="foo"/>
74 <xsl:choose>
75 <xsl:when test="@role = 'package'">
76 <xsl:text>mkdir -p ~/sources/</xsl:text>
77 <xsl:value-of select="$ftpdir"/>
78 <xsl:text>&#xA;cd ~/sources/</xsl:text>
79 <xsl:value-of select="$ftpdir"/>
80 <xsl:text>&#xA;</xsl:text>
81 <xsl:apply-templates select="itemizedlist/listitem/para">
82 <xsl:with-param name="package" select="$package"/>
83 <xsl:with-param name="ftpdir" select="$ftpdir"/>
84 </xsl:apply-templates>
85 <xsl:text>&#xA;</xsl:text>
86 </xsl:when>
87 <xsl:when test="@role = 'installation'">
88 <xsl:text>tar -xvf </xsl:text>
89 <xsl:value-of select="$package"/>
90 <xsl:text> > /tmp/unpacked&#xA;</xsl:text>
91 <xsl:text>UNPACKDIR=`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'`&#xA;</xsl:text>
92 <xsl:text>cd $UNPACKDIR&#xA;</xsl:text>
93 <xsl:apply-templates select=".//screen | .//para/command"/>
94 <xsl:text>&#xA;</xsl:text>
95 </xsl:when>
96 <xsl:when test="@role = 'configuration'">
97 <xsl:apply-templates select=".//screen"/>
98 <xsl:text>&#xA;</xsl:text>
99 </xsl:when>
100 <xsl:otherwise/>
101 </xsl:choose>
102 </xsl:template>
103
104<!--==================== Download code =======================-->
105
106 <xsl:template match="itemizedlist/listitem/para">
107 <xsl:param name="package" select="foo"/>
108 <xsl:param name="ftpdir" select="foo"/>
109 <xsl:choose>
110 <xsl:when test="contains(string(),'HTTP')">
111 <!-- SRC_ARCHIVE may have subdirectories or not -->
112 <xsl:text>cp $SRC_ARCHIVE/</xsl:text>
113 <xsl:value-of select="$ftpdir"/>
114 <xsl:text>/</xsl:text>
115 <xsl:value-of select="$package"/>
116 <xsl:text> || \&#xA;</xsl:text>
117 <xsl:text>cp $SRC_ARCHIVE/</xsl:text>
118 <xsl:value-of select="$package"/>
119 <xsl:text> || \&#xA;</xsl:text>
120 <!-- The FTP_SERVER mirror -->
121 <xsl:text>wget $FTP_SERVER/BLFS/conglomeration/</xsl:text>
122 <xsl:value-of select="$ftpdir"/>
123 <xsl:text>/</xsl:text>
124 <xsl:value-of select="$package"/>
125 <xsl:text> || \&#xA;</xsl:text>
126 <!-- Upstream HTTP URL -->
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(),'FTP')">
132 <!-- Upstream FTP URL -->
133 <xsl:text>wget </xsl:text>
134 <xsl:value-of select="ulink/@url"/>
135 <xsl:text>&#xA;</xsl:text>
136 </xsl:when>
137 <xsl:when test="contains(string(),'MD5')">
138 <xsl:text>echo "</xsl:text>
139 <xsl:value-of select="substring-after(string(),'sum: ')"/>
140 <xsl:text>&#x20;&#x20;</xsl:text>
141 <xsl:value-of select="$package"/>
142 <xsl:text>" | md5sum -c -&#xA;</xsl:text>
143 </xsl:when>
144 <!-- Patches. Need be veryfied -->
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<!--======================== Commands code ==========================-->
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="(contains(string(),'test') or
172 contains(string(),'check'))">
173 <xsl:text>#</xsl:text>
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.