source: BLFS/xsl/scripts.xsl@ dda2496

ablfs
Last change on this file since dda2496 was 5130b3a, checked in by Pierre Labastie <pierre@…>, 11 years ago

Merge trunk r3750-3760

  • Property mode set to 100644
File size: 23.3 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)
[1991326]436if [[ ! -f $BOOTPACKG ]] ; then
437 if [[ -f $SRC_ARCHIVE/$PKG_DIR/$BOOTPACKG ]] ; then
438 cp $SRC_ARCHIVE/$PKG_DIR/$BOOTPACKG $BOOTPACKG
439 elif [[ -f $SRC_ARCHIVE/$BOOTPACKG ]] ; then
440 cp $SRC_ARCHIVE/$BOOTPACKG $BOOTPACKG
441 else
442 wget -T 30 -t 5 $URL
443 cp $BOOTPACKG $SRC_ARCHIVE
444 fi
445 rm -f unpacked
446fi
447
[63fc514]448if [[ -e unpacked ]] ; then
449 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
450 if ! [[ -d $UNPACKDIR ]]; then
451 rm unpacked
452 tar -xvf $BOOTPACKG > unpacked
453 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
454 fi
455else
456 tar -xvf $BOOTPACKG > unpacked
457 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
458fi
459cd $UNPACKDIR
460</xsl:text>
461 </xsl:if>
462 <xsl:apply-templates select='.'/>
463 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
464 <xsl:text>
465popd</xsl:text>
466 </xsl:if>
467 <xsl:text>&#xA;</xsl:text>
468 </xsl:template>
469
[0efb837]470 <xsl:template match="screen" mode="sect-ver">
[a70c289]471 <xsl:text>section=</xsl:text>
472 <xsl:value-of select="substring-before(substring-after(string(),'mkdir '),' &amp;')"/>
[9d9a810]473 <xsl:text>&#xA;sect_ver=</xsl:text>
[0efb837]474 <xsl:value-of select="substring-before(substring-after(string(),'-c ../'),'.md5')"/>
475 <xsl:text>&#xA;</xsl:text>
[b45f723]476 </xsl:template>
477
[3c10176]478 <xsl:template match="para/command">
479 <xsl:if test="(contains(string(),'test') or
480 contains(string(),'check'))">
481 <xsl:text>#</xsl:text>
[5130b3a]482 <xsl:value-of select="substring-before(string(),'make ')"/>
483 <xsl:text>make </xsl:text>
484 <xsl:if test="not(contains(string(),'-k'))">
485 <xsl:text>-k </xsl:text>
486 </xsl:if>
487 <xsl:value-of select="substring-after(string(),'make ')"/>
[3c10176]488 <xsl:text> || true&#xA;</xsl:text>
489 </xsl:if>
490 </xsl:template>
491
492 <xsl:template match="userinput">
493 <xsl:apply-templates/>
494 </xsl:template>
495
[1061e6bc]496 <xsl:template match="userinput" mode="xorg7">
497 <xsl:apply-templates mode="xorg7"/>
498 </xsl:template>
499
500 <xsl:template match="text()" mode="xorg7">
501 <xsl:call-template name="output-text">
502 <xsl:with-param name="out-string" select="string()"/>
503 </xsl:call-template>
504 </xsl:template>
505
506 <xsl:template name="output-text">
507 <xsl:param name="out-string" select="''"/>
508 <xsl:choose>
509 <xsl:when test="contains($out-string,'bash -e')">
510 <xsl:call-template name="output-text">
511 <xsl:with-param name="out-string"
512 select="substring-before($out-string,'bash -e')"/>
513 </xsl:call-template>
514 <xsl:text># bash -e</xsl:text>
515 <xsl:call-template name="output-text">
516 <xsl:with-param name="out-string"
517 select="substring-after($out-string,'bash -e')"/>
518 </xsl:call-template>
519 </xsl:when>
520 <xsl:when test="contains($out-string,'exit')">
521 <xsl:call-template name="output-text">
522 <xsl:with-param name="out-string"
523 select="substring-before($out-string,'exit')"/>
524 </xsl:call-template>
525 <xsl:text># exit</xsl:text>
526 <xsl:call-template name="output-text">
527 <xsl:with-param name="out-string"
528 select="substring-after($out-string,'exit')"/>
529 </xsl:call-template>
530 </xsl:when>
531 <xsl:when test="contains($out-string,'mkdir')">
532 <xsl:call-template name="output-text">
533 <xsl:with-param name="out-string"
534 select="substring-before($out-string,'mkdir')"/>
535 </xsl:call-template>
536 <xsl:text>mkdir -p</xsl:text>
537 <xsl:call-template name="output-text">
538 <xsl:with-param name="out-string"
539 select="substring-after($out-string,'mkdir')"/>
540 </xsl:call-template>
541 </xsl:when>
542 <xsl:when test="contains($out-string,'rm -r ')">
543 <xsl:call-template name="output-text">
544 <xsl:with-param name="out-string"
545 select="substring-before($out-string,'rm -r ')"/>
546 </xsl:call-template>
547 <xsl:text>rm -rf </xsl:text>
548 <xsl:call-template name="output-text">
549 <xsl:with-param name="out-string"
550 select="substring-after($out-string,'rm -r ')"/>
551 </xsl:call-template>
552 </xsl:when>
553 <xsl:otherwise>
554 <xsl:value-of select="$out-string"/>
555 </xsl:otherwise>
556 </xsl:choose>
557 </xsl:template>
558
[f53dc4c]559 <xsl:template match="text()" mode="root">
560 <xsl:call-template name="output-root">
561 <xsl:with-param name="out-string" select="string()"/>
562 </xsl:call-template>
[96a30c7]563 </xsl:template>
564
[970f2dc]565 <xsl:template name="output-root">
566 <xsl:param name="out-string" select="''"/>
[5fb652f]567 <xsl:choose>
[5130b3a]568 <xsl:when test="contains($out-string,'make ')">
[970f2dc]569 <xsl:call-template name="output-root">
570 <xsl:with-param name="out-string"
[5130b3a]571 select="substring-before($out-string,'make ')"/>
[970f2dc]572 </xsl:call-template>
[5130b3a]573 <xsl:text>make -j1 </xsl:text>
[970f2dc]574 <xsl:call-template name="output-root">
575 <xsl:with-param name="out-string"
[5130b3a]576 select="substring-after($out-string,'make ')"/>
[970f2dc]577 </xsl:call-template>
578 </xsl:when>
[f53dc4c]579 <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
580 <xsl:call-template name="output-root">
581 <xsl:with-param name="out-string"
582 select="substring-before($out-string,'$')"/>
583 </xsl:call-template>
584 <xsl:text>\$</xsl:text>
585 <xsl:call-template name="output-root">
586 <xsl:with-param name="out-string"
587 select="substring-after($out-string,'$')"/>
588 </xsl:call-template>
589 </xsl:when>
[cd668b9]590 <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
[970f2dc]591 <xsl:call-template name="output-root">
592 <xsl:with-param name="out-string"
593 select="substring-before($out-string,'`')"/>
594 </xsl:call-template>
595 <xsl:text>\`</xsl:text>
596 <xsl:call-template name="output-root">
597 <xsl:with-param name="out-string"
598 select="substring-after($out-string,'`')"/>
599 </xsl:call-template>
600 </xsl:when>
[cd668b9]601 <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
[970f2dc]602 <xsl:call-template name="output-root">
603 <xsl:with-param name="out-string"
604 select="substring-before($out-string,'\')"/>
605 </xsl:call-template>
606 <xsl:text>\\</xsl:text>
607 <xsl:call-template name="output-root">
608 <xsl:with-param name="out-string"
609 select="substring-after($out-string,'\')"/>
610 </xsl:call-template>
[5fb652f]611 </xsl:when>
[970f2dc]612 <xsl:otherwise>
613 <xsl:value-of select="$out-string"/>
614 </xsl:otherwise>
615 </xsl:choose>
616 </xsl:template>
617
618 <xsl:template match="replaceable">
[5fb652f]619 <xsl:text>**EDITME</xsl:text>
620 <xsl:apply-templates/>
621 <xsl:text>EDITME**</xsl:text>
[3c10176]622 </xsl:template>
623
[f53dc4c]624 <xsl:template match="replaceable" mode="root">
625 <xsl:text>**EDITME</xsl:text>
626 <xsl:apply-templates/>
627 <xsl:text>EDITME**</xsl:text>
628 </xsl:template>
629
[3c10176]630</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.