source: BLFS/xsl/scripts.xsl@ df1f318

ablfs-more legacy trunk
Last change on this file since df1f318 was 9e0c4b6, checked in by Pierre Labastie <pierre@…>, 7 years ago

Wrong variable name when naming info.log file if stats are requested

  • Property mode set to 100644
File size: 30.4 KB
Line 
1<?xml version="1.0"?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:exsl="http://exslt.org/common"
5 extension-element-prefixes="exsl"
6 version="1.0">
7
8<!-- $Id$ -->
9
10<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
11
12<!-- Check whether the book is sysv or systemd -->
13 <xsl:variable name="rev">
14 <xsl:choose>
15 <xsl:when test="//bookinfo/title/phrase[@revision='systemd']">
16 systemd
17 </xsl:when>
18 <xsl:otherwise>
19 sysv
20 </xsl:otherwise>
21 </xsl:choose>
22 </xsl:variable>
23
24 <!-- Wrap "root" commands inside a wrapper function, allowing
25 "porg style" package management -->
26 <xsl:param name="wrap-install" select="'n'"/>
27
28 <!-- list of packages needing stats -->
29 <xsl:param name="list-stat" select="''"/>
30
31 <!-- Remove libtool .la files -->
32 <xsl:param name="del-la-files" select="'y'"/>
33
34 <!-- Build as user (y) or as root (n)? -->
35 <xsl:param name="sudo" select="'y'"/>
36
37<!-- simple instructions for removing .la files. -->
38 <xsl:variable name="la-files-instr">
39
40for libdir in /lib /usr/lib $(find /opt -name lib); do
41 find $libdir -name \*.la ! -path \*ImageMagick\* -delete
42done
43
44</xsl:variable>
45
46<xsl:variable name="list-stat-norm"
47 select="concat(' ', normalize-space($list-stat),' ')"/>
48
49 <xsl:template match="/">
50 <xsl:apply-templates select="//sect1"/>
51 </xsl:template>
52
53<!--=================== Master chunks code ======================-->
54
55 <xsl:template match="sect1">
56
57 <xsl:if test="@id != 'bootscripts' and @id != 'systemd-units'">
58 <!-- The file names -->
59 <xsl:variable name="filename" select="@id"/>
60
61 <!-- The build order -->
62 <xsl:variable name="position" select="position()"/>
63 <xsl:variable name="order">
64 <xsl:choose>
65 <xsl:when test="string-length($position) = 1">
66 <xsl:text>00</xsl:text>
67 <xsl:value-of select="$position"/>
68 </xsl:when>
69 <xsl:when test="string-length($position) = 2">
70 <xsl:text>0</xsl:text>
71 <xsl:value-of select="$position"/>
72 </xsl:when>
73 <xsl:otherwise>
74 <xsl:value-of select="$position"/>
75 </xsl:otherwise>
76 </xsl:choose>
77 </xsl:variable>
78
79 <!-- Depuration code -->
80 <xsl:message>
81 <xsl:text>SCRIPT is </xsl:text>
82 <xsl:value-of select="concat($order,'-z-',$filename)"/>
83 <xsl:text>&#xA; FTPDIR is </xsl:text>
84 <xsl:value-of select="$filename"/>
85 <xsl:text>&#xA;&#xA;</xsl:text>
86 </xsl:message>
87
88 <!-- Creating the scripts -->
89 <exsl:document href="{$order}-z-{$filename}" method="text">
90 <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
91 <xsl:choose>
92 <!-- Package page -->
93 <xsl:when test="sect2[@role='package']">
94 <!-- We build in a subdirectory, whose name may be needed
95 if using package management (see envars.conf), so
96 "export" it -->
97 <xsl:text>export JH_PKG_DIR=</xsl:text>
98 <xsl:value-of select="$filename"/>
99 <xsl:text>
100SRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${JH_PKG_DIR}}
101BUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${JH_PKG_DIR}}
102mkdir -p $SRC_DIR
103mkdir -p $BUILD_DIR
104
105</xsl:text>
106
107<!-- If stats are requested, include some definitions and intitializations -->
108 <xsl:if test="contains($list-stat-norm,concat(' ',@id,' '))">
109 <xsl:text>INFOLOG=$(pwd)/info-${JH_PKG_DIR}
110TESTLOG=$(pwd)/test-${JH_PKG_DIR}
111unset MAKEFLAGS
112#MAKEFLAGS=-j4
113echo MAKEFLAGS: $MAKEFLAGS > $INFOLOG
114> $TESTLOG
115PKG_DEST=${BUILD_DIR}/dest
116rm -rf $PKG_DEST
117
118</xsl:text>
119 </xsl:if>
120 <!-- Download code and build commands -->
121 <xsl:apply-templates select="sect2"/>
122 <!-- Clean-up -->
123 <xsl:text>cd $BUILD_DIR
124[[ -n "$JH_KEEP_FILES" ]] || </xsl:text>
125 <!-- In some case, some files in the build tree are owned
126 by root -->
127 <xsl:if test="$sudo='y'">
128 <xsl:text>sudo </xsl:text>
129 </xsl:if>
130 <xsl:text>rm -rf $JH_UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
131 </xsl:when>
132 <!-- Non-package page -->
133 <xsl:otherwise>
134 <xsl:apply-templates select=".//screen"/>
135 </xsl:otherwise>
136 </xsl:choose>
137 <xsl:text>exit</xsl:text>
138 </exsl:document>
139 </xsl:if>
140 </xsl:template>
141
142<!--======================= Sub-sections code =======================-->
143
144 <xsl:template match="sect2">
145 <xsl:choose>
146 <xsl:when test="@role = 'package'">
147 <xsl:text>cd $SRC_DIR
148</xsl:text>
149 <!-- Download information is in bridgehead tags -->
150 <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
151 <xsl:text>&#xA;</xsl:text>
152 </xsl:when>
153 <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
154 <xsl:apply-templates select=".//screen"/>
155 </xsl:when>
156 <xsl:when test="@role = 'installation'">
157 <xsl:text>
158cd $BUILD_DIR
159find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
160 <xsl:if test="$sudo='y'">
161 <xsl:text>sudo </xsl:text>
162 </xsl:if>
163 <xsl:text>rm -rf
164
165</xsl:text>
166<!-- If stats are requested, insert the start size -->
167 <xsl:if test="contains($list-stat-norm,concat(' ',../@id,' '))">
168 <xsl:text>echo Start Size: $(sudo du -skx --exclude home /) >> $INFOLOG
169
170</xsl:text>
171 </xsl:if>
172
173 <xsl:text>case $PACKAGE in
174 *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
175 tar -xvf $SRC_DIR/$PACKAGE &gt; unpacked
176 JH_UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^\./@@;s@/.*@@'`
177 ;;
178 *.tar.lz)
179 bsdtar -xvf $SRC_DIR/$PACKAGE 2&gt; unpacked
180 JH_UNPACKDIR=`head -n1 unpacked | cut -d" " -f2 | sed 's@^\./@@;s@/.*@@'`
181 ;;
182 *.zip)
183 zipinfo -1 $SRC_DIR/$PACKAGE &gt; unpacked
184 JH_UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
185 if test $(wc -w &lt;&lt;&lt; $JH_UNPACKDIR) -eq 1; then
186 unzip $SRC_DIR/$PACKAGE
187 else
188 JH_UNPACKDIR=${PACKAGE%.zip}
189 unzip -d $JH_UNPACKDIR $SRC_DIR/$PACKAGE
190 fi
191 ;;
192 *)
193 JH_UNPACKDIR=$JH_PKG_DIR-build
194 mkdir $JH_UNPACKDIR
195 cp $SRC_DIR/$PACKAGE $JH_UNPACKDIR
196 cp $(find . -mindepth 1 -maxdepth 1 -type l) $JH_UNPACKDIR
197 ;;
198esac
199export JH_UNPACKDIR
200cd $JH_UNPACKDIR&#xA;
201</xsl:text>
202<!-- If stats are requested, insert the start time -->
203 <xsl:if test="contains($list-stat-norm,concat(' ',../@id,' '))">
204 <xsl:text>echo Start Time: ${SECONDS} >> $INFOLOG
205
206</xsl:text>
207 </xsl:if>
208
209 <xsl:apply-templates select=".//screen | .//para/command"/>
210 <xsl:if test="$sudo = 'y'">
211 <xsl:text>sudo /sbin/</xsl:text>
212 </xsl:if>
213 <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
214 </xsl:when>
215 <xsl:when test="@role = 'configuration'">
216 <xsl:apply-templates select=".//screen" mode="config"/>
217 </xsl:when>
218 </xsl:choose>
219 </xsl:template>
220
221<!--==================== Download code =======================-->
222
223 <!-- template for extracting the filename from an url in the form:
224 proto://internet.name/dir1/.../dirn/filename?condition.
225 Needed, because substring-after(...,'/') returns only the
226 substring after the first '/'. -->
227 <xsl:template name="package_name">
228 <xsl:param name="url" select="foo"/>
229 <xsl:param name="sub-url" select="substring-after($url,'/')"/>
230 <xsl:choose>
231 <xsl:when test="contains($sub-url,'/')">
232 <xsl:call-template name="package_name">
233 <xsl:with-param name="url" select="$sub-url"/>
234 </xsl:call-template>
235 </xsl:when>
236 <xsl:otherwise>
237 <xsl:choose>
238 <xsl:when test="contains($sub-url,'?')">
239 <xsl:value-of select="substring-before($sub-url,'?')"/>
240 </xsl:when>
241 <xsl:otherwise>
242 <xsl:value-of select="$sub-url"/>
243 </xsl:otherwise>
244 </xsl:choose>
245 </xsl:otherwise>
246 </xsl:choose>
247 </xsl:template>
248
249 <!-- Generates the code to download a package, an additional package or
250 a patch. -->
251 <xsl:template name="download-file">
252 <xsl:param name="httpurl" select="''"/>
253 <xsl:param name="ftpurl" select="''"/>
254 <xsl:param name="md5" select="''"/>
255 <xsl:param name="varname" select="''"/>
256 <xsl:variable name="package">
257 <xsl:call-template name="package_name">
258 <xsl:with-param name="url">
259 <xsl:choose>
260 <xsl:when test="string-length($httpurl) &gt; 10">
261 <xsl:value-of select="$httpurl"/>
262 </xsl:when>
263 <xsl:otherwise>
264 <xsl:value-of select="$ftpurl"/>
265 </xsl:otherwise>
266 </xsl:choose>
267 </xsl:with-param>
268 </xsl:call-template>
269 </xsl:variable>
270 <xsl:variable name="first_letter"
271 select="translate(substring($package,1,1),
272 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
273 'abcdefghijklmnopqrstuvwxyz')"/>
274 <xsl:text>&#xA;</xsl:text>
275 <xsl:value-of select="$varname"/>
276 <xsl:text>=</xsl:text>
277 <xsl:value-of select="$package"/>
278 <xsl:text>&#xA;if [[ ! -f $</xsl:text>
279 <xsl:value-of select="$varname"/>
280 <xsl:text> ]] ; then
281 if [[ -f $JH_SRC_ARCHIVE/$</xsl:text>
282 <xsl:value-of select="$varname"/>
283 <xsl:text> ]] ; then&#xA;</xsl:text>
284 <xsl:text> cp $JH_SRC_ARCHIVE/$</xsl:text>
285 <xsl:value-of select="$varname"/>
286 <xsl:text> $</xsl:text>
287 <xsl:value-of select="$varname"/>
288 <xsl:text>
289 else&#xA;</xsl:text>
290 <!-- Download from upstream http -->
291 <xsl:if test="string-length($httpurl) &gt; 10">
292 <xsl:text> wget -T 30 -t 5 </xsl:text>
293 <xsl:value-of select="$httpurl"/>
294 <xsl:text> ||&#xA;</xsl:text>
295 </xsl:if>
296 <!-- Download from upstream ftp -->
297 <xsl:if test="string-length($ftpurl) &gt; 10">
298 <xsl:text> wget -T 30 -t 5 </xsl:text>
299 <xsl:value-of select="$ftpurl"/>
300 <xsl:text> ||&#xA;</xsl:text>
301 </xsl:if>
302 <!-- The FTP_SERVER mirror as a last resort -->
303 <xsl:text> wget -T 30 -t 5 ${JH_FTP_SERVER}svn/</xsl:text>
304 <xsl:value-of select="$first_letter"/>
305 <xsl:text>/$</xsl:text>
306 <xsl:value-of select="$varname"/>
307 <xsl:text>
308 fi
309fi
310</xsl:text>
311 <xsl:if test="string-length($md5) &gt; 10">
312 <xsl:text>echo "</xsl:text>
313 <xsl:value-of select="$md5"/>
314 <xsl:text>&#x20;&#x20;$</xsl:text>
315 <xsl:value-of select="$varname"/>
316 <xsl:text>" | md5sum -c -
317</xsl:text>
318 </xsl:if>
319<!-- link additional packages into $BUILD_DIR, because they are supposed to
320 be there-->
321 <xsl:if test="string($varname) != 'PACKAGE'">
322 <xsl:text>[[ "$SRC_DIR" != "$BUILD_DIR" ]] &amp;&amp; ln -sf $SRC_DIR/$</xsl:text>
323 <xsl:value-of select="$varname"/>
324 <xsl:text> $BUILD_DIR
325</xsl:text>
326 </xsl:if>
327 </xsl:template>
328
329 <!-- Extract the MD5 sum information -->
330 <xsl:template match="para" mode="md5">
331 <xsl:choose>
332 <xsl:when test="contains(substring-after(string(),'sum: '),'&#xA;')">
333 <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'&#xA;')"/>
334 </xsl:when>
335 <xsl:otherwise>
336 <xsl:value-of select="substring-after(string(),'sum: ')"/>
337 </xsl:otherwise>
338 </xsl:choose>
339 </xsl:template>
340
341 <!-- We have several templates itemizedlist, depending on whether we
342 expect the package information, or additional package(s) or patch(es)
343 information. Select the appropriate mode here. -->
344 <xsl:template match="bridgehead">
345 <xsl:choose>
346 <!-- Special case for Openjdk -->
347 <xsl:when test="contains(string(),'Source Package Information')">
348 <xsl:apply-templates
349 select="following-sibling::itemizedlist[1]//simplelist">
350 <xsl:with-param name="varname" select="'PACKAGE'"/>
351 </xsl:apply-templates>
352 <xsl:apply-templates select="following-sibling::itemizedlist
353 [preceding-sibling::bridgehead[1]=current()
354 and position() &gt;1]//simplelist">
355 <xsl:with-param name="varname" select="'PACKAGE1'"/>
356 </xsl:apply-templates>
357 </xsl:when>
358 <!-- Package information -->
359 <xsl:when test="contains(string(),'Package Information')">
360 <xsl:apply-templates select="following-sibling::itemizedlist
361 [preceding-sibling::bridgehead[1]=current()]"
362 mode="package"/>
363 </xsl:when>
364 <!-- Additional package information -->
365 <!-- special case for llvm -->
366 <xsl:when test="contains(string(),'Optional Download')">
367 <xsl:apply-templates select="following-sibling::itemizedlist"
368 mode="additional"/>
369 </xsl:when>
370 <!-- All other additional packages have "Additional" -->
371 <xsl:when test="contains(string(),'Additional')">
372 <xsl:apply-templates select="following-sibling::itemizedlist"
373 mode="additional"/>
374 </xsl:when>
375 <!-- Do not do anything if the dev has created another type of
376 bridgehead. -->
377 <xsl:otherwise/>
378 </xsl:choose>
379 </xsl:template>
380
381 <!-- Call the download code template with appropriate parameters -->
382 <xsl:template match="itemizedlist" mode="package">
383 <xsl:call-template name="download-file">
384 <xsl:with-param name="httpurl">
385 <xsl:value-of select="./listitem[1]/para/ulink/@url"/>
386 </xsl:with-param>
387 <xsl:with-param name="ftpurl">
388 <xsl:value-of select="./listitem/para[contains(string(),'FTP')]/ulink/@url"/>
389 </xsl:with-param>
390 <xsl:with-param name="md5">
391 <xsl:apply-templates select="./listitem/para[contains(string(),'MD5')]"
392 mode="md5"/>
393 </xsl:with-param>
394 <xsl:with-param name="varname" select="'PACKAGE'"/>
395 </xsl:call-template>
396 </xsl:template>
397
398 <xsl:template match="itemizedlist" mode="additional">
399 <!-- The normal layout is "one listitem"<->"one url", but some devs
400 find amusing to have FTP and/or MD5sum listitems, or to
401 enclose the download information inside a simplelist tag... -->
402 <xsl:for-each select="listitem[.//ulink]">
403 <xsl:choose>
404 <!-- hopefully, there was a HTTP line before -->
405 <xsl:when test="contains(string(./para),'FTP')"/>
406 <xsl:when test=".//simplelist">
407 <xsl:apply-templates select=".//simplelist">
408 <xsl:with-param name="varname" select="'PACKAGE1'"/>
409 </xsl:apply-templates>
410 </xsl:when>
411 <xsl:otherwise>
412 <xsl:call-template name="download-file">
413 <xsl:with-param name="httpurl">
414 <xsl:value-of select="./para/ulink/@url"/>
415 </xsl:with-param>
416 <xsl:with-param name="ftpurl">
417 <xsl:value-of
418 select="following-sibling::listitem[1]/
419 para[contains(string(),'FTP')]/ulink/@url"/>
420 </xsl:with-param>
421 <xsl:with-param name="md5">
422 <xsl:apply-templates
423 select="following-sibling::listitem[position()&lt;3]/
424 para[contains(string(),'MD5')]"
425 mode="md5"/>
426 </xsl:with-param>
427 <xsl:with-param name="varname">
428 <xsl:choose>
429 <xsl:when test="contains(./para/ulink/@url,'.patch')">
430 <xsl:text>PATCH</xsl:text>
431 </xsl:when>
432 <xsl:otherwise>
433 <xsl:text>PACKAGE1</xsl:text>
434 </xsl:otherwise>
435 </xsl:choose>
436 </xsl:with-param>
437 </xsl:call-template>
438 </xsl:otherwise>
439 </xsl:choose>
440 </xsl:for-each>
441 </xsl:template>
442
443 <!-- the simplelist case. Hopefully, the layout is one member for
444 url, one for md5 and others for various information, that we do not
445 use -->
446 <xsl:template match="simplelist">
447 <xsl:param name="varname" select="'PACKAGE1'"/>
448 <xsl:call-template name="download-file">
449 <xsl:with-param name="httpurl" select=".//ulink/@url"/>
450 <xsl:with-param name="md5">
451 <xsl:value-of select="substring-after(member[contains(string(),'MD5')],'sum: ')"/>
452 </xsl:with-param>
453 <xsl:with-param name="varname" select="$varname"/>
454 </xsl:call-template>
455 </xsl:template>
456<!--======================== Commands code ==========================-->
457
458 <xsl:template match="screen">
459 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
460 <xsl:choose>
461<!-- First the case of installation instructions -->
462 <xsl:when test="@role = 'root' and
463 ancestor::sect2[@role='installation'] and
464 not(contains(string(),'useradd')) and
465 not(contains(string(),'groupadd'))">
466 <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
467 <xsl:if test="contains($list-stat-norm,
468 concat(' ',
469 ancestor::sect1/@id,
470 ' '))">
471 <xsl:call-template name="output-destdir"/>
472 </xsl:if>
473 <xsl:if test="$sudo = 'y'">
474 <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
475 </xsl:if>
476 <xsl:if test="$wrap-install = 'y'">
477 <xsl:text>if [ -r "$JH_PACK_INSTALL" ]; then
478 source $JH_PACK_INSTALL
479 export -f wrapInstall
480 export -f packInstall
481fi
482wrapInstall '
483</xsl:text>
484 </xsl:if>
485 </xsl:if>
486 <xsl:apply-templates mode="root"/>
487 <xsl:if test="not(following-sibling::screen[1][@role='root'])">
488 <xsl:if test="$del-la-files = 'y'">
489 <xsl:call-template name="output-root">
490 <xsl:with-param name="out-string" select="$la-files-instr"/>
491 </xsl:call-template>
492 </xsl:if>
493 <xsl:if test="$wrap-install = 'y'">
494 <xsl:text>'&#xA;packInstall</xsl:text>
495 </xsl:if>
496 <xsl:if test="$sudo = 'y'">
497 <xsl:text>&#xA;ROOT_EOF</xsl:text>
498 </xsl:if>
499 </xsl:if>
500 </xsl:when>
501<!-- then the case of other instructions run as root (configuration mainly) -->
502 <xsl:when test="@role = 'root'">
503 <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
504 <xsl:if test="$sudo = 'y'">
505 <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
506 </xsl:if>
507 </xsl:if>
508 <xsl:apply-templates mode="root"/>
509 <xsl:if test="not(following-sibling::screen[1][@role='root'])">
510 <xsl:if test="$sudo = 'y'">
511 <xsl:text>&#xA;ROOT_EOF</xsl:text>
512 </xsl:if>
513 </xsl:if>
514 </xsl:when>
515<!-- then all the instructions run as user -->
516 <xsl:otherwise>
517 <xsl:apply-templates select="userinput"/>
518 </xsl:otherwise>
519 </xsl:choose>
520 <xsl:text>&#xA;</xsl:text>
521 </xsl:if>
522 </xsl:template>
523
524 <xsl:template name="set-bootpkg-dir">
525 <xsl:param name="bootpkg" select="'bootscripts'"/>
526 <xsl:param name="url" select="''"/>
527 <xsl:text>BOOTPKG_DIR=blfs-</xsl:text>
528 <xsl:copy-of select="$bootpkg"/>
529 <xsl:text>
530BOOTSRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${BOOTPKG_DIR}}
531BOOTBUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${BOOTPKG_DIR}}
532mkdir -p $BOOTSRC_DIR
533mkdir -p $BOOTBUILD_DIR
534
535pushd $BOOTSRC_DIR
536URL=</xsl:text>
537 <xsl:value-of select="$url"/>
538 <xsl:text>
539BOOTPACKG=$(basename $URL)
540if [[ ! -f $BOOTPACKG ]] ; then
541 if [[ -f $JH_SRC_ARCHIVE/$BOOTPACKG ]] ; then
542 cp $JH_SRC_ARCHIVE/$BOOTPACKG $BOOTPACKG
543 else
544 wget -T 30 -t 5 $URL
545 fi
546 rm -f $BOOTBUILD_DIR/unpacked
547fi
548
549cd $BOOTBUILD_DIR
550if [[ -e unpacked ]] ; then
551 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
552 if ! [[ -d $BOOTUNPACKDIR ]]; then
553 tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
554 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
555 fi
556else
557 tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
558 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
559fi
560cd $BOOTUNPACKDIR
561</xsl:text>
562 </xsl:template>
563
564 <xsl:template match="screen" mode="config">
565 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
566 <xsl:call-template name="set-bootpkg-dir">
567 <xsl:with-param name="bootpkg" select="'bootscripts'"/>
568 <xsl:with-param name="url"
569 select="id('bootscripts')//itemizedlist//ulink/@url"/>
570 </xsl:call-template>
571 </xsl:if>
572 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='systemd-units']">
573 <xsl:call-template name="set-bootpkg-dir">
574 <xsl:with-param name="bootpkg" select="'systemd-units'"/>
575 <xsl:with-param name="url"
576 select="id('systemd-units')//itemizedlist//ulink/@url"/>
577 </xsl:call-template>
578 </xsl:if>
579 <xsl:apply-templates select='.'/>
580 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts' or
581 @linkend='systemd-units']">
582 <xsl:text>
583popd</xsl:text>
584 </xsl:if>
585 <xsl:text>&#xA;</xsl:text>
586 </xsl:template>
587
588 <xsl:template match="para/command">
589 <xsl:variable name="ns" select="normalize-space(string())"/>
590 <xsl:if test="contains($ns,'test') or
591 contains($ns,'check')">
592 <xsl:choose>
593 <xsl:when test="contains($list-stat-norm,
594 concat(' ',ancestor::sect1/@id,' '))">
595 <xsl:text>
596echo Time after make: ${SECONDS} >> $INFOLOG
597echo Size after make: $(sudo du -skx --exclude home /) >> $INFOLOG
598echo Time before test: ${SECONDS} >> $INFOLOG
599</xsl:text>
600 </xsl:when>
601 <xsl:otherwise>
602 <xsl:text>#</xsl:text>
603 </xsl:otherwise>
604 </xsl:choose>
605 <xsl:choose>
606 <xsl:when test="contains($ns,'make')">
607 <xsl:value-of select="substring-before($ns,'make ')"/>
608 <xsl:text>make </xsl:text>
609 <xsl:if test="not(contains($ns,'-k'))">
610 <xsl:text>-k </xsl:text>
611 </xsl:if>
612 <xsl:value-of select="substring-after($ns,'make ')"/>
613 </xsl:when>
614 <xsl:otherwise>
615 <xsl:copy-of select="$ns"/>
616 </xsl:otherwise>
617 </xsl:choose>
618 <xsl:if test="contains($list-stat-norm,
619 concat(' ',ancestor::sect1/@id,' '))">
620 <xsl:text> &gt;&gt; $TESTLOG 2&gt;&amp;1</xsl:text>
621 </xsl:if>
622 <xsl:text> || true&#xA;</xsl:text>
623 </xsl:if>
624 </xsl:template>
625
626 <xsl:template match="userinput">
627 <xsl:apply-templates/>
628 </xsl:template>
629
630 <xsl:template match="text()" mode="root">
631 <xsl:call-template name="output-root">
632 <xsl:with-param name="out-string" select="string()"/>
633 </xsl:call-template>
634 </xsl:template>
635
636 <xsl:variable name="APOS">'</xsl:variable>
637
638 <xsl:template name="output-root">
639 <xsl:param name="out-string" select="''"/>
640 <xsl:choose>
641 <xsl:when test="contains($out-string,'make ')">
642 <xsl:call-template name="output-root">
643 <xsl:with-param name="out-string"
644 select="substring-before($out-string,'make ')"/>
645 </xsl:call-template>
646 <xsl:text>make -j1 </xsl:text>
647 <xsl:call-template name="output-root">
648 <xsl:with-param name="out-string"
649 select="substring-after($out-string,'make ')"/>
650 </xsl:call-template>
651 </xsl:when>
652 <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
653 <xsl:call-template name="output-root">
654 <xsl:with-param name="out-string"
655 select="substring-before($out-string,'$')"/>
656 </xsl:call-template>
657 <xsl:text>\$</xsl:text>
658 <xsl:call-template name="output-root">
659 <xsl:with-param name="out-string"
660 select="substring-after($out-string,'$')"/>
661 </xsl:call-template>
662 </xsl:when>
663 <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
664 <xsl:call-template name="output-root">
665 <xsl:with-param name="out-string"
666 select="substring-before($out-string,'`')"/>
667 </xsl:call-template>
668 <xsl:text>\`</xsl:text>
669 <xsl:call-template name="output-root">
670 <xsl:with-param name="out-string"
671 select="substring-after($out-string,'`')"/>
672 </xsl:call-template>
673 </xsl:when>
674 <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
675 <xsl:call-template name="output-root">
676 <xsl:with-param name="out-string"
677 select="substring-before($out-string,'\')"/>
678 </xsl:call-template>
679 <xsl:text>\\</xsl:text>
680 <xsl:call-template name="output-root">
681 <xsl:with-param name="out-string"
682 select="substring-after($out-string,'\')"/>
683 </xsl:call-template>
684 </xsl:when>
685 <xsl:when test="contains($out-string,string($APOS))
686 and $wrap-install = 'y'
687 and ancestor::sect2[@role='installation']">
688 <xsl:call-template name="output-root">
689 <xsl:with-param name="out-string"
690 select="substring-before($out-string,string($APOS))"/>
691 </xsl:call-template>
692 <xsl:text>'\''</xsl:text>
693 <xsl:call-template name="output-root">
694 <xsl:with-param name="out-string"
695 select="substring-after($out-string,string($APOS))"/>
696 </xsl:call-template>
697 </xsl:when>
698 <xsl:otherwise>
699 <xsl:value-of select="$out-string"/>
700 </xsl:otherwise>
701 </xsl:choose>
702 </xsl:template>
703
704 <xsl:template match="replaceable">
705 <xsl:text>**EDITME</xsl:text>
706 <xsl:apply-templates/>
707 <xsl:text>EDITME**</xsl:text>
708 </xsl:template>
709
710 <xsl:template match="replaceable" mode="root">
711 <xsl:text>**EDITME</xsl:text>
712 <xsl:apply-templates/>
713 <xsl:text>EDITME**</xsl:text>
714 </xsl:template>
715
716 <xsl:template name="output-destdir">
717<!-- Hopefully, the current node is the first screen with role equal to root.
718 We first output stats, since we are only called if stats are needed.
719 then we output DESTDIR instructions,etc -->
720 <xsl:text>
721echo Time after tests: ${SECONDS} >> $INFOLOG
722echo Size after tests: $(sudo du -skx --exclude home /) >> $INFOLOG
723echo Time before install: ${SECONDS} >> $INFOLOG
724</xsl:text>
725 <xsl:apply-templates
726 select="userinput|following-sibling::screen[@role='root']/userinput"
727 mode="destdir"/>
728 <xsl:text>
729echo Time after install: ${SECONDS} >> $INFOLOG
730echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
731</xsl:text>
732 </xsl:template>
733
734 <xsl:template match="userinput" mode="destdir">
735 <xsl:choose>
736 <xsl:when test="./literal">
737 <xsl:call-template name="outputpkgdest">
738 <xsl:with-param name="outputstring" select="text()[1]"/>
739 </xsl:call-template>
740 <xsl:apply-templates select="literal"/>
741 <xsl:call-template name="outputpkgdest">
742 <xsl:with-param name="outputstring" select="text()[2]"/>
743 </xsl:call-template>
744 </xsl:when>
745 <xsl:otherwise>
746 <xsl:call-template name="outputpkgdest">
747 <xsl:with-param name="outputstring" select="string()"/>
748 </xsl:call-template>
749 </xsl:otherwise>
750 </xsl:choose>
751 <xsl:text>&#xA;</xsl:text>
752 </xsl:template>
753
754 <xsl:template name="outputpkgdest">
755 <xsl:param name="outputstring" select="'foo'"/>
756 <xsl:choose>
757 <xsl:when test="contains($outputstring,'make ')">
758 <xsl:choose>
759 <xsl:when test="not(starts-with($outputstring,'make'))">
760 <xsl:call-template name="outputpkgdest">
761 <xsl:with-param name="outputstring"
762 select="substring-before($outputstring,'make')"/>
763 </xsl:call-template>
764 <xsl:call-template name="outputpkgdest">
765 <xsl:with-param
766 name="outputstring"
767 select="substring-after($outputstring,
768 substring-before($outputstring,'make'))"/>
769 </xsl:call-template>
770 </xsl:when>
771 <xsl:otherwise>
772 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
773 <xsl:call-template name="outputpkgdest">
774 <xsl:with-param
775 name="outputstring"
776 select="substring-after($outputstring,'make')"/>
777 </xsl:call-template>
778 </xsl:otherwise>
779 </xsl:choose>
780 </xsl:when>
781 <xsl:when test="contains($outputstring,'ninja install')">
782 <xsl:choose>
783 <xsl:when test="not(starts-with($outputstring,'ninja install'))">
784 <xsl:call-template name="outputpkgdest">
785 <xsl:with-param name="outputstring"
786 select="substring-before($outputstring,'ninja install')"/>
787 </xsl:call-template>
788 <xsl:call-template name="outputpkgdest">
789 <xsl:with-param
790 name="outputstring"
791 select="substring-after($outputstring,
792 substring-before($outputstring,'ninja install'))"/>
793 </xsl:call-template>
794 </xsl:when>
795 <xsl:otherwise>
796 <xsl:text>DESTDIR=$PKG_DEST ninja</xsl:text>
797 <xsl:call-template name="outputpkgdest">
798 <xsl:with-param
799 name="outputstring"
800 select="substring-after($outputstring,'ninja')"/>
801 </xsl:call-template>
802 </xsl:otherwise>
803 </xsl:choose>
804 </xsl:when>
805 <xsl:otherwise> <!-- no make nor ninja in this string -->
806 <xsl:choose>
807 <xsl:when test="contains($outputstring,'&gt;/') and
808 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
809 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
810 <xsl:text>&gt;$PKG_DEST/</xsl:text>
811 <xsl:call-template name="outputpkgdest">
812 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
813 </xsl:call-template>
814 </xsl:when>
815 <xsl:when test="contains($outputstring,' /')">
816 <xsl:value-of select="substring-before($outputstring,' /')"/>
817 <xsl:text> $PKG_DEST/</xsl:text>
818 <xsl:call-template name="outputpkgdest">
819 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
820 </xsl:call-template>
821 </xsl:when>
822 <xsl:otherwise>
823 <xsl:value-of select="$outputstring"/>
824 </xsl:otherwise>
825 </xsl:choose>
826 </xsl:otherwise>
827 </xsl:choose>
828 </xsl:template>
829
830</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.