source: BLFS/xsl/scripts.xsl@ b86dfaf

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

Finally, openldap does not need .la files

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