source: BLFS/xsl/scripts.xsl@ edba613

ablfs
Last change on this file since edba613 was 1061e6bc, checked in by Pierre Labastie <pierre@…>, 12 years ago

Adjust to modifications in X Window chapter

  • Property mode set to 100644
File size: 23.0 KB
RevLine 
[1061e6bc]1<?xml version="1.0"?>
[3c10176]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
[63fc514]8<!-- $Id: scripts.xsl 34 2012-02-21 16:05:09Z labastie $ -->
[3c10176]9
10<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
11
[c0bc66d]12 <!-- Build as user (y) or as root (n)? -->
[dd7e92a4]13 <xsl:param name="sudo" select="'y'"/>
[c0bc66d]14
[3c10176]15 <xsl:template match="/">
16 <xsl:apply-templates select="//sect1"/>
17 </xsl:template>
18
19<!--=================== Master chunks code ======================-->
20
21 <xsl:template match="sect1">
22
[63fc514]23 <xsl:if test="@id != 'bootscripts'">
[3c10176]24 <!-- The file names -->
[f4ed135]25 <xsl:variable name="filename" select="@id"/>
[3c10176]26
27 <!-- The build order -->
28 <xsl:variable name="position" select="position()"/>
29 <xsl:variable name="order">
30 <xsl:choose>
31 <xsl:when test="string-length($position) = 1">
32 <xsl:text>00</xsl:text>
33 <xsl:value-of select="$position"/>
34 </xsl:when>
35 <xsl:when test="string-length($position) = 2">
36 <xsl:text>0</xsl:text>
37 <xsl:value-of select="$position"/>
38 </xsl:when>
39 <xsl:otherwise>
40 <xsl:value-of select="$position"/>
41 </xsl:otherwise>
42 </xsl:choose>
43 </xsl:variable>
44
45 <!-- Depuration code -->
46 <xsl:message>
47 <xsl:text>SCRIPT is </xsl:text>
[63fc514]48 <xsl:value-of select="concat($order,'-z-',$filename)"/>
[3c10176]49 <xsl:text>&#xA; FTPDIR is </xsl:text>
[63fc514]50 <xsl:value-of select="$filename"/>
[3c10176]51 <xsl:text>&#xA;&#xA;</xsl:text>
52 </xsl:message>
53
54 <!-- Creating the scripts -->
[73c3c1c]55 <exsl:document href="{$order}-z-{$filename}" method="text">
[91ff6a9]56 <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
[3c10176]57 <xsl:choose>
58 <!-- Package page -->
[b45f723]59 <xsl:when test="sect2[@role='package'] and not(@id = 'xorg7-app' or
60 @id = 'xorg7-data' or @id = 'xorg7-driver' or
61 @id = 'xorg7-font' or @id = 'xorg7-lib' or
62 @id = 'xorg7-proto' or @id = 'xorg7-util')">
[3c10176]63 <!-- Variables -->
[63fc514]64 <!-- These three lines could be important if SRC_ARCHIVE,
65 FTP_SERVER and SRCDIR were not set in the environment.
66 But they are not tested for length or anything later,
67 so not needed
[3c10176]68 <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE&#xA;</xsl:text>
[63fc514]69 <xsl:text>FTP_SERVER=$FTP_SERVER&#xA;</xsl:text>
70 <xsl:text>SRC_DIR=$SRC_DIR&#xA;&#xA;</xsl:text>-->
[3c10176]71 <xsl:text>&#xA;PKG_DIR=</xsl:text>
[63fc514]72 <xsl:value-of select="$filename"/>
73 <xsl:text>&#xA;</xsl:text>
[3c10176]74 <!-- Download code and build commands -->
[63fc514]75 <xsl:apply-templates select="sect2"/>
[3c10176]76 <!-- Clean-up -->
[63fc514]77 <!-- xorg7-server used to require mesalib tree being present.
78 That is no more true
79 <xsl:if test="not(@id='mesalib')"> -->
[5fb652f]80 <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
[5e9076f]81 <!-- In some case, some files in the build tree are owned
82 by root -->
83 <xsl:if test="$sudo='y'">
84 <xsl:text>sudo </xsl:text>
85 </xsl:if>
[5fb652f]86 <xsl:text>rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
[63fc514]87 <!-- Same reason as preceding comment
[5fb652f]88 </xsl:if>
89 <xsl:if test="@id='xorg7-server'">
90 <xsl:text>cd $SRC_DIR/MesaLib
[1061e6bc]91UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
[5fb652f]92rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
[63fc514]93 </xsl:if> -->
[3c10176]94 </xsl:when>
[b45f723]95 <!-- Xorg7 pseudo-packages -->
96 <xsl:when test="contains(@id,'xorg7') and not(@id = 'xorg7-server')">
[63fc514]97 <xsl:text># Useless SRC_DIR=$SRC_DIR
[b45f723]98
99cd $SRC_DIR
100mkdir -p xc
101cd xc&#xA;</xsl:text>
102 <xsl:apply-templates select="sect2" mode="xorg7"/>
103 </xsl:when>
[3c10176]104 <!-- Non-package page -->
105 <xsl:otherwise>
106 <xsl:apply-templates select=".//screen"/>
107 </xsl:otherwise>
108 </xsl:choose>
109 <xsl:text>exit</xsl:text>
110 </exsl:document>
111 </xsl:if>
112 </xsl:template>
113
114<!--======================= Sub-sections code =======================-->
115
116 <xsl:template match="sect2">
117 <xsl:choose>
118 <xsl:when test="@role = 'package'">
[f65d3cb]119 <xsl:text>mkdir -p $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
120 <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
[63fc514]121 <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
[3c10176]122 <xsl:text>&#xA;</xsl:text>
123 </xsl:when>
124 <xsl:when test="@role = 'installation'">
[859d863]125 <xsl:text>
[9683707]126if [ "${PACKAGE%.zip}" = "${PACKAGE}" ]; then
127 if [[ -e unpacked ]] ; then
[1061e6bc]128 UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
[efef736]129 [[ -n $UNPACKDIR ]] &amp;&amp; [[ -d $UNPACKDIR ]] &amp;&amp; rm -rf $UNPACKDIR
[9683707]130 fi
131 tar -xvf $PACKAGE > unpacked
[1061e6bc]132 UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
[9683707]133else
134 UNPACKDIR=${PACKAGE%.zip}
135 [[ -n $UNPACKDIR ]] &amp;&amp; [[ -d $UNPACKDIR ]] &amp;&amp; rm -rf $UNPACKDIR
136 unzip -d $UNPACKDIR ${PACKAGE}
[859d863]137fi
[6ff1be4]138cd $UNPACKDIR&#xA;</xsl:text>
[3c10176]139 <xsl:apply-templates select=".//screen | .//para/command"/>
[a1d0d5c]140 <xsl:if test="$sudo = 'y'">
[52b0d10]141 <xsl:text>sudo /sbin/</xsl:text>
[a1d0d5c]142 </xsl:if>
143 <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
[3c10176]144 </xsl:when>
145 <xsl:when test="@role = 'configuration'">
[63fc514]146 <xsl:apply-templates select=".//screen" mode="config"/>
[3c10176]147 </xsl:when>
148 </xsl:choose>
149 </xsl:template>
150
[b45f723]151 <xsl:template match="sect2" mode="xorg7">
152 <xsl:choose>
[1061e6bc]153 <!-- <xsl:when test="@role = 'package'">
[0efb837]154 <xsl:apply-templates select="itemizedlist/listitem/para" mode="xorg7"/>
[1061e6bc]155 </xsl:when>-->
[b45f723]156 <xsl:when test="not(@role)">
[1061e6bc]157<!-- This is the packages download instructions> -->
158 <xsl:apply-templates select=".//screen" mode="xorg7"/>
[b45f723]159 </xsl:when>
160 <xsl:when test="@role = 'installation'">
[1061e6bc]161 <xsl:apply-templates select=".//screen" mode="xorg7"/>
[b45f723]162 <xsl:if test="$sudo = 'y'">
[52b0d10]163 <xsl:text>sudo /sbin/</xsl:text>
[b45f723]164 </xsl:if>
165 <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
166 </xsl:when>
[0efb837]167 <xsl:when test="@role = 'configuration'">
[1061e6bc]168 <xsl:text>if [[ $XORG_PREFIX != /usr ]] ; then&#xA;</xsl:text>
[0efb837]169 <xsl:apply-templates select=".//screen"/>
[1061e6bc]170 <xsl:text>fi&#xA;</xsl:text>
[0efb837]171 </xsl:when>
[b45f723]172 </xsl:choose>
173 </xsl:template>
174
[3c10176]175<!--==================== Download code =======================-->
176
177 <xsl:template name="package_name">
178 <xsl:param name="url" select="foo"/>
179 <xsl:param name="sub-url" select="substring-after($url,'/')"/>
180 <xsl:choose>
181 <xsl:when test="contains($sub-url,'/')">
182 <xsl:call-template name="package_name">
183 <xsl:with-param name="url" select="$sub-url"/>
184 </xsl:call-template>
185 </xsl:when>
186 <xsl:otherwise>
187 <xsl:choose>
188 <xsl:when test="contains($sub-url,'?')">
189 <xsl:value-of select="substring-before($sub-url,'?')"/>
190 </xsl:when>
191 <xsl:otherwise>
192 <xsl:value-of select="$sub-url"/>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:otherwise>
196 </xsl:choose>
197 </xsl:template>
198
[63fc514]199 <xsl:template match="bridgehead">
[3c10176]200 <xsl:choose>
[63fc514]201 <xsl:when test="string()='Package Information'">
202 <xsl:variable name="url">
203 <xsl:choose>
204 <xsl:when
205 test="string-length(
206 following-sibling::itemizedlist[1]/listitem[1]/para/ulink/@url)
207 &gt; 10">
208 <xsl:value-of select=
209 "following-sibling::itemizedlist[1]/listitem[1]/para/ulink/@url"/>
210 </xsl:when>
211 <xsl:otherwise>
212 <xsl:value-of select=
213 "following-sibling::itemizedlist[1]/listitem[2]/para/ulink/@url"/>
214 </xsl:otherwise>
215 </xsl:choose>
[3c10176]216 </xsl:variable>
[63fc514]217 <xsl:variable name="package">
218 <xsl:call-template name="package_name">
219 <xsl:with-param name="url" select="$url"/>
220 </xsl:call-template>
221 </xsl:variable>
222 <xsl:variable
223 name="first_letter"
224 select="translate(substring($package,1,1),
225 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
226 'abcdefghijklmnopqrstuvwxyz')"/>
227 <xsl:text>PACKAGE=</xsl:text>
228 <xsl:value-of select="$package"/>
229 <xsl:text>&#xA;if [[ ! -f $PACKAGE ]] ; then&#xA;</xsl:text>
[3c10176]230 <!-- SRC_ARCHIVE may have subdirectories or not -->
231 <xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PACKAGE ]] ; then&#xA;</xsl:text>
232 <xsl:text> cp $SRC_ARCHIVE/$PKG_DIR/$PACKAGE $PACKAGE&#xA;</xsl:text>
233 <xsl:text> elif [[ -f $SRC_ARCHIVE/$PACKAGE ]] ; then&#xA;</xsl:text>
234 <xsl:text> cp $SRC_ARCHIVE/$PACKAGE $PACKAGE&#xA; else&#xA;</xsl:text>
235 <!-- The FTP_SERVER mirror -->
[63fc514]236 <xsl:text> wget -T 30 -t 5 ${FTP_SERVER}svn/</xsl:text>
237 <xsl:value-of select="$first_letter"/>
238 <xsl:text>/$PACKAGE</xsl:text>
239 <xsl:apply-templates
240 select="following-sibling::itemizedlist[1]/listitem/para"
241 mode="package"/>
242 </xsl:when>
[1061e6bc]243 <xsl:when test="contains(string(),'Additional')">
[63fc514]244 <xsl:apply-templates
245 select="following-sibling::itemizedlist[1]/listitem/para"
246 mode="additional"/>
247 </xsl:when>
248 <xsl:otherwise/>
249 </xsl:choose>
250 </xsl:template>
251
252 <xsl:template match="para" mode="package">
253 <xsl:choose>
254 <xsl:when test="contains(string(),'HTTP')">
[3c10176]255 <!-- Upstream HTTP URL -->
[f221c2c]256 <xsl:if test="string-length(ulink/@url) &gt; '10'">
[63fc514]257 <xsl:text> || \&#xA; wget -T 30 -t 5 </xsl:text>
[f221c2c]258 <xsl:choose>
259 <xsl:when test="contains(ulink/@url,'?')">
260 <xsl:value-of select="substring-before(ulink/@url,'?')"/>
261 </xsl:when>
262 <xsl:otherwise>
263 <xsl:value-of select="ulink/@url"/>
264 </xsl:otherwise>
265 </xsl:choose>
[63fc514]266 <xsl:if test="not(contains(string(parent::listitem/following-sibling::listitem[1]/para),'FTP'))">
[fd988ce]267 <xsl:text>
268 cp $PACKAGE $SRC_ARCHIVE
269 fi
270fi
271</xsl:text>
[63fc514]272 </xsl:if>
[3c10176]273 </xsl:if>
274 </xsl:when>
275 <xsl:when test="contains(string(),'FTP')">
276 <!-- Upstream FTP URL -->
277 <xsl:if test="string-length(ulink/@url) &gt; '10'">
[63fc514]278 <xsl:text> || \&#xA; wget -T 30 -t 5 </xsl:text>
[3c10176]279 <xsl:value-of select="ulink/@url"/>
280 </xsl:if>
[fd988ce]281 <xsl:text>
282 cp $PACKAGE $SRC_ARCHIVE
283 fi
284fi
285</xsl:text>
[3c10176]286 </xsl:when>
287 <xsl:when test="contains(string(),'MD5')">
[0aaeb8e]288<!-- some md5 sums are written with a LF -->
289 <xsl:variable name="md5">
290 <xsl:choose>
[6631b83]291 <xsl:when test="contains(substring-after(string(),'sum: '),'&#xA;')">
[0aaeb8e]292 <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'&#xA;')"/>
293 </xsl:when>
294 <xsl:otherwise>
295 <xsl:value-of select="substring-after(string(),'sum: ')"/>
296 </xsl:otherwise>
297 </xsl:choose>
298 </xsl:variable>
[3c10176]299 <xsl:text>echo "</xsl:text>
[0aaeb8e]300 <xsl:value-of select="$md5"/>
[3c10176]301 <xsl:text>&#x20;&#x20;$PACKAGE" | md5sum -c -&#xA;</xsl:text>
302 </xsl:when>
[63fc514]303 </xsl:choose>
304 </xsl:template>
305
306 <xsl:template match="para" mode="additional">
307 <xsl:choose>
[3c10176]308 <xsl:when test="contains(string(ulink/@url),'.patch')">
[b9c5dc9]309 <xsl:variable name="patch">
310 <xsl:call-template name="package_name">
311 <xsl:with-param name="url" select="ulink/@url"/>
312 </xsl:call-template>
313 </xsl:variable>
314 <xsl:text>PATCH=</xsl:text>
315 <xsl:value-of select="$patch"/>
316 <xsl:text>&#xA;if [[ ! -f $PATCH ]] ; then&#xA;</xsl:text>
317 <!-- SRC_ARCHIVE may have subdirectories or not -->
318 <xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PATCH ]] ; then&#xA;</xsl:text>
319 <xsl:text> cp $SRC_ARCHIVE/$PKG_DIR/$PATCH $PATCH&#xA;</xsl:text>
320 <xsl:text> elif [[ -f $SRC_ARCHIVE/$PATCH ]] ; then&#xA;</xsl:text>
321 <xsl:text> cp $SRC_ARCHIVE/$PATCH $PATCH&#xA; else&#xA;</xsl:text>
[63fc514]322 <xsl:text>wget -T 30 -t 5 </xsl:text>
[3c10176]323 <xsl:value-of select="ulink/@url"/>
324 <xsl:text>&#xA;</xsl:text>
[fd988ce]325 <xsl:text>
326 cp $PATCH $SRC_ARCHIVE
327 fi
328fi
329</xsl:text>
[3c10176]330 </xsl:when>
[63fc514]331 <xsl:when test="ulink">
332 <xsl:if test="string-length(ulink/@url) &gt; '10'">
333 <xsl:variable name="package">
334 <xsl:call-template name="package_name">
335 <xsl:with-param name="url" select="ulink/@url"/>
336 </xsl:call-template>
337 </xsl:variable>
338 <xsl:variable
339 name="first_letter"
340 select="translate(substring($package,1,1),
341 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
342 'abcdefghijklmnopqrstuvwxyz')"/>
343 <xsl:text>PACKAGE1=</xsl:text>
344 <xsl:value-of select="$package"/>
345 <xsl:text>&#xA;if [[ ! -f $PACKAGE1 ]] ; then&#xA;</xsl:text>
346 <!-- SRC_ARCHIVE may have subdirectories or not -->
347 <xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PACKAGE1 ]] ; then&#xA;</xsl:text>
348 <xsl:text> cp $SRC_ARCHIVE/$PKG_DIR/$PACKAGE1 $PACKAGE1&#xA;</xsl:text>
349 <xsl:text> elif [[ -f $SRC_ARCHIVE/$PACKAGE1 ]] ; then&#xA;</xsl:text>
350 <xsl:text> cp $SRC_ARCHIVE/$PACKAGE1 $PACKAGE1&#xA; else&#xA;</xsl:text>
351 <!-- The FTP_SERVER mirror -->
[b9c5dc9]352 <xsl:text> wget -T 30 -t 5 ${FTP_SERVER}svn/</xsl:text>
[63fc514]353 <xsl:value-of select="$first_letter"/>
354 <xsl:text>/$PACKAGE1</xsl:text>
355 <xsl:text> || \&#xA; wget -T 30 -t 5 </xsl:text>
356 <xsl:value-of select="ulink/@url"/>
[fd988ce]357 <xsl:text>
358 cp $PACKAGE1 $SRC_ARCHIVE
359 fi
360fi
361</xsl:text>
[63fc514]362 </xsl:if>
363 </xsl:when>
364 <xsl:when test="contains(string(),'MD5')">
[968e958]365<!-- some md5 sums are written with a LF -->
366 <xsl:variable name="md5">
367 <xsl:choose>
[6631b83]368 <xsl:when test="contains(substring-after(string(),'sum: '),'&#xA;')">
[968e958]369 <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'&#xA;')"/>
370 </xsl:when>
371 <xsl:otherwise>
372 <xsl:value-of select="substring-after(string(),'sum: ')"/>
373 </xsl:otherwise>
374 </xsl:choose>
375 </xsl:variable>
[63fc514]376 <xsl:text>echo "</xsl:text>
[968e958]377 <xsl:value-of select="$md5"/>
[63fc514]378 <xsl:text>&#x20;&#x20;$PACKAGE1" | md5sum -c -&#xA;</xsl:text>
379 </xsl:when>
[3c10176]380 </xsl:choose>
381 </xsl:template>
382
[5be3651]383 <xsl:template match="itemizedlist/listitem/para" mode="xorg7">
[0efb837]384 <xsl:if test="contains(string(ulink/@url),'.md5') or
385 contains(string(ulink/@url),'.wget')">
[63fc514]386 <xsl:text>wget -T 30 -t 5 </xsl:text>
[0efb837]387 <xsl:value-of select="ulink/@url"/>
388 <xsl:text>&#xA;</xsl:text>
389 </xsl:if>
390 </xsl:template>
391
392 <xsl:template match="itemizedlist/listitem/para" mode="xorg7-patch">
[5be3651]393 <xsl:if test="contains(string(ulink/@url),'.patch')">
[63fc514]394 <xsl:text>wget -T 30 -t 5 </xsl:text>
[5be3651]395 <xsl:value-of select="ulink/@url"/>
396 <xsl:text>&#xA;</xsl:text>
397 </xsl:if>
398 </xsl:template>
399
[3c10176]400<!--======================== Commands code ==========================-->
401
402 <xsl:template match="screen">
403 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
[96a30c7]404 <xsl:choose>
405 <xsl:when test="@role = 'root'">
406 <xsl:if test="$sudo = 'y'">
[f53dc4c]407 <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
[96a30c7]408 </xsl:if>
[f53dc4c]409 <xsl:apply-templates mode="root"/>
[96a30c7]410 <xsl:if test="$sudo = 'y'">
[970f2dc]411 <xsl:text>&#xA;ROOT_EOF</xsl:text>
[96a30c7]412 </xsl:if>
413 </xsl:when>
414 <xsl:otherwise>
415 <xsl:apply-templates select="userinput"/>
416 </xsl:otherwise>
417 </xsl:choose>
[3c10176]418 <xsl:text>&#xA;</xsl:text>
419 </xsl:if>
420 </xsl:template>
421
[1061e6bc]422 <xsl:template match="screen" mode="xorg7">
423 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
424 <xsl:apply-templates select="userinput" mode="xorg7"/>
425 <xsl:text>&#xA;</xsl:text>
426 </xsl:if>
427 </xsl:template>
428
[63fc514]429 <xsl:template match="screen" mode="config">
430 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
431 <xsl:text>[[ ! -d $SRC_DIR/blfs-bootscripts ]] &amp;&amp; mkdir $SRC_DIR/blfs-bootscripts
432pushd $SRC_DIR/blfs-bootscripts
433URL=</xsl:text>
434 <xsl:value-of select="id('bootscripts')//itemizedlist//ulink/@url"/><xsl:text>
435BOOTPACKG=$(basename $URL)
436[[ ! -f "$BOOTPACKG" ]] &amp;&amp; { wget -T 30 -t 5 $URL; rm -f unpacked; }
437if [[ -e unpacked ]] ; then
438 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
439 if ! [[ -d $UNPACKDIR ]]; then
440 rm unpacked
441 tar -xvf $BOOTPACKG > unpacked
442 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
443 fi
444else
445 tar -xvf $BOOTPACKG > unpacked
446 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
447fi
448cd $UNPACKDIR
449</xsl:text>
450 </xsl:if>
451 <xsl:apply-templates select='.'/>
452 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
453 <xsl:text>
454popd</xsl:text>
455 </xsl:if>
456 <xsl:text>&#xA;</xsl:text>
457 </xsl:template>
458
[0efb837]459 <xsl:template match="screen" mode="sect-ver">
[a70c289]460 <xsl:text>section=</xsl:text>
461 <xsl:value-of select="substring-before(substring-after(string(),'mkdir '),' &amp;')"/>
[9d9a810]462 <xsl:text>&#xA;sect_ver=</xsl:text>
[0efb837]463 <xsl:value-of select="substring-before(substring-after(string(),'-c ../'),'.md5')"/>
464 <xsl:text>&#xA;</xsl:text>
[b45f723]465 </xsl:template>
466
[3c10176]467 <xsl:template match="para/command">
468 <xsl:if test="(contains(string(),'test') or
469 contains(string(),'check'))">
470 <xsl:text>#</xsl:text>
471 <xsl:value-of select="substring-before(string(),'make')"/>
472 <xsl:text>make -k</xsl:text>
473 <xsl:value-of select="substring-after(string(),'make')"/>
474 <xsl:text> || true&#xA;</xsl:text>
475 </xsl:if>
476 </xsl:template>
477
478 <xsl:template match="userinput">
479 <xsl:apply-templates/>
480 </xsl:template>
481
[1061e6bc]482 <xsl:template match="userinput" mode="xorg7">
483 <xsl:apply-templates mode="xorg7"/>
484 </xsl:template>
485
486 <xsl:template match="text()" mode="xorg7">
487 <xsl:call-template name="output-text">
488 <xsl:with-param name="out-string" select="string()"/>
489 </xsl:call-template>
490 </xsl:template>
491
492 <xsl:template name="output-text">
493 <xsl:param name="out-string" select="''"/>
494 <xsl:choose>
495 <xsl:when test="contains($out-string,'bash -e')">
496 <xsl:call-template name="output-text">
497 <xsl:with-param name="out-string"
498 select="substring-before($out-string,'bash -e')"/>
499 </xsl:call-template>
500 <xsl:text># bash -e</xsl:text>
501 <xsl:call-template name="output-text">
502 <xsl:with-param name="out-string"
503 select="substring-after($out-string,'bash -e')"/>
504 </xsl:call-template>
505 </xsl:when>
506 <xsl:when test="contains($out-string,'exit')">
507 <xsl:call-template name="output-text">
508 <xsl:with-param name="out-string"
509 select="substring-before($out-string,'exit')"/>
510 </xsl:call-template>
511 <xsl:text># exit</xsl:text>
512 <xsl:call-template name="output-text">
513 <xsl:with-param name="out-string"
514 select="substring-after($out-string,'exit')"/>
515 </xsl:call-template>
516 </xsl:when>
517 <xsl:when test="contains($out-string,'mkdir')">
518 <xsl:call-template name="output-text">
519 <xsl:with-param name="out-string"
520 select="substring-before($out-string,'mkdir')"/>
521 </xsl:call-template>
522 <xsl:text>mkdir -p</xsl:text>
523 <xsl:call-template name="output-text">
524 <xsl:with-param name="out-string"
525 select="substring-after($out-string,'mkdir')"/>
526 </xsl:call-template>
527 </xsl:when>
528 <xsl:when test="contains($out-string,'rm -r ')">
529 <xsl:call-template name="output-text">
530 <xsl:with-param name="out-string"
531 select="substring-before($out-string,'rm -r ')"/>
532 </xsl:call-template>
533 <xsl:text>rm -rf </xsl:text>
534 <xsl:call-template name="output-text">
535 <xsl:with-param name="out-string"
536 select="substring-after($out-string,'rm -r ')"/>
537 </xsl:call-template>
538 </xsl:when>
539 <xsl:otherwise>
540 <xsl:value-of select="$out-string"/>
541 </xsl:otherwise>
542 </xsl:choose>
543 </xsl:template>
544
[f53dc4c]545 <xsl:template match="text()" mode="root">
546 <xsl:call-template name="output-root">
547 <xsl:with-param name="out-string" select="string()"/>
548 </xsl:call-template>
[96a30c7]549 </xsl:template>
550
[970f2dc]551 <xsl:template name="output-root">
552 <xsl:param name="out-string" select="''"/>
[5fb652f]553 <xsl:choose>
[970f2dc]554 <xsl:when test="contains($out-string,'make')">
555 <xsl:call-template name="output-root">
556 <xsl:with-param name="out-string"
557 select="substring-before($out-string,'make')"/>
558 </xsl:call-template>
559 <xsl:text>make -j1</xsl:text>
560 <xsl:call-template name="output-root">
561 <xsl:with-param name="out-string"
562 select="substring-after($out-string,'make')"/>
563 </xsl:call-template>
564 </xsl:when>
[f53dc4c]565 <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
566 <xsl:call-template name="output-root">
567 <xsl:with-param name="out-string"
568 select="substring-before($out-string,'$')"/>
569 </xsl:call-template>
570 <xsl:text>\$</xsl:text>
571 <xsl:call-template name="output-root">
572 <xsl:with-param name="out-string"
573 select="substring-after($out-string,'$')"/>
574 </xsl:call-template>
575 </xsl:when>
[cd668b9]576 <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
[970f2dc]577 <xsl:call-template name="output-root">
578 <xsl:with-param name="out-string"
579 select="substring-before($out-string,'`')"/>
580 </xsl:call-template>
581 <xsl:text>\`</xsl:text>
582 <xsl:call-template name="output-root">
583 <xsl:with-param name="out-string"
584 select="substring-after($out-string,'`')"/>
585 </xsl:call-template>
586 </xsl:when>
[cd668b9]587 <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
[970f2dc]588 <xsl:call-template name="output-root">
589 <xsl:with-param name="out-string"
590 select="substring-before($out-string,'\')"/>
591 </xsl:call-template>
592 <xsl:text>\\</xsl:text>
593 <xsl:call-template name="output-root">
594 <xsl:with-param name="out-string"
595 select="substring-after($out-string,'\')"/>
596 </xsl:call-template>
[5fb652f]597 </xsl:when>
[970f2dc]598 <xsl:otherwise>
599 <xsl:value-of select="$out-string"/>
600 </xsl:otherwise>
601 </xsl:choose>
602 </xsl:template>
603
604 <xsl:template match="replaceable">
[5fb652f]605 <xsl:text>**EDITME</xsl:text>
606 <xsl:apply-templates/>
607 <xsl:text>EDITME**</xsl:text>
[3c10176]608 </xsl:template>
609
[f53dc4c]610 <xsl:template match="replaceable" mode="root">
611 <xsl:text>**EDITME</xsl:text>
612 <xsl:apply-templates/>
613 <xsl:text>EDITME**</xsl:text>
614 </xsl:template>
615
[3c10176]616</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.