source: BLFS/xsl/scripts.xsl@ 3439ff6

ablfs-more trunk
Last change on this file since 3439ff6 was a6c57de, checked in by Pierre Labastie <pierre.labastie@…>, 14 months ago

Process <prompt> tags in mit-kerberos

when we have a command followed by prompts:
command
<prompt>command:</prompt> instr
...
we want to transform to:
command << PROMPT_EOF
instr
...
quit
PROMPT_EOF.
This patch implements this. The problem is that the <prompt>
tags may occur in several consecutive <screen> ones. So we create
a fragment tree and process it recursively.

  • Property mode set to 100644
File size: 40.2 KB
RevLine 
[e576789]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 "linear build" BLFS books. -->
9
[c048987]10<!-- parameters and global variables -->
11 <!-- Check whether the book is sysv or systemd -->
[70d73d1]12 <xsl:variable name="rev">
13 <xsl:choose>
14 <xsl:when test="//bookinfo/title/phrase[@revision='systemd']">
15 systemd
16 </xsl:when>
17 <xsl:otherwise>
18 sysv
19 </xsl:otherwise>
20 </xsl:choose>
21 </xsl:variable>
22
[945ccaa]23 <!-- Wrap "root" commands inside a wrapper function, allowing
24 "porg style" package management -->
25 <xsl:param name="wrap-install" select="'n'"/>
[9daa202]26 <xsl:param name="pack-install" select="'$HOME/blfs_root/packInstall.sh'"/>
[945ccaa]27
[67c3df4]28 <!-- list of packages needing stats -->
29 <xsl:param name="list-stat" select="''"/>
30
[dc7fd7b]31 <!-- Remove libtool .la files -->
32 <xsl:param name="del-la-files" select="'y'"/>
33
[e576789]34 <!-- Build as user (y) or as root (n)? -->
35 <xsl:param name="sudo" select="'y'"/>
36
[9daa202]37 <!-- Root of sources directory -->
38 <xsl:param name="src-archive" select="'/sources'"/>
39
40 <!-- Download and archive tarballs to subdirs. Can be 'y' or '',
41 not 'n' -->
42 <xsl:param name="src-subdirs" select="''"/>
43
44 <!-- Root of build directory -->
45 <xsl:param name="build-root" select="'/sources'"/>
46
47 <!-- extract sources and build into subdirs. Can be 'y' or '',
48 not 'n' -->
49 <xsl:param name="build-subdirs" select="''"/>
50
51 <!-- Keep files in the build directory after building. Can be 'y' or '',
52 not 'n' -->
53 <xsl:param name="keep-files" select="''"/>
54
55 <!-- Number of parallel jobs; type integer, not string -->
56 <xsl:param name="jobs" select="0"/>
[dc7fd7b]57<!-- simple instructions for removing .la files. -->
[619b313]58<!-- We'll use the rule that any text output begins with a linefeed if needed
59 so that we do not need to output one at the end-->
[dc7fd7b]60 <xsl:variable name="la-files-instr">
61
62for libdir in /lib /usr/lib $(find /opt -name lib); do
[2969cdf]63 find $libdir -name \*.la \
64 ! -path \*ImageMagick\* \
65 -delete
[619b313]66done</xsl:variable>
[67c3df4]67
[c048987]68 <xsl:variable name="list-stat-norm"
69 select="concat(' ', normalize-space($list-stat),' ')"/>
70
71<!-- To be able to use the single quote in tests -->
72 <xsl:variable name="APOS">'</xsl:variable>
73
74<!-- end parameters and global variables -->
75
[7933ed7]76<!-- include the template for processing screen children of
77 role="install" sect2 -->
78 <xsl:include href="process-install.xsl"/>
[c048987]79
[96d7e44]80<!-- include the template for replaceable tags -->
81 <xsl:include href="process-replaceable.xsl"/>
82
[a6c57de]83<!-- include the template for prompt tags -->
84 <xsl:include href="process-prompt.xsl"/>
85
[c048987]86<!--=================== Begin processing ========================-->
[67c3df4]87
[e576789]88 <xsl:template match="/">
[c048987]89 <xsl:apply-templates select="//sect1[@id != 'bootscripts' and
90 @id != 'systemd-units']"/>
[e576789]91 </xsl:template>
92
93<!--=================== Master chunks code ======================-->
94
95 <xsl:template match="sect1">
96
[619b313]97 <!-- Are stat requested for this page? -->
98 <xsl:variable name="want-stats"
99 select="contains($list-stat-norm,
100 concat(' ',@id,' '))"/>
101
[c048987]102 <!-- The file names -->
103 <xsl:variable name="filename" select="@id"/>
[e576789]104
[c048987]105 <!-- The build order -->
106 <xsl:variable name="position" select="position()"/>
107 <xsl:variable name="order">
108 <xsl:choose>
109 <xsl:when test="string-length($position) = 1">
110 <xsl:text>00</xsl:text>
111 <xsl:value-of select="$position"/>
112 </xsl:when>
113 <xsl:when test="string-length($position) = 2">
114 <xsl:text>0</xsl:text>
115 <xsl:value-of select="$position"/>
116 </xsl:when>
117 <xsl:otherwise>
118 <xsl:value-of select="$position"/>
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:variable>
[e576789]122
123 <!-- Depuration code -->
[c048987]124 <xsl:message>
125 <xsl:text>SCRIPT is </xsl:text>
126 <xsl:value-of select="concat($order,'-z-',$filename)"/>
127 <xsl:text>&#xA; FTPDIR is </xsl:text>
128 <xsl:value-of select="$filename"/>
129 <xsl:text>&#xA;&#xA;</xsl:text>
130 </xsl:message>
131
132 <!-- Creating the scripts -->
133 <exsl:document href="{$order}-z-{$filename}" method="text">
134 <xsl:text>#!/bin/bash
[eabfc59]135set -e
[9daa202]136# Variables coming from configuration
137export JH_PACK_INSTALL="</xsl:text>
138 <xsl:copy-of select="$pack-install"/>
139 <xsl:text>"
140export JH_SRC_ARCHIVE="</xsl:text>
141 <xsl:copy-of select="$src-archive"/>
142 <xsl:text>"
143export JH_SRC_SUBDIRS="</xsl:text>
144 <xsl:copy-of select="$src-subdirs"/>
145 <xsl:text>"
146export JH_BUILD_ROOT="</xsl:text>
147 <xsl:copy-of select="$build-root"/>
148 <xsl:text>"
149export JH_BUILD_SUBDIRS="</xsl:text>
150 <xsl:copy-of select="$build-subdirs"/>
151 <xsl:text>"
152export JH_KEEP_FILES="</xsl:text>
153 <xsl:copy-of select="$keep-files"/>
154 <xsl:text>"
155</xsl:text>
156 <xsl:choose>
157 <xsl:when test="$cfg-cflags = 'EMPTY'">
158 <xsl:text>unset CFLAGS
159</xsl:text>
160 </xsl:when>
161 <xsl:otherwise>
162 <xsl:text>export CFLAGS="</xsl:text>
163 <xsl:copy-of select="$cfg-cflags"/>
164 <xsl:text>"
165</xsl:text>
166 </xsl:otherwise>
167 </xsl:choose>
168 <xsl:choose>
169 <xsl:when test="$cfg-cxxflags = 'EMPTY'">
170 <xsl:text>unset CXXFLAGS
171</xsl:text>
172 </xsl:when>
173 <xsl:otherwise>
174 <xsl:text>export CXXFLAGS="</xsl:text>
175 <xsl:copy-of select="$cfg-cxxflags"/>
176 <xsl:text>"
177</xsl:text>
178 </xsl:otherwise>
179 </xsl:choose>
180 <xsl:choose>
181 <xsl:when test="$cfg-ldflags = 'EMPTY'">
182 <xsl:text>unset LDFLAGS
[eabfc59]183</xsl:text>
[9daa202]184 </xsl:when>
185 <xsl:otherwise>
186 <xsl:text>export LDFLAGS="</xsl:text>
187 <xsl:copy-of select="$cfg-ldflags"/>
188 <xsl:text>"
189</xsl:text>
190 </xsl:otherwise>
191 </xsl:choose>
192<!-- We use MAKEFLAGS and NINJAJOBS for setting the number of
193 parallel jobs. This supposes that ninja has been build with
194 support for NINJAJOBS in lfs. We'll have to change that code
195 if lfs changes its policy for ninja. -->
196 <xsl:text>export MAKEFLAGS="-j</xsl:text>
197 <xsl:choose>
198 <xsl:when test="$jobs = 0">
199 <xsl:text>$(nproc)"
200</xsl:text>
201 </xsl:when>
202 <xsl:otherwise>
203 <xsl:value-of select="$jobs"/>
204 <xsl:text>"
205</xsl:text>
206 </xsl:otherwise>
207 </xsl:choose>
208 <xsl:choose>
209 <xsl:when test="$jobs = 0">
210 <xsl:text>unset NINJAJOBS
211</xsl:text>
212 </xsl:when>
213 <xsl:otherwise>
214 <xsl:text>export NINJAJOBS="</xsl:text>
215 <xsl:value-of select="$jobs"/>
216 <xsl:text>"
217</xsl:text>
218 </xsl:otherwise>
219 </xsl:choose>
[8fc6a47]220<!-- Unsetting MAKELEVEL is needed for some packages which assume that
[1870b56]221 their top level Makefile is at level zero.
222 Some packages (cmake) use MAKE_TERMOUT and MAKE_TERMERR to determine
223 whether they are talking to a terminal.
224 In our case, stdout/stderr are always redirected, so unset them.-->
[9daa202]225 <xsl:text>unset MAKELEVEL
[1870b56]226unset MAKE_TERMOUT
227unset MAKE_TERMERR
[b0965fa]228<!-- When installing several packages, and profile or profile.d
229 has been modified by a previous package, we need to ensure that
230 the updated profile is used.
231-->if [ -r /etc/profile ]; then source /etc/profile; fi
[9daa202]232# End of environment</xsl:text>
233
[c048987]234 <xsl:choose>
235 <!-- Package page -->
236 <xsl:when test="sect2[@role='package']">
237 <!-- We build in a subdirectory, whose name may be needed
[9daa202]238 if using package management, so
[c048987]239 "export" it -->
[619b313]240 <xsl:text>
241export JH_PKG_DIR=</xsl:text>
[c048987]242 <xsl:value-of select="$filename"/>
243 <xsl:text>
[1fa0dee]244SRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${JH_PKG_DIR}}
245BUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${JH_PKG_DIR}}
[39dc04a]246mkdir -p $SRC_DIR
247mkdir -p $BUILD_DIR
248</xsl:text>
[67c3df4]249
[9daa202]250<!-- If stats are requested, include some definitions and initializations -->
[619b313]251 <xsl:if test="$want-stats">
252 <xsl:text>
253INFOLOG=$(pwd)/info-${JH_PKG_DIR}
[9e0c4b6]254TESTLOG=$(pwd)/test-${JH_PKG_DIR}
[9daa202]255echo MAKEFLAGS: $MAKEFLAGS > $INFOLOG
256echo NINJAJOBS: $NINJAJOBS >> $INFOLOG
[c048987]257: > $TESTLOG
[67c3df4]258PKG_DEST=${BUILD_DIR}/dest
259</xsl:text>
[9daa202]260<!-- in some cases, DESTDIR may have been populated by root -->
261 <xsl:if test="$sudo = 'y'">
262 <xsl:text>sudo </xsl:text>
263 </xsl:if>
264 <xsl:text>rm -rf $PKG_DEST
265</xsl:text>
266 </xsl:if><!-- want-stats -->
[c048987]267 <!-- Download code and build commands -->
[619b313]268 <xsl:apply-templates select="sect2">
269 <xsl:with-param name="want-stats" select="$want-stats"/>
270 </xsl:apply-templates>
[c048987]271 <!-- Clean-up -->
[619b313]272 <xsl:text>
273
274cd $BUILD_DIR
[1fa0dee]275[[ -n "$JH_KEEP_FILES" ]] || </xsl:text>
[c048987]276 <!-- In some case, some files in the build tree are owned
277 by root -->
278 <xsl:if test="$sudo='y'">
279 <xsl:text>sudo </xsl:text>
280 </xsl:if>
[619b313]281 <xsl:text>rm -rf $JH_UNPACKDIR unpacked
282</xsl:text>
[c048987]283 </xsl:when>
284 <!-- Non-package page -->
285 <xsl:otherwise>
286 <xsl:apply-templates select=".//screen" mode="not-pack"/>
287 </xsl:otherwise>
288 </xsl:choose>
[619b313]289 <xsl:text>
290exit
291</xsl:text><!-- include a \n at the end of document-->
[c048987]292 </exsl:document>
[e576789]293 </xsl:template>
294
295<!--======================= Sub-sections code =======================-->
296
297 <xsl:template match="sect2">
[619b313]298 <xsl:param name="want-stats" select="false"/>
[e576789]299 <xsl:choose>
[c048987]300
[e576789]301 <xsl:when test="@role = 'package'">
[619b313]302 <xsl:text>
303cd $SRC_DIR</xsl:text>
[642722f]304 <!-- Download information is in bridgehead tags -->
[e576789]305 <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
[c048987]306 </xsl:when><!-- @role="package" -->
307
[967b819]308 <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
[625cb14]309 <xsl:apply-templates select=".//screen[./userinput]"/>
[967b819]310 </xsl:when>
[c048987]311
[0a0b609]312 <xsl:when test="@role = 'installation' and
313 not(preceding-sibling::sect2[@role = 'installation'])">
[e576789]314 <xsl:text>
[39dc04a]315cd $BUILD_DIR
[07f7eff]316find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
317 <xsl:if test="$sudo='y'">
318 <xsl:text>sudo </xsl:text>
319 </xsl:if>
320 <xsl:text>rm -rf
[67c3df4]321</xsl:text>
[619b313]322 <!-- If stats are requested, insert the start size -->
323 <xsl:if test="$want-stats">
324 <xsl:text>
[59c4761]325echo Start Size: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
[67c3df4]326</xsl:text>
327 </xsl:if>
328
[619b313]329 <xsl:text>
330case $PACKAGE in
[e6967a1]331 *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
[39dc04a]332 tar -xvf $SRC_DIR/$PACKAGE &gt; unpacked
[1fa0dee]333 JH_UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^\./@@;s@/.*@@'`
[6eaae5e]334 ;;
335 *.tar.lz)
[39dc04a]336 bsdtar -xvf $SRC_DIR/$PACKAGE 2&gt; unpacked
[1fa0dee]337 JH_UNPACKDIR=`head -n1 unpacked | cut -d" " -f2 | sed 's@^\./@@;s@/.*@@'`
[67992a0]338 ;;
339 *.zip)
[39dc04a]340 zipinfo -1 $SRC_DIR/$PACKAGE &gt; unpacked
[1fa0dee]341 JH_UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
342 if test $(wc -w &lt;&lt;&lt; $JH_UNPACKDIR) -eq 1; then
[39dc04a]343 unzip $SRC_DIR/$PACKAGE
[67992a0]344 else
[1fa0dee]345 JH_UNPACKDIR=${PACKAGE%.zip}
346 unzip -d $JH_UNPACKDIR $SRC_DIR/$PACKAGE
[67992a0]347 fi
348 ;;
349 *)
[1fa0dee]350 JH_UNPACKDIR=$JH_PKG_DIR-build
351 mkdir $JH_UNPACKDIR
352 cp $SRC_DIR/$PACKAGE $JH_UNPACKDIR
[619b313]353 ADDITIONAL="$(find . -mindepth 1 -maxdepth 1 -type l)"
354 if [ -n "$ADDITIONAL" ]; then
355 cp $ADDITIONAL $JH_UNPACKDIR
356 fi
[67992a0]357 ;;
358esac
[1fa0dee]359export JH_UNPACKDIR
[619b313]360cd $JH_UNPACKDIR
[67992a0]361</xsl:text>
[619b313]362 <!-- If stats are requested, insert the start time -->
363 <xsl:if test="$want-stats">
364 <xsl:text>
365echo Start Time: ${SECONDS} >> $INFOLOG
[67c3df4]366</xsl:text>
367 </xsl:if>
368
[7933ed7]369 <xsl:call-template name="process-install">
370 <xsl:with-param
371 name="instruction-tree"
[625cb14]372 select=".//screen[not(@role = 'nodump') and ./userinput] |
[c048987]373 .//para/command[contains(text(),'check') or
[7933ed7]374 contains(text(),'test')]"/>
[619b313]375 <xsl:with-param name="want-stats" select="$want-stats"/>
[7933ed7]376 <xsl:with-param name="root-seen" select="boolean(0)"/>
377 <xsl:with-param name="install-seen" select="boolean(0)"/>
378 <xsl:with-param name="test-seen" select="boolean(0)"/>
379 <xsl:with-param name="doc-seen" select="boolean(0)"/>
380 </xsl:call-template>
[619b313]381 <xsl:text>
382</xsl:text>
[e576789]383 <xsl:if test="$sudo = 'y'">
384 <xsl:text>sudo /sbin/</xsl:text>
385 </xsl:if>
[619b313]386 <xsl:text>ldconfig</xsl:text>
[c048987]387 </xsl:when><!-- @role="installation" -->
388
[e576789]389 <xsl:when test="@role = 'configuration'">
[619b313]390 <xsl:text>&#xA;</xsl:text>
[a6c57de]391 <xsl:choose>
392 <xsl:when test=".//screen/userinput/prompt">
393 <xsl:call-template name="process-prompt">
394 <xsl:with-param
395 name="instructions"
396 select=".//screen[not(@role = 'nodump') and ./userinput]"/>
397 <xsl:with-param name="root-seen" select="false"/>
398 <xsl:with-param name="prompt-seen" select="false"/>
399 </xsl:call-template>
400 </xsl:when>
401 <xsl:otherwise>
402 <xsl:apply-templates mode="config"
403 select=".//screen[not(@role = 'nodump') and ./userinput]"/>
404 </xsl:otherwise>
405 </xsl:choose>
[c048987]406 </xsl:when><!-- @role="configuration" -->
407
[e576789]408 </xsl:choose>
409 </xsl:template>
410
411<!--==================== Download code =======================-->
412
[642722f]413 <!-- template for extracting the filename from an url in the form:
414 proto://internet.name/dir1/.../dirn/filename?condition.
415 Needed, because substring-after(...,'/') returns only the
416 substring after the first '/'. -->
[e576789]417 <xsl:template name="package_name">
418 <xsl:param name="url" select="foo"/>
419 <xsl:param name="sub-url" select="substring-after($url,'/')"/>
420 <xsl:choose>
421 <xsl:when test="contains($sub-url,'/')">
422 <xsl:call-template name="package_name">
423 <xsl:with-param name="url" select="$sub-url"/>
424 </xsl:call-template>
425 </xsl:when>
426 <xsl:otherwise>
427 <xsl:choose>
428 <xsl:when test="contains($sub-url,'?')">
429 <xsl:value-of select="substring-before($sub-url,'?')"/>
430 </xsl:when>
431 <xsl:otherwise>
432 <xsl:value-of select="$sub-url"/>
433 </xsl:otherwise>
434 </xsl:choose>
435 </xsl:otherwise>
436 </xsl:choose>
437 </xsl:template>
438
[642722f]439 <!-- Generates the code to download a package, an additional package or
440 a patch. -->
441 <xsl:template name="download-file">
442 <xsl:param name="httpurl" select="''"/>
443 <xsl:param name="ftpurl" select="''"/>
444 <xsl:param name="md5" select="''"/>
445 <xsl:param name="varname" select="''"/>
446 <xsl:variable name="package">
447 <xsl:call-template name="package_name">
448 <xsl:with-param name="url">
[e576789]449 <xsl:choose>
[642722f]450 <xsl:when test="string-length($httpurl) &gt; 10">
451 <xsl:value-of select="$httpurl"/>
[e576789]452 </xsl:when>
453 <xsl:otherwise>
[642722f]454 <xsl:value-of select="$ftpurl"/>
[e576789]455 </xsl:otherwise>
456 </xsl:choose>
[642722f]457 </xsl:with-param>
458 </xsl:call-template>
459 </xsl:variable>
460 <xsl:variable name="first_letter"
461 select="translate(substring($package,1,1),
462 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
463 'abcdefghijklmnopqrstuvwxyz')"/>
464 <xsl:text>&#xA;</xsl:text>
465 <xsl:value-of select="$varname"/>
466 <xsl:text>=</xsl:text>
467 <xsl:value-of select="$package"/>
468 <xsl:text>&#xA;if [[ ! -f $</xsl:text>
469 <xsl:value-of select="$varname"/>
[8dc4646]470 <xsl:text> ]] ; then
[9daa202]471 if [ -f "$JH_SRC_ARCHIVE/$</xsl:text>
[642722f]472 <xsl:value-of select="$varname"/>
[9daa202]473 <xsl:text>" ] ; then&#xA;</xsl:text>
474 <xsl:text> cp "$JH_SRC_ARCHIVE/$</xsl:text>
[642722f]475 <xsl:value-of select="$varname"/>
[9daa202]476 <xsl:text>" "$</xsl:text>
[642722f]477 <xsl:value-of select="$varname"/>
[9daa202]478 <xsl:text>"
[8dc4646]479 else&#xA;</xsl:text>
[342c862]480 <!-- Download from upstream http -->
[642722f]481 <xsl:if test="string-length($httpurl) &gt; 10">
[9daa202]482 <xsl:text> wget -T 30 -t 5 "</xsl:text>
[642722f]483 <xsl:value-of select="$httpurl"/>
[9daa202]484 <xsl:text>" ||&#xA;</xsl:text>
[642722f]485 </xsl:if>
[342c862]486 <!-- Download from upstream ftp -->
[642722f]487 <xsl:if test="string-length($ftpurl) &gt; 10">
[9daa202]488 <xsl:text> wget -T 30 -t 5 "</xsl:text>
[642722f]489 <xsl:value-of select="$ftpurl"/>
[9daa202]490 <xsl:text>" ||&#xA;</xsl:text>
[642722f]491 </xsl:if>
[342c862]492 <!-- The FTP_SERVER mirror as a last resort -->
[9daa202]493 <xsl:text> wget -T 30 -t 5 "${JH_FTP_SERVER}svn/</xsl:text>
[342c862]494 <xsl:value-of select="$first_letter"/>
495 <xsl:text>/$</xsl:text>
496 <xsl:value-of select="$varname"/>
[9daa202]497 <xsl:text>"
[8dc4646]498 fi
[619b313]499fi</xsl:text>
[642722f]500 <xsl:if test="string-length($md5) &gt; 10">
[619b313]501 <xsl:text>
502echo "</xsl:text>
[642722f]503 <xsl:value-of select="$md5"/>
504 <xsl:text>&#x20;&#x20;$</xsl:text>
505 <xsl:value-of select="$varname"/>
[619b313]506 <xsl:text>" | md5sum -c -</xsl:text>
[39dc04a]507 </xsl:if>
508<!-- link additional packages into $BUILD_DIR, because they are supposed to
509 be there-->
510 <xsl:if test="string($varname) != 'PACKAGE'">
[619b313]511 <xsl:text>
[9daa202]512[ "$SRC_DIR" != "$BUILD_DIR" ] &amp;&amp; ln -sf "$SRC_DIR/$</xsl:text>
[39dc04a]513 <xsl:value-of select="$varname"/>
[9daa202]514 <xsl:text>" "$BUILD_DIR"</xsl:text>
[642722f]515 </xsl:if>
[619b313]516 <xsl:text>&#xA;</xsl:text>
[642722f]517 </xsl:template>
518
519 <!-- Extract the MD5 sum information -->
520 <xsl:template match="para" mode="md5">
521 <xsl:choose>
522 <xsl:when test="contains(substring-after(string(),'sum: '),'&#xA;')">
523 <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'&#xA;')"/>
[e576789]524 </xsl:when>
[642722f]525 <xsl:otherwise>
526 <xsl:value-of select="substring-after(string(),'sum: ')"/>
527 </xsl:otherwise>
[e576789]528 </xsl:choose>
529 </xsl:template>
530
[642722f]531 <!-- We have several templates itemizedlist, depending on whether we
532 expect the package information, or additional package(s) or patch(es)
533 information. Select the appropriate mode here. -->
534 <xsl:template match="bridgehead">
[e576789]535 <xsl:choose>
[642722f]536 <!-- Special case for Openjdk -->
537 <xsl:when test="contains(string(),'Source Package Information')">
538 <xsl:apply-templates
539 select="following-sibling::itemizedlist[1]//simplelist">
540 <xsl:with-param name="varname" select="'PACKAGE'"/>
541 </xsl:apply-templates>
542 <xsl:apply-templates select="following-sibling::itemizedlist
543 [preceding-sibling::bridgehead[1]=current()
544 and position() &gt;1]//simplelist">
545 <xsl:with-param name="varname" select="'PACKAGE1'"/>
546 </xsl:apply-templates>
[e576789]547 </xsl:when>
[642722f]548 <!-- Package information -->
549 <xsl:when test="contains(string(),'Package Information')">
550 <xsl:apply-templates select="following-sibling::itemizedlist
551 [preceding-sibling::bridgehead[1]=current()]"
552 mode="package"/>
[e576789]553 </xsl:when>
[642722f]554 <!-- Additional package information -->
[2873df6]555 <!-- special cases for llvm -->
[bfc99d1]556 <xsl:when test="contains(string(),'Recommended Download')">
[0f4df7c]557 <xsl:apply-templates select="following-sibling::itemizedlist
558 [preceding-sibling::bridgehead[1]=current()]"
[2873df6]559 mode="additional"/>
560 </xsl:when>
[ba57e61]561 <xsl:when test="contains(string(),'Optional Download')">
[0f4df7c]562 <xsl:apply-templates select="following-sibling::itemizedlist
563 [preceding-sibling::bridgehead[1]=current()]"
[ba57e61]564 mode="additional"/>
565 </xsl:when>
566 <!-- All other additional packages have "Additional" -->
[642722f]567 <xsl:when test="contains(string(),'Additional')">
[0f4df7c]568 <xsl:apply-templates select="following-sibling::itemizedlist
569 [preceding-sibling::bridgehead[1]=current()]"
[642722f]570 mode="additional"/>
[e576789]571 </xsl:when>
[642722f]572 <!-- Do not do anything if the dev has created another type of
573 bridgehead. -->
574 <xsl:otherwise/>
[e576789]575 </xsl:choose>
576 </xsl:template>
577
[642722f]578 <!-- Call the download code template with appropriate parameters -->
579 <xsl:template match="itemizedlist" mode="package">
580 <xsl:call-template name="download-file">
581 <xsl:with-param name="httpurl">
582 <xsl:value-of select="./listitem[1]/para/ulink/@url"/>
583 </xsl:with-param>
584 <xsl:with-param name="ftpurl">
585 <xsl:value-of select="./listitem/para[contains(string(),'FTP')]/ulink/@url"/>
586 </xsl:with-param>
587 <xsl:with-param name="md5">
588 <xsl:apply-templates select="./listitem/para[contains(string(),'MD5')]"
589 mode="md5"/>
590 </xsl:with-param>
591 <xsl:with-param name="varname" select="'PACKAGE'"/>
592 </xsl:call-template>
[e576789]593 </xsl:template>
594
[642722f]595 <xsl:template match="itemizedlist" mode="additional">
596 <!-- The normal layout is "one listitem"<->"one url", but some devs
597 find amusing to have FTP and/or MD5sum listitems, or to
598 enclose the download information inside a simplelist tag... -->
599 <xsl:for-each select="listitem[.//ulink]">
600 <xsl:choose>
601 <!-- hopefully, there was a HTTP line before -->
602 <xsl:when test="contains(string(./para),'FTP')"/>
603 <xsl:when test=".//simplelist">
604 <xsl:apply-templates select=".//simplelist">
605 <xsl:with-param name="varname" select="'PACKAGE1'"/>
606 </xsl:apply-templates>
607 </xsl:when>
608 <xsl:otherwise>
609 <xsl:call-template name="download-file">
610 <xsl:with-param name="httpurl">
611 <xsl:value-of select="./para/ulink/@url"/>
612 </xsl:with-param>
613 <xsl:with-param name="ftpurl">
614 <xsl:value-of
615 select="following-sibling::listitem[1]/
616 para[contains(string(),'FTP')]/ulink/@url"/>
617 </xsl:with-param>
618 <xsl:with-param name="md5">
619 <xsl:apply-templates
620 select="following-sibling::listitem[position()&lt;3]/
621 para[contains(string(),'MD5')]"
622 mode="md5"/>
623 </xsl:with-param>
624 <xsl:with-param name="varname">
625 <xsl:choose>
626 <xsl:when test="contains(./para/ulink/@url,'.patch')">
627 <xsl:text>PATCH</xsl:text>
628 </xsl:when>
629 <xsl:otherwise>
630 <xsl:text>PACKAGE1</xsl:text>
631 </xsl:otherwise>
632 </xsl:choose>
633 </xsl:with-param>
634 </xsl:call-template>
635 </xsl:otherwise>
636 </xsl:choose>
637 </xsl:for-each>
[e576789]638 </xsl:template>
639
[642722f]640 <!-- the simplelist case. Hopefully, the layout is one member for
641 url, one for md5 and others for various information, that we do not
642 use -->
643 <xsl:template match="simplelist">
644 <xsl:param name="varname" select="'PACKAGE1'"/>
645 <xsl:call-template name="download-file">
646 <xsl:with-param name="httpurl" select=".//ulink/@url"/>
647 <xsl:with-param name="md5">
648 <xsl:value-of select="substring-after(member[contains(string(),'MD5')],'sum: ')"/>
649 </xsl:with-param>
650 <xsl:with-param name="varname" select="$varname"/>
651 </xsl:call-template>
652 </xsl:template>
[625cb14]653
654<!--====================== Non package code =========================-->
655
656 <xsl:template match="screen" mode="not-pack">
657 <xsl:choose>
[6622409]658 <xsl:when test="@role='nodump'"/>
[625cb14]659 <xsl:when test="ancestor::sect1[@id='postlfs-config-vimrc']">
660 <xsl:text>
661cat > ~/.vimrc &lt;&lt;EOF
662</xsl:text>
663 <xsl:apply-templates/>
664 <xsl:text>
665EOF
666</xsl:text>
667 </xsl:when>
668 <xsl:otherwise>
669 <xsl:apply-templates select="." mode="config"/>
670 </xsl:otherwise>
671 </xsl:choose>
672 </xsl:template>
[e576789]673<!--======================== Commands code ==========================-->
[c048987]674<!-- Code for installation instructions is in gen-install.xsl -->
[e576789]675
676 <xsl:template match="screen">
[c048987]677 <xsl:choose>
678<!-- instructions run as root (configuration mainly) -->
679 <xsl:when test="@role = 'root'">
[aeb8539]680<!-- templates begin/end-root are in gen-install.xsl -->
[c048987]681 <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
[aeb8539]682 <xsl:call-template name="begin-root"/>
[c048987]683 </xsl:if>
684 <xsl:apply-templates mode="root"/>
685 <xsl:if test="not(following-sibling::screen[1][@role='root'])">
[aeb8539]686 <xsl:call-template name="end-root"/>
[c048987]687 </xsl:if>
688 </xsl:when>
[67c3df4]689<!-- then all the instructions run as user -->
[c048987]690 <xsl:otherwise>
691 <xsl:apply-templates select="userinput"/>
692 </xsl:otherwise>
693 </xsl:choose>
[e576789]694 </xsl:template>
695
[8fc6a47]696<!-- Templates for bootscripts/units installation -->
[70d73d1]697 <xsl:template name="set-bootpkg-dir">
698 <xsl:param name="bootpkg" select="'bootscripts'"/>
699 <xsl:param name="url" select="''"/>
[619b313]700 <xsl:text>
701BOOTPKG_DIR=blfs-</xsl:text>
[70d73d1]702 <xsl:copy-of select="$bootpkg"/>
703 <xsl:text>
[619b313]704
[1fa0dee]705BOOTSRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${BOOTPKG_DIR}}
706BOOTBUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${BOOTPKG_DIR}}
[973c767]707mkdir -p $BOOTSRC_DIR
708mkdir -p $BOOTBUILD_DIR
709
710pushd $BOOTSRC_DIR
[e576789]711URL=</xsl:text>
[70d73d1]712 <xsl:value-of select="$url"/>
713 <xsl:text>
[e576789]714BOOTPACKG=$(basename $URL)
[bbcdeab]715if [[ ! -f $BOOTPACKG ]] ; then
[1fa0dee]716 if [[ -f $JH_SRC_ARCHIVE/$BOOTPACKG ]] ; then
717 cp $JH_SRC_ARCHIVE/$BOOTPACKG $BOOTPACKG
[bbcdeab]718 else
719 wget -T 30 -t 5 $URL
720 fi
[973c767]721 rm -f $BOOTBUILD_DIR/unpacked
[bbcdeab]722fi
723
[973c767]724cd $BOOTBUILD_DIR
[e576789]725if [[ -e unpacked ]] ; then
[f079f8f]726 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
727 if ! [[ -d $BOOTUNPACKDIR ]]; then
[973c767]728 tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
[f079f8f]729 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
[e576789]730 fi
731else
[973c767]732 tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
[f079f8f]733 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
[e576789]734fi
[619b313]735cd $BOOTUNPACKDIR</xsl:text>
[70d73d1]736 </xsl:template>
737
738 <xsl:template match="screen" mode="config">
739 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
[aeb8539]740<!-- if the preceding "screen" tag is role="root", and we are role="root"
[24ad4fd]741 the end-root has not been called, except if the preceding "screen"
742 tag is itself preceded by a <para> containing and <xref> to
743 bootscripts. So close it only if needed -->
[619b313]744 <xsl:if
[24ad4fd]745 test="preceding-sibling::screen[1][@role='root'] and
746 @role='root' and
747 not(preceding-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='bootscripts'])">
[aeb8539]748 <xsl:call-template name="end-root"/>
749 </xsl:if>
[70d73d1]750 <xsl:call-template name="set-bootpkg-dir">
751 <xsl:with-param name="bootpkg" select="'bootscripts'"/>
752 <xsl:with-param name="url"
753 select="id('bootscripts')//itemizedlist//ulink/@url"/>
754 </xsl:call-template>
[aeb8539]755<!-- if the preceding "screen" tag is role="root", and we are role="root"
[24ad4fd]756 the begin-root will not be called. So do it.-->
[619b313]757 <xsl:if
[24ad4fd]758 test="preceding-sibling::screen[1][@role='root'] and
759 @role='root'">
[aeb8539]760 <xsl:call-template name="begin-root"/>
761 </xsl:if>
[70d73d1]762 </xsl:if>
763 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='systemd-units']">
[aeb8539]764<!-- if the preceding "screen" tag is role="root", and we are role="root"
[24ad4fd]765 the end-root has not been called. So do it, except if it was already a
766 unit install -->
[619b313]767 <xsl:if
[24ad4fd]768 test="preceding-sibling::screen[1][@role='root'] and
769 @role='root' and
770 not(preceding-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='systemd-units'])">
[aeb8539]771 <xsl:call-template name="end-root"/>
772 </xsl:if>
[70d73d1]773 <xsl:call-template name="set-bootpkg-dir">
774 <xsl:with-param name="bootpkg" select="'systemd-units'"/>
775 <xsl:with-param name="url"
776 select="id('systemd-units')//itemizedlist//ulink/@url"/>
777 </xsl:call-template>
[aeb8539]778<!-- if the preceding "screen" tag is role="root", and we are role="root"
[24ad4fd]779 the begin-root will not be called. So do it. -->
[619b313]780 <xsl:if
[24ad4fd]781 test="preceding-sibling::screen[1][@role='root'] and
782 @role='root'">
[aeb8539]783 <xsl:call-template name="begin-root"/>
784 </xsl:if>
[e576789]785 </xsl:if>
786 <xsl:apply-templates select='.'/>
[70d73d1]787 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts' or
788 @linkend='systemd-units']">
[aeb8539]789<!-- if the next "screen" tag is role="root", and we are role="root"
[24ad4fd]790 the end-root has not been called. -->
[619b313]791 <xsl:if
792 test="following-sibling::screen[1][@role='root'] and @role='root'">
[aeb8539]793 <xsl:call-template name="end-root"/>
794 </xsl:if>
[619b313]795 <xsl:text>
796popd</xsl:text>
[aeb8539]797<!-- if the next "screen" tag is role="root", and we are role="root"
[24ad4fd]798 the begin-root will not be called. So do it, except if the next
799 <screen> is itself a unit or bootscript install -->
[619b313]800 <xsl:if
[24ad4fd]801 test="following-sibling::screen[1][@role='root'] and
802 @role='root' and
803 not(following-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='bootscripts' or @linkend='systemd-units'])">
[aeb8539]804 <xsl:call-template name="begin-root"/>
805 </xsl:if>
[e576789]806 </xsl:if>
807 </xsl:template>
808
[c048987]809 <xsl:template match="command" mode="installation">
[619b313]810 <xsl:param name="want-stats" select="false"/>
[a743e57]811 <xsl:variable name="ns" select="normalize-space(string())"/>
[c048987]812 <xsl:variable name="first"
813 select="not(
814 boolean(
815 preceding-sibling::command[contains(text(),'check') or
816 contains(text(),'test')]))"/>
817 <xsl:variable name="last"
818 select="not(
819 boolean(
820 following-sibling::command[contains(text(),'check') or
821 contains(text(),'test')]))"/>
822 <xsl:choose>
[619b313]823 <xsl:when test="$want-stats">
[c048987]824 <xsl:if test="$first">
[67c3df4]825 <xsl:text>
[619b313]826
[67c3df4]827echo Time after make: ${SECONDS} >> $INFOLOG
[59c4761]828echo Size after make: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
[67c3df4]829echo Time before test: ${SECONDS} >> $INFOLOG
[c048987]830
[67c3df4]831</xsl:text>
[c048987]832 </xsl:if>
833 </xsl:when>
834 <xsl:otherwise>
[619b313]835 <xsl:text>
836#</xsl:text>
[c048987]837 </xsl:otherwise>
838 </xsl:choose>
839 <xsl:choose>
840 <xsl:when test="contains($ns,'make')">
841 <xsl:value-of select="substring-before($ns,'make ')"/>
842 <xsl:text>make </xsl:text>
843 <xsl:if test="not(contains($ns,'-k'))">
844 <xsl:text>-k </xsl:text>
845 </xsl:if>
846 <xsl:value-of select="substring-after($ns,'make ')"/>
847 </xsl:when>
848 <xsl:otherwise>
849 <xsl:copy-of select="$ns"/>
850 </xsl:otherwise>
851 </xsl:choose>
[619b313]852 <xsl:if test="$want-stats">
[c048987]853 <xsl:text> &gt;&gt; $TESTLOG 2&gt;&amp;1</xsl:text>
[e576789]854 </xsl:if>
[619b313]855 <xsl:text> || true</xsl:text>
856 <xsl:if test="$want-stats">
[c048987]857 <xsl:text>
[619b313]858
[c048987]859echo Time after test: ${SECONDS} >> $INFOLOG
[59c4761]860echo Size after test: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
[c048987]861echo Time before install: ${SECONDS} >> $INFOLOG
862</xsl:text>
863 </xsl:if>
[e576789]864 </xsl:template>
865
[8fc6a47]866 <xsl:template match="userinput|command">
[619b313]867 <xsl:text>
868</xsl:text>
[e576789]869 <xsl:apply-templates/>
870 </xsl:template>
871
[619b313]872 <xsl:template match="userinput" mode="root">
873 <xsl:text>
874</xsl:text>
875 <xsl:apply-templates mode="root"/>
876 </xsl:template>
877
[aeb8539]878 <xsl:template match="text()">
879 <xsl:call-template name="remove-ampersand">
880 <xsl:with-param name="out-string" select="string()"/>
881 </xsl:call-template>
882 </xsl:template>
883
[e576789]884 <xsl:template match="text()" mode="root">
885 <xsl:call-template name="output-root">
886 <xsl:with-param name="out-string" select="string()"/>
887 </xsl:call-template>
888 </xsl:template>
889
890 <xsl:template name="output-root">
891 <xsl:param name="out-string" select="''"/>
892 <xsl:choose>
893 <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
894 <xsl:call-template name="output-root">
895 <xsl:with-param name="out-string"
896 select="substring-before($out-string,'$')"/>
897 </xsl:call-template>
898 <xsl:text>\$</xsl:text>
899 <xsl:call-template name="output-root">
900 <xsl:with-param name="out-string"
901 select="substring-after($out-string,'$')"/>
902 </xsl:call-template>
903 </xsl:when>
904 <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
905 <xsl:call-template name="output-root">
906 <xsl:with-param name="out-string"
907 select="substring-before($out-string,'`')"/>
908 </xsl:call-template>
909 <xsl:text>\`</xsl:text>
910 <xsl:call-template name="output-root">
911 <xsl:with-param name="out-string"
912 select="substring-after($out-string,'`')"/>
913 </xsl:call-template>
914 </xsl:when>
915 <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
916 <xsl:call-template name="output-root">
917 <xsl:with-param name="out-string"
918 select="substring-before($out-string,'\')"/>
919 </xsl:call-template>
920 <xsl:text>\\</xsl:text>
921 <xsl:call-template name="output-root">
922 <xsl:with-param name="out-string"
923 select="substring-after($out-string,'\')"/>
924 </xsl:call-template>
925 </xsl:when>
926 <xsl:otherwise>
[aeb8539]927 <xsl:call-template name="remove-ampersand">
928 <xsl:with-param name="out-string" select="$out-string"/>
929 </xsl:call-template>
930<!-- <xsl:value-of select="$out-string"/> -->
[e576789]931 </xsl:otherwise>
932 </xsl:choose>
933 </xsl:template>
934
[67c3df4]935 <xsl:template name="output-destdir">
936 <xsl:apply-templates
937 select="userinput|following-sibling::screen[@role='root']/userinput"
938 mode="destdir"/>
939 <xsl:text>
[619b313]940
[67c3df4]941echo Time after install: ${SECONDS} >> $INFOLOG
[59c4761]942echo Size after install: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
[67c3df4]943</xsl:text>
944 </xsl:template>
945
946 <xsl:template match="userinput" mode="destdir">
[8fc6a47]947 <xsl:text>
948</xsl:text>
[6ac0d96]949 <xsl:for-each select="./literal">
950 <xsl:call-template name="outputpkgdest">
951 <xsl:with-param name="outputstring" select="preceding-sibling::text()[1]"/>
952 </xsl:call-template>
953 <xsl:apply-templates select="."/>
954 </xsl:for-each>
955 <xsl:call-template name="outputpkgdest">
956 <xsl:with-param name="outputstring" select="text()[last()]"/>
957 </xsl:call-template>
[67c3df4]958 </xsl:template>
959
960 <xsl:template name="outputpkgdest">
961 <xsl:param name="outputstring" select="'foo'"/>
962 <xsl:choose>
[3fa4147]963 <xsl:when test="contains(normalize-space($outputstring),' make ') or
964 starts-with($outputstring, 'make ')">
[67c3df4]965 <xsl:choose>
966 <xsl:when test="not(starts-with($outputstring,'make'))">
967 <xsl:call-template name="outputpkgdest">
968 <xsl:with-param name="outputstring"
969 select="substring-before($outputstring,'make')"/>
970 </xsl:call-template>
971 <xsl:call-template name="outputpkgdest">
972 <xsl:with-param
973 name="outputstring"
974 select="substring-after($outputstring,
975 substring-before($outputstring,'make'))"/>
976 </xsl:call-template>
977 </xsl:when>
978 <xsl:otherwise>
[619b313]979 <xsl:text>
980make DESTDIR=$PKG_DEST</xsl:text>
[67c3df4]981 <xsl:call-template name="outputpkgdest">
982 <xsl:with-param
983 name="outputstring"
984 select="substring-after($outputstring,'make')"/>
985 </xsl:call-template>
986 </xsl:otherwise>
987 </xsl:choose>
988 </xsl:when>
989 <xsl:when test="contains($outputstring,'ninja install')">
990 <xsl:choose>
991 <xsl:when test="not(starts-with($outputstring,'ninja install'))">
992 <xsl:call-template name="outputpkgdest">
993 <xsl:with-param name="outputstring"
994 select="substring-before($outputstring,'ninja install')"/>
995 </xsl:call-template>
996 <xsl:call-template name="outputpkgdest">
997 <xsl:with-param
998 name="outputstring"
999 select="substring-after($outputstring,
1000 substring-before($outputstring,'ninja install'))"/>
1001 </xsl:call-template>
1002 </xsl:when>
1003 <xsl:otherwise>
[619b313]1004 <xsl:text>
1005DESTDIR=$PKG_DEST ninja</xsl:text>
[67c3df4]1006 <xsl:call-template name="outputpkgdest">
1007 <xsl:with-param
1008 name="outputstring"
1009 select="substring-after($outputstring,'ninja')"/>
1010 </xsl:call-template>
1011 </xsl:otherwise>
1012 </xsl:choose>
1013 </xsl:when>
1014 <xsl:otherwise> <!-- no make nor ninja in this string -->
1015 <xsl:choose>
1016 <xsl:when test="contains($outputstring,'&gt;/') and
1017 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
[aeb8539]1018 <xsl:call-template name="remove-ampersand">
1019 <xsl:with-param name="out-string"
1020 select="substring-before($outputstring,'&gt;/')"/>
1021 </xsl:call-template>
1022<!-- <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>-->
[67c3df4]1023 <xsl:text>&gt;$PKG_DEST/</xsl:text>
1024 <xsl:call-template name="outputpkgdest">
1025 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
1026 </xsl:call-template>
1027 </xsl:when>
1028 <xsl:when test="contains($outputstring,' /')">
[aeb8539]1029 <xsl:call-template name="remove-ampersand">
1030 <xsl:with-param name="out-string"
1031 select="substring-before($outputstring,' /')"/>
1032 </xsl:call-template>
1033<!-- <xsl:value-of select="substring-before($outputstring,' /')"/>-->
[67c3df4]1034 <xsl:text> $PKG_DEST/</xsl:text>
1035 <xsl:call-template name="outputpkgdest">
1036 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
1037 </xsl:call-template>
1038 </xsl:when>
1039 <xsl:otherwise>
[aeb8539]1040 <xsl:call-template name="remove-ampersand">
1041 <xsl:with-param name="out-string" select="$outputstring"/>
1042 </xsl:call-template>
1043<!-- <xsl:value-of select="$outputstring"/>-->
[67c3df4]1044 </xsl:otherwise>
1045 </xsl:choose>
1046 </xsl:otherwise>
1047 </xsl:choose>
1048 </xsl:template>
1049
[aeb8539]1050 <xsl:template name="remove-ampersand">
1051 <xsl:param name="out-string" select="''"/>
1052 <xsl:choose>
1053 <xsl:when test="contains($out-string,'&amp;&amp;&#xA;')">
1054 <xsl:variable name="instruction-before">
1055 <xsl:call-template name="last-line">
1056 <xsl:with-param
1057 name="instructions"
1058 select="substring-before($out-string,'&amp;&amp;&#xA;')"/>
1059 </xsl:call-template>
1060 </xsl:variable>
1061 <xsl:call-template name="remove-end-space">
1062 <xsl:with-param
1063 name="instructions"
1064 select="substring-before($out-string,'&amp;&amp;&#xA;')"/>
1065 </xsl:call-template>
1066 <xsl:if test="contains($instruction-before,' ]') or
1067 contains($instruction-before,'test ') or
1068 contains($instruction-before,'pgrep -l')">
1069 <xsl:text> &amp;&amp;</xsl:text>
1070 </xsl:if>
[619b313]1071 <xsl:text>
1072</xsl:text>
[aeb8539]1073 <xsl:call-template name="remove-ampersand">
1074 <xsl:with-param name="out-string"
1075 select="substring-after($out-string,
1076 '&amp;&amp;&#xA;')"/>
1077 </xsl:call-template>
1078 </xsl:when>
1079 <xsl:otherwise>
1080 <xsl:copy-of select="$out-string"/>
1081 </xsl:otherwise>
1082 </xsl:choose>
1083 </xsl:template>
1084
1085 <xsl:template name="last-line">
1086 <xsl:param name="instructions" select="''"/>
1087 <xsl:choose>
1088 <xsl:when test="contains($instructions,'&#xA;')">
1089 <xsl:call-template name="last-line">
1090 <xsl:with-param
1091 name="instructions"
1092 select="substring-after($instructions,'&#xA;')"/>
1093 </xsl:call-template>
1094 </xsl:when>
1095 <xsl:otherwise>
1096 <xsl:copy-of select="normalize-space($instructions)"/>
1097 </xsl:otherwise>
1098 </xsl:choose>
1099 </xsl:template>
1100
1101 <xsl:template name="remove-end-space">
1102 <xsl:param name="instructions" select="''"/>
1103 <xsl:choose>
[619b313]1104 <xsl:when
1105 test="substring($instructions,string-length($instructions))=' '">
[aeb8539]1106 <xsl:call-template name="remove-end-space">
1107 <xsl:with-param
1108 name="instructions"
[619b313]1109 select="substring($instructions,
1110 1,
1111 string-length($instructions)-1)"/>
[aeb8539]1112 </xsl:call-template>
1113 </xsl:when>
1114 <xsl:otherwise>
[619b313]1115 <xsl:copy-of select="$instructions"/>
[aeb8539]1116 </xsl:otherwise>
1117 </xsl:choose>
1118 </xsl:template>
1119
[e576789]1120</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.