source: BLFS/xsl/scripts.xsl@ b81c951

2.4 ablfs-more legacy new_features trunk
Last change on this file since b81c951 was e576789, checked in by Pierre Labastie <pierre@…>, 11 years ago

Merge ablfs branch. Normally, jhalfs should not perform differently
for building LFS

  • Property mode set to 100644
File size: 23.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: scripts.xsl 34 2012-02-21 16:05:09Z labastie $ -->
9
10<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
11
12 <!-- Build as user (y) or as root (n)? -->
13 <xsl:param name="sudo" select="'y'"/>
14
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
23 <xsl:if test="@id != 'bootscripts'">
24 <!-- The file names -->
25 <xsl:variable name="filename" select="@id"/>
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>
48 <xsl:value-of select="concat($order,'-z-',$filename)"/>
49 <xsl:text>&#xA; FTPDIR is </xsl:text>
50 <xsl:value-of select="$filename"/>
51 <xsl:text>&#xA;&#xA;</xsl:text>
52 </xsl:message>
53
54 <!-- Creating the scripts -->
55 <exsl:document href="{$order}-z-{$filename}" method="text">
56 <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
57 <xsl:choose>
58 <!-- Package page -->
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')">
63 <!-- Variables -->
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
68 <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE&#xA;</xsl:text>
69 <xsl:text>FTP_SERVER=$FTP_SERVER&#xA;</xsl:text>
70 <xsl:text>SRC_DIR=$SRC_DIR&#xA;&#xA;</xsl:text>-->
71 <xsl:text>&#xA;PKG_DIR=</xsl:text>
72 <xsl:value-of select="$filename"/>
73 <xsl:text>&#xA;</xsl:text>
74 <!-- Download code and build commands -->
75 <xsl:apply-templates select="sect2"/>
76 <!-- Clean-up -->
77 <!-- xorg7-server used to require mesalib tree being present.
78 That is no more true
79 <xsl:if test="not(@id='mesalib')"> -->
80 <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
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>
86 <xsl:text>rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
87 <!-- Same reason as preceding comment
88 </xsl:if>
89 <xsl:if test="@id='xorg7-server'">
90 <xsl:text>cd $SRC_DIR/MesaLib
91UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
92rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
93 </xsl:if> -->
94 </xsl:when>
95 <!-- Xorg7 pseudo-packages -->
96 <xsl:when test="contains(@id,'xorg7') and not(@id = 'xorg7-server')">
97 <xsl:text># Useless SRC_DIR=$SRC_DIR
98
99cd $SRC_DIR
100mkdir -p xc
101cd xc&#xA;</xsl:text>
102 <xsl:apply-templates select="sect2" mode="xorg7"/>
103 </xsl:when>
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'">
119 <xsl:text>mkdir -p $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
120 <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
121 <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
122 <xsl:text>&#xA;</xsl:text>
123 </xsl:when>
124 <xsl:when test="@role = 'installation'">
125 <xsl:text>
126if [ "${PACKAGE%.zip}" = "${PACKAGE}" ]; then
127 if [[ -e unpacked ]] ; then
128 UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
129 [[ -n $UNPACKDIR ]] &amp;&amp; [[ -d $UNPACKDIR ]] &amp;&amp; rm -rf $UNPACKDIR
130 fi
131 tar -xvf $PACKAGE > unpacked
132 UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
133else
134 UNPACKDIR=${PACKAGE%.zip}
135 [[ -n $UNPACKDIR ]] &amp;&amp; [[ -d $UNPACKDIR ]] &amp;&amp; rm -rf $UNPACKDIR
136 unzip -d $UNPACKDIR ${PACKAGE}
137fi
138cd $UNPACKDIR&#xA;</xsl:text>
139 <xsl:apply-templates select=".//screen | .//para/command"/>
140 <xsl:if test="$sudo = 'y'">
141 <xsl:text>sudo /sbin/</xsl:text>
142 </xsl:if>
143 <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
144 </xsl:when>
145 <xsl:when test="@role = 'configuration'">
146 <xsl:apply-templates select=".//screen" mode="config"/>
147 </xsl:when>
148 </xsl:choose>
149 </xsl:template>
150
151 <xsl:template match="sect2" mode="xorg7">
152 <xsl:choose>
153 <!-- <xsl:when test="@role = 'package'">
154 <xsl:apply-templates select="itemizedlist/listitem/para" mode="xorg7"/>
155 </xsl:when>-->
156 <xsl:when test="not(@role)">
157<!-- This is the packages download instructions> -->
158 <xsl:apply-templates select=".//screen" mode="xorg7"/>
159 </xsl:when>
160 <xsl:when test="@role = 'installation'">
161 <xsl:apply-templates select=".//screen" mode="xorg7"/>
162 <xsl:if test="$sudo = 'y'">
163 <xsl:text>sudo /sbin/</xsl:text>
164 </xsl:if>
165 <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
166 </xsl:when>
167 <xsl:when test="@role = 'configuration'">
168 <xsl:text>if [[ $XORG_PREFIX != /usr ]] ; then&#xA;</xsl:text>
169 <xsl:apply-templates select=".//screen"/>
170 <xsl:text>fi&#xA;</xsl:text>
171 </xsl:when>
172 </xsl:choose>
173 </xsl:template>
174
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
199 <xsl:template match="bridgehead">
200 <xsl:choose>
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>
216 </xsl:variable>
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>
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 -->
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>
243 <xsl:when test="contains(string(),'Additional')">
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')">
255 <!-- Upstream HTTP URL -->
256 <xsl:if test="string-length(ulink/@url) &gt; '10'">
257 <xsl:text> || \&#xA; wget -T 30 -t 5 </xsl:text>
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>
266 <xsl:if test="not(contains(string(parent::listitem/following-sibling::listitem[1]/para),'FTP'))">
267 <xsl:text>
268 cp $PACKAGE $SRC_ARCHIVE
269 fi
270fi
271</xsl:text>
272 </xsl:if>
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'">
278 <xsl:text> || \&#xA; wget -T 30 -t 5 </xsl:text>
279 <xsl:value-of select="ulink/@url"/>
280 </xsl:if>
281 <xsl:text>
282 cp $PACKAGE $SRC_ARCHIVE
283 fi
284fi
285</xsl:text>
286 </xsl:when>
287 <xsl:when test="contains(string(),'MD5')">
288<!-- some md5 sums are written with a LF -->
289 <xsl:variable name="md5">
290 <xsl:choose>
291 <xsl:when test="contains(substring-after(string(),'sum: '),'&#xA;')">
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>
299 <xsl:text>echo "</xsl:text>
300 <xsl:value-of select="$md5"/>
301 <xsl:text>&#x20;&#x20;$PACKAGE" | md5sum -c -&#xA;</xsl:text>
302 </xsl:when>
303 </xsl:choose>
304 </xsl:template>
305
306 <xsl:template match="para" mode="additional">
307 <xsl:choose>
308 <xsl:when test="contains(string(ulink/@url),'.patch')">
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>
322 <xsl:text>wget -T 30 -t 5 </xsl:text>
323 <xsl:value-of select="ulink/@url"/>
324 <xsl:text>&#xA;</xsl:text>
325 <xsl:text>
326 cp $PATCH $SRC_ARCHIVE
327 fi
328fi
329</xsl:text>
330 </xsl:when>
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 -->
352 <xsl:text> wget -T 30 -t 5 ${FTP_SERVER}svn/</xsl:text>
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"/>
357 <xsl:text>
358 cp $PACKAGE1 $SRC_ARCHIVE
359 fi
360fi
361</xsl:text>
362 </xsl:if>
363 </xsl:when>
364 <xsl:when test="contains(string(),'MD5')">
365<!-- some md5 sums are written with a LF -->
366 <xsl:variable name="md5">
367 <xsl:choose>
368 <xsl:when test="contains(substring-after(string(),'sum: '),'&#xA;')">
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>
376 <xsl:text>echo "</xsl:text>
377 <xsl:value-of select="$md5"/>
378 <xsl:text>&#x20;&#x20;$PACKAGE1" | md5sum -c -&#xA;</xsl:text>
379 </xsl:when>
380 </xsl:choose>
381 </xsl:template>
382
383 <xsl:template match="itemizedlist/listitem/para" mode="xorg7">
384 <xsl:if test="contains(string(ulink/@url),'.md5') or
385 contains(string(ulink/@url),'.wget')">
386 <xsl:text>wget -T 30 -t 5 </xsl:text>
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">
393 <xsl:if test="contains(string(ulink/@url),'.patch')">
394 <xsl:text>wget -T 30 -t 5 </xsl:text>
395 <xsl:value-of select="ulink/@url"/>
396 <xsl:text>&#xA;</xsl:text>
397 </xsl:if>
398 </xsl:template>
399
400<!--======================== Commands code ==========================-->
401
402 <xsl:template match="screen">
403 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
404 <xsl:choose>
405 <xsl:when test="@role = 'root'">
406 <xsl:if test="$sudo = 'y'">
407 <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
408 </xsl:if>
409 <xsl:apply-templates mode="root"/>
410 <xsl:if test="$sudo = 'y'">
411 <xsl:text>&#xA;ROOT_EOF</xsl:text>
412 </xsl:if>
413 </xsl:when>
414 <xsl:otherwise>
415 <xsl:apply-templates select="userinput"/>
416 </xsl:otherwise>
417 </xsl:choose>
418 <xsl:text>&#xA;</xsl:text>
419 </xsl:if>
420 </xsl:template>
421
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
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
459 <xsl:template match="screen" mode="sect-ver">
460 <xsl:text>section=</xsl:text>
461 <xsl:value-of select="substring-before(substring-after(string(),'mkdir '),' &amp;')"/>
462 <xsl:text>&#xA;sect_ver=</xsl:text>
463 <xsl:value-of select="substring-before(substring-after(string(),'-c ../'),'.md5')"/>
464 <xsl:text>&#xA;</xsl:text>
465 </xsl:template>
466
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
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
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>
549 </xsl:template>
550
551 <xsl:template name="output-root">
552 <xsl:param name="out-string" select="''"/>
553 <xsl:choose>
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>
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>
576 <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
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>
587 <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
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>
597 </xsl:when>
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">
605 <xsl:text>**EDITME</xsl:text>
606 <xsl:apply-templates/>
607 <xsl:text>EDITME**</xsl:text>
608 </xsl:template>
609
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
616</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.